Skip to content

Commit 047b279

Browse files
authored
Merge pull request #348 from smart-on-fhir/mikix/docker-version
docker: add git revision to version during docker build
2 parents d7abeb3 + 28cfb7b commit 047b279

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ jobs:
8686
with:
8787
load: true # just build, no push
8888
tags: smartonfhir/cumulus-etl:latest
89+
build-args: |
90+
LOCAL_VERSION=${{ github.sha }}
8991
9092
- name: Download NLP images
9193
run: |

.github/workflows/docker-hub.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ jobs:
2929
password: ${{ secrets.DOCKERHUB_TOKEN }}
3030

3131
- name: Build and push image to Docker Hub
32-
uses: docker/build-push-action@v5
32+
uses: docker/build-push-action@v6
3333
with:
3434
push: true
3535
platforms: |
3636
linux/amd64
3737
linux/arm64
3838
tags: ${{ steps.meta.outputs.tags }}
3939
labels: ${{ steps.meta.outputs.labels }}
40+
build-args: |
41+
LOCAL_VERSION=${{ github.sha }}

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ RUN pip3 install nltk
3838
RUN python3 -m nltk.downloader -d /usr/local/share/nltk_data averaged_perceptron_tagger
3939

4040
COPY . /app
41+
42+
# A local version is the trailing bit of a Python version after a plus sign, like 5.0+ubuntu1.
43+
# We use it here mostly to inject a git commit sha when building from git.
44+
ARG LOCAL_VERSION
45+
RUN [ -z "$LOCAL_VERSION" ] || sed -i "s/\(__version__.*\)\"/\1+$LOCAL_VERSION\"/" /app/cumulus_etl/__init__.py
46+
# Print the final version we're using
47+
RUN grep __version__ /app/cumulus_etl/__init__.py
48+
4149
RUN --mount=type=cache,target=/root/.cache \
4250
pip3 install /app
4351
RUN rm -r /app

0 commit comments

Comments
 (0)