Browse Source

support image build without git history; setup github action verifying docker build succeeds

Fabian Peter Hammerle 2 years ago
parent
commit
a7223fc812
4 changed files with 36 additions and 0 deletions
  1. 1 0
      .dockerignore
  2. 30 0
      .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

+ 30 - 0
.github/workflows/container-image.yml

@@ -0,0 +1,30 @@
+# sync with https://github.com/fphammerle/docker-onion-service/blob/master/.github/workflows/container-image.yml
+
+name: container image
+
+on:
+  push:
+  pull_request:
+  schedule:
+  - cron: '0 20 * * 5'
+
+jobs:
+  docker-build:
+    runs-on: ubuntu-20.04
+    steps:
+    - uses: docker/setup-qemu-action@v1.2.0
+    - uses: docker/setup-buildx-action@v1.3.0
+    # > By default, this action uses the Git context so you don't need to use
+    # > the actions/checkout action to checkout the repository because this
+    # > 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
+        # 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 \