Skip to content

Commit

Permalink
Allow setting app version in docker run command.
Browse files Browse the repository at this point in the history
  • Loading branch information
mross-ua committed Jul 28, 2024
1 parent a2b5f6a commit 141e41c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ jobs:
path: build/vcpkg_installed
save-always: true

- name: Build Docker image (with version)
if: ${{ github.ref_type == 'tag' }}
run: docker build -t kdeck-build -DAPP_VERSION=${{ github.ref_name }} .

- name: Build Docker image (without version)
if: ${{ github.ref_type != 'tag' }}
- name: Build Docker image
run: docker build -t kdeck-build .

# NOTE: We use a bind-mount instead of a volume for the build dir
Expand All @@ -60,6 +55,7 @@ jobs:
run: |
docker run \
-v "${{ github.workspace }}/build:/src/build" \
${{ github.ref_type == 'tag' && format('--env {0}', github.ref_name) || '' }} \
kdeck-build
- name: Record hash
Expand Down
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM debian:bookworm-slim

ARG APP_VERSION="0.0.0"

FROM debian:bookworm-slim

# NOTE: vcpkg packages expect various build tools to be present.
# The *-dev packages especially pull in many additional
# dependencies.
Expand Down Expand Up @@ -36,7 +36,10 @@ RUN ["./vendor/microsoft/vcpkg/bootstrap-vcpkg.sh"]

SHELL ["/bin/bash", "-c"]

ARG APP_VERSION
ENV APP_VERSION=${APP_VERSION}

#TODO it's not clear why we need CMAKE_MAKE_PROGRAM; this is supposed to be detected automatically;
# is it because the shell form of RUN doesn't capture environment variables? (a new shell is invoked)
CMD cmake -DCMAKE_MAKE_PROGRAM=make -DAPP_VERSION="$APP_VERSION" --preset release \
CMD cmake -DCMAKE_MAKE_PROGRAM=make -D APP_VERSION="${APP_VERSION}" --preset release \
&& cmake --build --preset release

0 comments on commit 141e41c

Please sign in to comment.