Browse Source

support image build without git history (fixes github action)

Fabian Peter Hammerle 2 years ago
parent
commit
a1015b3d7f
4 changed files with 11 additions and 1 deletions
  1. 1 0
      .dockerignore
  2. 5 1
      .github/workflows/container-image.yml
  3. 3 0
      CHANGELOG.md
  4. 2 0
      Dockerfile

+ 1 - 0
.dockerignore

@@ -6,4 +6,5 @@
 !Pipfile.lock
 !README.md
 !location_guessing_game_telegram_bot/
+!pyproject.toml
 !setup.py

+ 5 - 1
.github/workflows/container-image.yml

@@ -19,8 +19,12 @@ jobs:
     # > will be done directly by buildkit. [...]
     # > any file mutation in the steps that precede [...] will be ignored
     # https://github.com/marketplace/actions/build-and-push-docker-images
+    # > The commit history is not preserved.
+    # https://docs.docker.com/engine/reference/commandline/build/#git-repositories
     - uses: docker/build-push-action@v2.5.0
       with:
+        build-args: |
+          SETUPTOOLS_SCM_PRETEND_VERSION=0 # git history unavailable (see above)
         platforms: |
           linux/amd64
-          linux/arm/v7
+        # missing cffi wheel for linux/arm/v7

+ 3 - 0
CHANGELOG.md

@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 ## [Unreleased]
+### Fixed
+- `dockerfile`: support build without git history
+  (by manually setting build argument `SETUPTOOLS_SCM_PRETEND_VERSION`)
 
 ## [0.1.1] - 2021-02-14
 ### Fixed

+ 2 - 0
Dockerfile

@@ -29,6 +29,8 @@ RUN jq 'del(.default."location-guessing-game-telegram-bot", .default."sanitized-
     && pipenv install --deploy \
     && rm -rf $PIPENV_CACHE_DIR
 COPY --chown=build . $SOURCE_DIR_PATH
+# allow manual specification to support build without git history
+ARG SETUPTOOLS_SCM_PRETEND_VERSION=
 RUN pipenv install --deploy \
     && pipenv run location-guessing-game-telegram-bot --help \
     && pipenv graph \