Skip to content

Commit

Permalink
Make build-docker locally debuggable
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMind committed Jan 6, 2025
1 parent 1a5ef01 commit c5c8224
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
29 changes: 12 additions & 17 deletions .github/actions/build-docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ runs:
echo "git_build_url=$git_repo_url/actions/runs/${{ github.run_id }}" >> $GITHUB_OUTPUT
echo "git_sha=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "metadata_file=buildx-bake-metadata.json" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
Expand All @@ -51,33 +52,27 @@ runs:
# and to prevent multiple tags from being associated with a build
type=raw,value=${{ inputs.version }}
- name: Create .env and version.json files
shell: bash
run: |
# We only build the production image in CI
echo "DOCKER_TARGET=production" >> $GITHUB_ENV
echo "DOCKER_VERSION=${{ steps.meta.outputs.version }}" >> $GITHUB_ENV
echo "DOCKER_COMMIT=${{ steps.context.outputs.git_sha }}" >> $GITHUB_ENV
echo "DOCKER_BUILD=${{ steps.context.outputs.git_build_url }}" >> $GITHUB_ENV
echo "TAGS_FILE=${{ steps.meta.outputs.bake-file-tags }}" >> $GITHUB_ENV
echo "ANNOTATIONS_FILE=${{ steps.meta.outputs.bake-file-annotations }}" >> $GITHUB_ENV
echo "DOCKER_METADATA_FILE=buildx-bake-metadata.json" >> $GITHUB_ENV
make setup
- name: Build Image
id: build
shell: bash
run: |
make setup \
DOCKER_TARGET="production" \
DOCKER_VERSION="${{ steps.meta.outputs.version }}"
make docker_build_web \
ARGS="--file ${{ env.TAGS_FILE }} --file ${{ env.ANNOTATIONS_FILE }}" \
DOCKER_PUSH=${{ inputs.push }}
DOCKER_TAGS_FILE="${{ steps.meta.outputs.bake-file-tags }}" \
DOCKER_ANNOTATIONS_FILE="${{ steps.meta.outputs.bake-file-annotations }}" \
DOCKER_METADATA_FILE="${{ steps.context.outputs.metadata_file }}" \
DOCKER_COMMIT="${{ steps.context.outputs.git_sha }}" \
DOCKER_BUILD="${{ steps.context.outputs.git_build_url }}" \
DOCKER_PUSH="${{ inputs.push }}"
- name: Get image digest
id: build_meta
shell: bash
run: |
metadata=$(cat $DOCKER_METADATA_FILE)
metadata=$(cat ${{ steps.context.outputs.metadata_file }})
echo "digest=$(echo $metadata | jq -r '.web."containerimage.digest"')" >> $GITHUB_OUTPUT
echo "tag=$(echo $metadata | jq -r '.web."image.name"')" >> $GITHUB_OUTPUT
8 changes: 8 additions & 0 deletions Makefile-os
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ ifeq ($(DOCKER_PUSH), true)
DOCKER_BAKE_ARGS += --push
endif

ifneq ($(DOCKER_ANNOTATIONS_FILE),)
DOCKER_BAKE_ARGS += --file $(DOCKER_ANNOTATIONS_FILE)
endif

ifneq ($(DOCKER_TAGS_FILE),)
DOCKER_BAKE_ARGS += --file $(DOCKER_TAGS_FILE)
endif

DOCKER_COMPOSE_ARGS := \
-d \
--remove-orphans \
Expand Down

0 comments on commit c5c8224

Please sign in to comment.