diff --git a/.github/workflows/docker-build-push-aws.yml b/.github/workflows/docker-build-push-aws.yml new file mode 100644 index 000000000..3f400a384 --- /dev/null +++ b/.github/workflows/docker-build-push-aws.yml @@ -0,0 +1,53 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Build and push image to Amazon ECR. + +on: + pull_request: + branches: + - main + +env: + AWS_REGION: us-east-1 # set this to your preferred AWS region, e.g. us-west-1 + ECR_REPOSITORY: mdtf/mdtf-test # set this to your Amazon ECR repository name + ECS_SERVICE: custom-service # MY_ECS_SERVICE set this to your Amazon ECS service name + ECS_CLUSTER: mdtf-east1 # MY_ECS_CLUSTER set this to your Amazon ECS cluster name + ECS_TASK_DEFINITION: ecs-task-defn.json # set this to the path to your Amazon ECS task definition + # file, e.g. .aws/task-definition.json + CONTAINER_NAME: mdtf-test-a1r # set this to the name of the container in the + # containerDefinitions section of your task definition MY_CONTAINER_NAME + +jobs: + deploy: + name: push-to-public-ecr-cache-test + runs-on: ubuntu-latest + environment: dev + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@13d241b293754004c80624b5567555c4a39ffbe3 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: Build, tag, and push image to Amazon ECR + id: build-image + uses: aradhakrishnanGFDL/docker-build-with-cache-action@master #support-aws-ecr-public + env: + ECR_REGISTRY: public.ecr.aws + IMAGE_TAG: "latest" + ECS_IMAGE: $ECR_REGISTRY/ECR_REPOSITORY:$env.IMAGE_TAG + with: + registry: public.ecr.aws + username: "${{ secrets.AWS_ACCESS_KEY_ID }}" + password: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" + image_name: c6h4h4s8/mdtf/mdtf-test + push_image_and_stages: true + image_tag: latest diff --git a/.github/workflows/docker-run-test.yml b/.github/workflows/docker-run-test.yml new file mode 100644 index 000000000..dfddcb24c --- /dev/null +++ b/.github/workflows/docker-run-test.yml @@ -0,0 +1,18 @@ +name: docker-run-minitest1 +on: + pull_request: + branches: [ main ] +jobs: + container-test-job: + runs-on: ubuntu-latest + container: + image: public.ecr.aws/c6h4h4s8/mdtf/mdtf-test:latest + env: + NODE_ENV: development + options: --cpus 1 + steps: + - name: Check PATH + run: (echo $PATH) || (echo "No path") + - name: Activate environment + shell: bash + run: (eval "$(micromamba shell hook -s bash -p ~/conda)"; micromamba activate; micromamba activate _MDTF_base;mdtf_framework.py --version) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cbc155734..b60094fd0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,10 +3,10 @@ # separate terms of service, privacy policy, and support # documentation. -name: Deploy to ECS,open +name: Deploy to ECS. Build, push image, on: - push: + pull_request: branches: - main @@ -61,7 +61,7 @@ jobs: image: public.ecr.aws/c6h4h4s8/mdtf/mdtf-test:latest - name: Deploy Amazon ECS task definition - uses: aws-actions/amazon-ecs-deploy-task-definition@de0132cf8cdedb79975c6d42b77eb7ea193cf28e + uses: aws-actions/amazon-ecs-deploy-task-definition@v1.4.10 with: task-definition: ${{ steps.task-def.outputs.task-definition }} service: ${{ env.ECS_SERVICE }} diff --git a/Dockerfile b/Dockerfile index 0170421ca..f0db5afac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,35 +1,28 @@ # Base OS -FROM ubuntu:20.04 +FROM ubuntu:latest +FROM mambaorg/micromamba:latest as micromamba + +#micromamba set up + +USER root + +RUN micromamba info + + +RUN micromamba shell hook --shell bash +#RUN micromamba create -f /proj/MDTF-diagnostics/src/conda/env_base.yml + +## # Container Metadata LABEL maintainer="20195932+wrongkindofdoctor@users.noreply.github.com" LABEL version="alpha-01" LABEL description="This is a docker image for the MDTF-diagnostics package" # Disable Prompt During Packages Installation -ARG DEBIAN_FRONTEND=noninteractive -# Update Ubuntu Software repository -RUN apt update -# Install dependencies -RUN apt install -y wget -RUN apt install -y vim -# Cleanup -RUN rm -rf /var/lib/apt/lists/* && \ - apt clean -# Install Miniconda3 -# Download the latest shell script -RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -# Change permission to execute build script -RUN chmod +x Miniconda3-latest-Linux-x86_64.sh -# Run miniconda installation script -ENV PATH="/root/miniconda3/bin:${PATH}" -ARG PATH="/root/miniconda3/bin:${PATH}" -RUN bash ./Miniconda3-latest-Linux-x86_64.sh -b -RUN rm -f Miniconda3-latest-Linux-x86_64.sh -RUN conda info -RUN conda init bash -RUN conda install -c conda-forge mamba +#ARG DEBIAN_FRONTEND=noninteractive + # Copy the MDTF-diagnostics package contents from local machine to image ENV CODE_ROOT=/proj/MDTF-diagnostics -COPY src ${CODE_ROOT}/src +COPY src ${CODE_ROOT}/src COPY data ${CODE_ROOT}/data #COPY diagnostics ${CODE_ROOT}/diagnostics COPY mdtf_framework.py ${CODE_ROOT} @@ -37,11 +30,17 @@ COPY shared ${CODE_ROOT}/shared COPY sites ${CODE_ROOT}/sites COPY tests ${CODE_ROOT}/tests # Install conda environments -ENV CONDA_ROOT=/root/miniconda3 -ENV CONDA_ENV_DIR=/root/miniconda3/envs -RUN bash ${CODE_ROOT}/src/conda/conda_env_setup.sh --all --conda_root ${CONDA_ROOT} \ - --conda_env_dir ${CONDA_ENV_DIR} +ENV CONDA_ROOT=/opt/conda/ +ENV CONDA_ENV_DIR=/opt/conda/envs + +#USER mambauser +RUN micromamba create -f /proj/MDTF-diagnostics/src/conda/env_base.yml + +ENV PATH="${PATH}:/proj/MDTF-diagnostics/" +#cRUN micromamba activate _MDTF_base # Verify installation -RUN ${CODE_ROOT}/mdtf --version +#RUN /proj/MDTF-diagnostics/mdtf_framework.py --help # Run mdtf on src/default_tests.jsonc -CMD ["${CODE_ROOT}/mdtf", "-f","${CODE_ROOT}/src/default_tests.jsonc"] +# CMD ["${CODE_ROOT}/mdtf", "-f","${CODE_ROOT}/src/default_tests.jsonc"] +#ENTRYPOINT ["micromamba activate _MDTF_base"] +CMD ["/bin/bash"] diff --git a/ecs-task-defn.json b/ecs-task-defn.json new file mode 100644 index 000000000..b8fefe348 --- /dev/null +++ b/ecs-task-defn.json @@ -0,0 +1,63 @@ +{ + "taskDefinitionArn": "arn:aws:ecs:us-east-1:430073024411:task-definition/mdtf-test-a1r:25", + "containerDefinitions": [ + { + "name": "mdtf-test-a1r", + "image": "public.ecr.aws/c6h4h4s8/mdtf/mdtf-test:latest", + "cpu": 0, + "portMappings": [], + "essential": true, + "environment": [], + "mountPoints": [], + "volumesFrom": [], + "logConfiguration": { + "logDriver": "awslogs", + "options": { + "awslogs-group": "/ecs/mdtf-test-a1r", + "awslogs-region": "us-east-1", + "awslogs-stream-prefix": "ecs" + } + } + } + ], + "family": "mdtf-test-a1r", + "taskRoleArn": "arn:aws:iam::430073024411:role/ecsTaskExecutionRole", + "executionRoleArn": "arn:aws:iam::430073024411:role/ecsTaskExecutionRole", + "networkMode": "awsvpc", + "revision": 25, + "volumes": [], + "status": "ACTIVE", + "requiresAttributes": [ + { + "name": "com.amazonaws.ecs.capability.logging-driver.awslogs" + }, + { + "name": "ecs.capability.execution-role-awslogs" + }, + { + "name": "com.amazonaws.ecs.capability.docker-remote-api.1.19" + }, + { + "name": "com.amazonaws.ecs.capability.task-iam-role" + }, + { + "name": "com.amazonaws.ecs.capability.docker-remote-api.1.18" + }, + { + "name": "ecs.capability.task-eni" + } + ], + "placementConstraints": [], + "compatibilities": [ + "EC2", + "FARGATE" + ], + "requiresCompatibilities": [ + "FARGATE" + ], + "cpu": "4096", + "memory": "8192", + "registeredAt": "2022-10-20T16:01:08.915Z", + "registeredBy": "arn:aws:iam::430073024411:user/a1r", + "tags": [] +}