From 5bf032a5e06ae523e317de79f322111c8b939859 Mon Sep 17 00:00:00 2001 From: Calvin Date: Mon, 12 Feb 2024 23:30:58 +0200 Subject: [PATCH 1/2] Changed the base image to laxzal/laxzal:latest so this reduces the code required for maintaining --- Dockerfile | 49 +++++++++++-------------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/Dockerfile b/Dockerfile index 815e6b91..ad05b982 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Using the a base image of rmgpy:latest from DockerHub - Not the official version but a custom version that is smaller in size -FROM --platform=linux/amd64 laxzal/rmgpy:latest +FROM --platform=linux/amd64 laxzal/arc:latest USER rmguser @@ -7,32 +7,6 @@ USER rmguser # Change directory to Code WORKDIR /home/rmguser/Code -# Clone main branch ARC repository from GitHub and set as working directory -RUN git clone -b main https://github.com/ReactionMechanismGenerator/ARC.git -WORKDIR /home/rmguser/Code/ARC - -# Set environment variables for the Docker run and container -ENV PYTHONPATH="${PYTHONPATH}:/home/rmguser/Code/ARC" -ENV PYTHONPATH="${PYTHONPATH}:/home/rmguser/Code/AutoTST" -ENV PYTHONPATH="${PYTHONPATH}:/home/rmguser/Code/TS-GCN" -ENV PATH /home/rmguser/Code/ARC:$PATH - -# Install ARC Environment -RUN micromamba create -y -f environment.yml && \ - micromamba clean --all -f -y && \ - rm -rf /home/rmguser/.cache/yarn \ - rm -rf /home/rmguser/.cache/pip &&\ - rm -rf /home/rmguser/.cache/pip && \ - find -name '*.a' -delete && \ - find -name '*.pyc' -delete && \ - find -name '__pycache__' -type d -exec rm -rf '{}' '+' && \ - find /opt/conda/envs/arc_env/lib/python3.7/site-packages/scipy -name 'tests' -type d -exec rm -rf '{}' '+' && \ - find /opt/conda/envs/arc_env/lib/python3.7/site-packages/numpy -name 'tests' -type d -exec rm -rf '{}' '+' && \ - find /opt/conda/envs/arc_env/lib/python3.7/site-packages/pandas -name 'tests' -type d -exec rm -rf '{}' '+' && \ - find /opt/conda/envs/arc_env/lib/python3.7/site-packages -name '*.pyx' -delete && \ - rm -rf /opt/conda/envs/arc_env/lib/python3.7/site-packages/uvloop/loop.c &&\ - make clean - # Install T3 # Change directory to Code @@ -54,21 +28,20 @@ RUN micromamba create -y -f environment.yml && \ find /opt/conda/envs/t3_env/lib/python3.7/site-packages -name '*.pyx' -delete \ && find /opt/conda/ -follow -type f -name '*.a' -delete \ && find /opt/conda/ -follow -type f -name '*.pyc' -delete \ - && find /opt/conda/ -follow -type f -name '*.js.map' -delete + && find /opt/conda/ -follow -type f -name '*.js.map' -delete # Add alias to bashrc - rmge to activate the environment # These commands are not necessary for the Docker image to run, but they are useful for the user -RUN echo "alias arce='micromamba activate arc_env'" >> ~/.bashrc \ - && echo "export PYTHONPATH=/home/rmguser/Code/ARC:$PYTHONPATH" >> ~/.bashrc \ - && echo "export PYTHONPATH=\"${PYTHONPATH}:/home/rmguser/Code/AutoTST\"" >> ~/.bashrc \ - && echo "alias arc='python /home/rmguser/Code/ARC/ARC.py input.yml'" >> ~/.bashrc \ - && echo "export PYTHONPATH=\"${PYTHONPATH}:/home/rmguser/Code/TS-GCN\"" >> ~/.bashrc \ - && echo "alias deact='micromamba deactivate'" >> ~/.bashrc \ - && echo "export arc_path='/home/rmguser/Code/ARC/'" >> ~/.bashrc \ +RUN echo "export arc_path='/home/rmguser/Code/ARC/'" >> ~/.bashrc \ && echo "export t3_path='/home/rmguser/Code/T3/'" >> ~/.bashrc \ - && echo "alias arccode='cd \$arc_path'" >> ~/.bashrc \ && echo "alias t3code='cd \$t3_path'" >> ~/.bashrc \ && echo "alias t3e='micromamba activate t3_env'" >> ~/.bashrc \ - && echo "alias t3='python /home/rmguser/Code/T3/T3.py input.yml'" >> ~/.bashrc + && echo "alias t3='python /home/rmguser/Code/T3/T3.py input.yml'" >> ~/.bashrc + +# Set the wrapper script as the entrypoint +ENTRYPOINT ["/home/rmguser/entrywrapper.sh"] -SHELL ["/bin/bash", "-c"] +# Activate the T3 environment +WORKDIR /home/rmguser/ +ARG MAMBA_DOCKERFILE_ACTIVATE=1 +ENV ENV_NAME=t3_env From 26cb19b1e14eefd000b8d2030b6d0ab2ba911627 Mon Sep 17 00:00:00 2001 From: Calvin Date: Tue, 13 Feb 2024 18:28:18 +0200 Subject: [PATCH 2/2] Run Docker CI no push during PR --- .github/workflows/docker_build.yml | 34 ++++++++++++------------------ 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index 1a6ef93b..d1a3ee36 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -4,19 +4,26 @@ name: Docker Image Build and Push #https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions + on: schedule: - cron: "0 0 */7 * *" # every 7 days push: branches: - main + paths: + - "Dockerfile" + - "devtools/Dockerfile_rmgpy" + - ".github/workflows/docker_build.yml" pull_request: - types: [opened, synchronize, reopened] branches: - main paths: - - "./Dockerfile" - - "./devtools/Dockerfile_rmgpy" + - "Dockerfile" + - "devtools/Dockerfile_rmgpy" + - ".github/workflows/docker_build.yml" + types: [opened, synchronize, reopened, ready_for_review] + #workflow_dispatch: # Add this line to enable manual trigger permissions: contents: read @@ -24,7 +31,7 @@ permissions: jobs: ci-check: - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref != 'refs/heads/main') runs-on: ubuntu-latest steps: - name: Free Disk Space (Ubuntu) @@ -43,28 +50,15 @@ jobs: swap-storage: false - name: Checkout uses: actions/checkout@v4.1.1 - # Add steps for CI checks of the Dockerfile - - name: Login to Docker Hub - uses: docker/login-action@v3.0.0 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3.0.0 - - name: Build RMG-Py - uses: docker/build-push-action@v5.0.0 - with: - context: . - file: ./devtools/Dockerfile_rmgpy - push: false - tags: ${{ secrets.DOCKERHUB_USERNAME }}/rmgpy:latest - - name: Build T3 - uses: docker/build-push-action@v5.0.0 + # Add steps for CI checks of the Dockerfile + - name: Build Docker Image (No Push) + uses: docker/build-push-action@v5.1.0 with: context: . file: ./Dockerfile push: false - tags: ${{ secrets.DOCKERHUB_USERNAME }}/thetandemtool-t3:latest build-and-push: if: github.event_name == 'push' && github.ref == 'refs/heads/main'