Skip to content

Commit

Permalink
Merge pull request #15 from NASA-IMPACT/fix/prod_env
Browse files Browse the repository at this point in the history
Fix/prod env
  • Loading branch information
sharkinsspatial authored Jan 18, 2021
2 parents 120b6a8 + 4bf7ec9 commit ef0ce23
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 60 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build_push_prod_ecr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: build_push_to_prod_ecr

on:
release:
branches: [ master ]
types: [ published ]

jobs:
build_push_to_prod_ecr:
runs-on: ubuntu-latest

steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Build image
run: docker build . --tag hls-base-c2

- name: Push to prod ECR
id: push-prod-ecr
uses: jwalton/gh-ecr-push@v1
with:
access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
region: us-west-2
local-image: hls-base-c2
image: hls-base-c2:${GITHUB_REF##*/}
37 changes: 37 additions & 0 deletions .github/workflows/build_push_to_ecr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: build_push_to_ecr

on:
push:
branches: [ dev ]

jobs:
build_push_to_ecr:
runs-on: ubuntu-latest

steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Build image
run: docker build . --tag hls-base-c2

- name: Push to latest ECR
id: push-latest-ecr
uses: jwalton/gh-ecr-push@v1
with:
access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
region: us-west-2
local-image: hls-base-c2
image: hls-base-c2
39 changes: 17 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,42 @@
ARG AWS_ACCOUNT_ID
FROM ${AWS_ACCOUNT_ID}.dkr.ecr.us-west-2.amazonaws.com/espa/external:latest
FROM 018923174646.dkr.ecr.us-west-2.amazonaws.com/espa/external-c2:latest
ENV PREFIX=/usr/local \
SRC_DIR=/usr/local/src \
ESPAINC=/usr/local/include \
ESPALIB=/usr/local/lib \
L8_AUX_DIR=/usr/local/src \
ECS_ENABLE_TASK_IAM_ROLE=true \
OMP_NUM_THREADS=4 \
PYTHONPATH="${PYTHONPATH}:${PREFIX}/lib/python2.7/site-packages"
PYTHONPATH="${PYTHONPATH}:${PREFIX}/lib/python3.6/site-packages" \
ESPA_SCHEMA="${PREFIX}/schema/espa_internal_metadata_v2_2.xsd"

RUN pip install scipy gsutil awscli gdal~=2.4
RUN pip3 install scipy gsutil awscli gdal~=2.4
RUN yum -y install java-1.8.0-openjdk-devel
COPY ./matlabenv /etc/environment
RUN cd ${SRC_DIR} \
&& wget -q --no-check-certificate --no-proxy 'http://fmask4installer.s3.amazonaws.com/Fmask_4_3_Linux_mcr.install' \
&& chmod +x Fmask_4_3_Linux_mcr.install \
&& ln -s /etc/ssl/certs/ca-bundle.trust.crt /etc/ssl/certs/ca-certificates.crt \
&& ./Fmask_4_3_Linux_mcr.install -destinationFolder /usr/local/MATLAB -agreeToLicense yes -mode silent \
&& rm Fmask_4_3_Linux_mcr.install
RUN yum -y install libXt

RUN REPO_NAME=espa-product-formatter \
&& cd $SRC_DIR \
&& git clone --single-branch --branch collection2 https://github.com/NASA-IMPACT/${REPO_NAME}.git ${REPO_NAME} \
&& git clone -b v3.0.2 https://github.com/NASA-IMPACT/${REPO_NAME}.git ${REPO_NAME} \
&& cd ${REPO_NAME} \
&& make BUILD_STATIC=yes ENABLE_THREADING=yes \
&& make install \
&& cd $SRC_DIR \
&& rm -rf ${REPO_NAME}

RUN REPO_NAME=espa-surface-reflectance \
&& cd $SRC_DIR \
&& git clone https://github.com/developmentseed/${REPO_NAME}.git \
&& git clone -b eros-collection2-3.0.5 https://github.com/NASA-IMPACT/${REPO_NAME}.git \
&& cd ${REPO_NAME} \
&& make BUILD_STATIC=yes ENABLE_THREADING=yes \
&& make install \
&& make install-lasrc-aux \
&& cd $SRC_DIR \
&& rm -rf ${REPO_NAME}

RUN yum -y install java-1.8.0-openjdk-devel
COPY ./matlabenv /etc/environment

RUN pip install --upgrade git+https://github.com/USGS-EROS/espa-python-library.git@v1.1.0#espa

RUN cd ${SRC_DIR} \
&& wget --no-check-certificate --no-proxy 'http://fmask4installer.s3.amazonaws.com/Fmask_4_2_Linux_mcr.install' \
&& chmod +x Fmask_4_2_Linux_mcr.install \
&& ln -s /etc/ssl/certs/ca-bundle.trust.crt /etc/ssl/certs/ca-certificates.crt \
&& ./Fmask_4_2_Linux_mcr.install -destinationFolder /usr/local/MATLAB -agreeToLicense yes -mode silent \
&& rm Fmask_4_2_Linux_mcr.install

RUN yum -y install libXt
RUN ln -fs /usr/bin/python3 /usr/bin/python
RUN pip3 install --upgrade git+https://github.com/repository-preservation/espa-python-library@v2.0.0#espa

ENTRYPOINT ["/bin/sh", "-c"]
25 changes: 7 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
## hls-base

This repository contains a base Dockerfile for shared libraries for HLS landast and sentinel processing.

### Pre-requisites
The `lasrc` and `hls` code requires a number of [dependencies](https://github.com/nasa-impact/espa-surface-reflectance/tree/master/lasrc#dependencies). To manage these dependencies in a more streamlined way the `Dockerfile` uses a base image which can be built using the `usgs.espa.centos.external` template defined in the [espa-dockerfiles](https://github.com/nasa-impact/espa-dockerfiles) repository.

The `lasrc` and `hls` code requires a number of [dependencies](https://github.com/developmentseed/espa-surface-reflectance/tree/master/lasrc#dependencies). To manage these dependencies in a more streamlined way the `Dockerfile` uses a base image which can be built using the `usgs.espa.centos.external` template defined in the [espa-dockerfiles](https://github.com/developmentseed/espa-dockerfiles) repository.

See the instructions in the [espa-dockerfiles](https://github.com/developmentseed/espa-dockerfiles) repository for building the external dependencies image.
See the instructions in the [espa-dockerfiles](https://github.com/nasa-impact/espa-dockerfiles) repository for building the external dependencies image.

Specifically, you will need to run `make centos.base` and `make centos.external`.

After building the dependencies image, following the steps outlined [here](https://docs.aws.amazon.com/AmazonECR/latest/userguide/ECR_AWSCLI.html) you can tag this image as `<AWS_ACCOUNT_ID>.dkr.ecr.us-west-2.amazonaws.com/espa/external` and push it to ECR.
After building the dependencies image, following the steps outlined [here](https://docs.aws.amazon.com/AmazonECR/latest/userguide/ECR_AWSCLI.html) you can tag this image as `018923174646.dkr.ecr.us-west-2.amazonaws.com/espa/external` and push it to ECR.


After building your dependencies image and pushing it to ECR you can build the `hls-base` image with:

```shell
$ docker build --no-cache --build-arg AWS_ACCOUNT_ID="${AWS_ACCOUNT_ID}" -t hls-base .
```

Note: The command above assumes you have exported an environment variable `AWS_ACCOUNT_ID` which references the AWS account where the espa/external reference image is stored.

You can then tag and push this `hls-base` image as `<AWS_ACCOUNT_ID>.dkr.ecr.us-west-2.amazonaws.com/hls-base` and push it to ECR.

```shell
$ docker tag hls-base "${AWS_ACCOUNT_ID}.dkr.ecr.us-west-2.amazonaws.com/hls-base"
```

```shell
$ docker push "${AWS_ACCOUNT_ID}.dkr.ecr.us-west-2.amazonaws.com/hls-base"
$ docker build --no-cache -t hls-base .
```
### CI
The repository contains two CI workflows. When commits are pushed to the collection2 branch a new image is built and pushed to ECR with no tag.

When a new release is created from collection2 a new image is built and pushed to ECR with the release version as a tag.
20 changes: 0 additions & 20 deletions download.sh

This file was deleted.

0 comments on commit ef0ce23

Please sign in to comment.