Skip to content

Commit

Permalink
Fixing more docker related stuff (#141)
Browse files Browse the repository at this point in the history
* [bug] fixing docker build

* [feat] new dockerfile, passes tests

* [feat] Adding comments

* [fix] even faster caching

* [info] commenting dockerfile

* [feat] added no root, unsure if it would change anything here
  • Loading branch information
ctr26 authored Aug 7, 2024
1 parent d28ce99 commit 5d91c7a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/publish_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./
working-directory: .
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 2
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/[email protected]
with:
Expand All @@ -32,17 +32,17 @@ jobs:
- name: Build and push Docker image (version tag)
uses: docker/[email protected]
with:
context: ./
dockerfile: api/Dockerfile
context: .
file: api/Dockerfile
push: true
tags: ghcr.io/${{ steps.image-label.outputs.image_name }}:${{ steps.image-label.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push Docker image (latest tag)
if: steps.check-version.outputs.current-version
uses: docker/[email protected]
with:
context: ./
dockerfile: api/Dockerfile
context: .
file: api/Dockerfile
push: true
tags: ghcr.io/${{ steps.image-label.outputs.image_name }}:latest
labels: ${{ steps.meta.outputs.labels }}
24 changes: 14 additions & 10 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ ENV PATH=/root/.local/bin:$PATH
WORKDIR /bia-integrator

# only add poetry.lock if it exists (building on local)
ADD ./api/poetry.lock* api/poetry.lock
ADD ./api/pyproject.toml api/pyproject.toml
ADD api/poetry.lock* api/poetry.lock
ADD api/pyproject.toml api/pyproject.toml

# This needed to be added because it's a poetry dep
ADD bia-shared-datamodels bia-shared-datamodels

WORKDIR /bia-integrator/api
RUN poetry lock
RUN poetry install
# Everything up to here should be reused most times

# add the actual project, which is what is often changed in between two different container builds
ADD . /bia-integrator

CMD ["poetry", "run", "uvicorn", "--workers", "4", "--port", "8080", "--log-config", "./src/log_config.yml", "--host", "0.0.0.0", "api.app:app"]

# This will now cache unless theres changes to the lock file, or the pyproject.toml, or bia-shared-datamodels
RUN poetry install --no-root

# Add the rest of the files
# The previous layers will cache fully and only this layer will be rebuilt if there are changes to the files.

ADD . ..

CMD ["poetry", "run", "uvicorn", "--workers", "4", "--port", "8080", "--log-config", "src/log_config.yml", "--host", "0.0.0.0", "api.app:app"]

0 comments on commit 5d91c7a

Please sign in to comment.