-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate off Anaconda to Poetry and create dedicated RMG-Py builder image #165
Draft
DarkAce65
wants to merge
10
commits into
comocheng:master
Choose a base branch
from
DarkAce65:migrate-off-anaconda
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c889c53
Replace conda with poetry
DarkAce65 63bb31e
Rework build Dockerfile to output RMG-Py
DarkAce65 f62430c
Replace conda with poetry in application container
DarkAce65 662a3fa
Create multi-stage build with RMG-Py and application
DarkAce65 78e83a3
Clean up docker compose files
DarkAce65 1288d5e
Split out RMG-Py image for better CI/CD performance
DarkAce65 a4b2215
use poetry env for python commands
kiancm de98429
add RMG-models repo to container via context
kiancm e96076d
build application and all images on Docker Hub
kiancm 13b89f9
rename rmgpy -> rmg
kiancm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Docker Builds | ||
on: | ||
push: | ||
branches: [ master ] | ||
jobs: | ||
docker_builds: | ||
name: Docker Builds | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout main | ||
- uses: actions/checkout@v2 | ||
with: | ||
path: main | ||
- name: Checkout RMG-models | ||
- uses: actions/checkout@v2 | ||
with: | ||
repository: comocheng/RMG-models | ||
token: ${{ secrets.PAT }} | ||
path: rmg-models | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
- name: Build RMG Image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
file: main/Dockerfile.rmg | ||
push: true | ||
tags: comocheng/kms-rmg:latest | ||
- name: Build Application Image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
tags: comocheng/kms:latest |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
name: CI/CD | ||
name: CI | ||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
types: [ opened, synchronize, ready_for_review ] | ||
jobs: | ||
testing: | ||
name: Testing | ||
tests: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
if: github.event.pull_request.draft == false | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run Tests | ||
run: | | ||
echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin | ||
docker pull ghcr.io/comocheng/kineticmodelssite/kms-build:latest | ||
cp .env.dev .env | ||
docker volume create rmg-models | ||
docker-compose run web ./bin/test.sh --rm | ||
- name: Tests | ||
run: docker-compose run web ./bin/test.sh --rm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
FROM ghcr.io/comocheng/kineticmodelssite/kms-build:latest | ||
# Fetch RMG-Py build | ||
FROM comocheng/kms-rmg:latest as rmg | ||
|
||
COPY environment.yml /app/ | ||
RUN conda config --set channel_priority strict | ||
RUN conda env update --prefix $ENV_PREFIX --file environment.yml | ||
RUN conda clean -afy | ||
ENV PATH /kms_env/bin:$PATH | ||
ENV CONDA_DEFAULT_ENV /kms_env | ||
RUN source activate /kms_env | ||
# Application | ||
FROM python:3.9-alpine | ||
|
||
COPY . /app/ | ||
ENV PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
POETRY_HOME="/opt/poetry" \ | ||
POETRY_NO_INTERACTION=1 | ||
|
||
COPY --from=rmg /rmg/RMG-Py/rmgpy /rmgpy | ||
|
||
RUN apk add --no-cache curl \ | ||
&& (curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -) | ||
ENV PATH="$POETRY_HOME/bin:$PATH" \ | ||
PYTHONPATH="/rmgpy:$PYTHONPATH" | ||
|
||
WORKDIR /app | ||
|
||
COPY main/pyproject.toml poetry.lock ./ | ||
RUN poetry install --no-dev --no-interaction | ||
|
||
COPY rmg-models/ /rmg-models | ||
COPY main/ . | ||
|
||
CMD [ "./bin/entrypoint.sh" ] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Builds RMG-Py from source to /rmg/RMG-Py/rmgpy | ||
FROM continuumio/miniconda3:latest | ||
|
||
RUN apt update && apt -y install \ | ||
g++ \ | ||
gcc \ | ||
git \ | ||
make | ||
|
||
WORKDIR /rmg | ||
RUN git clone https://github.com/ReactionMechanismGenerator/RMG-Py.git \ | ||
&& git clone https://github.com/ReactionMechanismGenerator/RMG-database.git | ||
|
||
WORKDIR /rmg/RMG-Py | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
RUN conda env create -v --file environment.yml | ||
SHELL ["conda", "run", "-n", "rmg_env", "/bin/bash", "-c"] | ||
RUN make | ||
|
||
WORKDIR /rmg/RMG-Py/rmgpy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
#!/bin/bash | ||
|
||
python manage.py collectstatic --noinput | ||
python manage.py migrate --noinput | ||
gunicorn kms.wsgi --bind 0.0.0.0:8000 | ||
poetry run python manage.py migrate --noinput | ||
poetry run gunicorn kms.wsgi --bind 0.0.0.0:8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,24 @@ | ||
version: "3.8" | ||
version: "3.7" | ||
|
||
services: | ||
db: | ||
image: postgres | ||
env_file: .env.dev | ||
ports: | ||
- "5432:5432" | ||
env_file: | ||
- ./.env.dev | ||
debug: | ||
build: . | ||
tty: true | ||
env_file: | ||
- ./.env.dev | ||
env_file: .env.dev | ||
volumes: | ||
- .:/app | ||
- rmg-models:/app/rmg-models | ||
- conda:/kms_env | ||
ports: | ||
- "5678:5678" | ||
- "8080:8080" | ||
depends_on: | ||
- db | ||
|
||
volumes: | ||
rmg-models: | ||
external: true | ||
conda: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This volume should no longer be necessary |
||
external: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that RMG-Py is not specified as a dependency in the
pyproject.toml
- the dependency is added to the PYTHONPATH here