Skip to content

Commit

Permalink
Merge pull request #149 from ReactionMechanismGenerator/dockerfile_ba…
Browse files Browse the repository at this point in the history
…se_img

Dockerfile base img
  • Loading branch information
calvinp0 authored Feb 13, 2024
2 parents 9df7899 + 26cb19b commit 73be4fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 58 deletions.
34 changes: 14 additions & 20 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,34 @@ 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
pull-requests: write

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)
Expand All @@ -43,28 +50,15 @@ jobs:
swap-storage: false
- name: Checkout
uses: actions/[email protected]
# Add steps for CI checks of the Dockerfile
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Build RMG-Py
uses: docker/[email protected]
with:
context: .
file: ./devtools/Dockerfile_rmgpy
push: false
tags: ${{ secrets.DOCKERHUB_USERNAME }}/rmgpy:latest
- name: Build T3
uses: docker/[email protected]
# Add steps for CI checks of the Dockerfile
- name: Build Docker Image (No Push)
uses: docker/[email protected]
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'
Expand Down
49 changes: 11 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,12 @@
# 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

# Installing ARC
# 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
Expand All @@ -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

0 comments on commit 73be4fa

Please sign in to comment.