Skip to content

Commit

Permalink
Merge pull request #348 from smart-on-fhir/mikix/docker-version
Browse files Browse the repository at this point in the history
docker: add git revision to version during docker build
  • Loading branch information
mikix authored Sep 25, 2024
2 parents d7abeb3 + 28cfb7b commit 047b279
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ jobs:
with:
load: true # just build, no push
tags: smartonfhir/cumulus-etl:latest
build-args: |
LOCAL_VERSION=${{ github.sha }}
- name: Download NLP images
run: |
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/docker-hub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push image to Docker Hub
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
push: true
platforms: |
linux/amd64
linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
LOCAL_VERSION=${{ github.sha }}
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ RUN pip3 install nltk
RUN python3 -m nltk.downloader -d /usr/local/share/nltk_data averaged_perceptron_tagger

COPY . /app

# A local version is the trailing bit of a Python version after a plus sign, like 5.0+ubuntu1.
# We use it here mostly to inject a git commit sha when building from git.
ARG LOCAL_VERSION
RUN [ -z "$LOCAL_VERSION" ] || sed -i "s/\(__version__.*\)\"/\1+$LOCAL_VERSION\"/" /app/cumulus_etl/__init__.py
# Print the final version we're using
RUN grep __version__ /app/cumulus_etl/__init__.py

RUN --mount=type=cache,target=/root/.cache \
pip3 install /app
RUN rm -r /app
Expand Down

0 comments on commit 047b279

Please sign in to comment.