Skip to content

Commit

Permalink
Merge pull request #1171 from lairworks/renameDockerBuildImages
Browse files Browse the repository at this point in the history
Rename Docker build images
  • Loading branch information
DanRStevens authored Nov 11, 2024
2 parents 240ddcc + b12a338 commit b853a3d
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
fail-fast: false
matrix:
image:
- "nas2d-arch:1.5"
- "build-env-nas2d-arch:1.5"
runs-on: ubuntu-latest
container:
image: "ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Build
name: Build Docker Build Env

on:
push:
Expand All @@ -8,8 +8,8 @@ on:
branches-ignore:
- 'main'
paths:
- '.github/workflows/dockerBuild.yml'
- 'docker/*'
- '.github/workflows/buildDockerBuildEnv.yml'
- 'dockerBuildEnv/*'
workflow_dispatch:

jobs:
Expand All @@ -20,8 +20,6 @@ jobs:
matrix:
platform:
- 'arch'
env:
DockerRepository: ghcr.io/${{ github.repository_owner }}

steps:
- uses: actions/checkout@v4
Expand All @@ -35,16 +33,16 @@ jobs:
id: diff
run: |
set +e
git diff --exit-code --no-patch origin/main docker/nas2d-${{ matrix.platform }}.* ; echo "modified=$?" >> $GITHUB_OUTPUT
git diff --exit-code --no-patch origin/main dockerBuildEnv/makefile dockerBuildEnv/nas2d-${{ matrix.platform }}.* ; echo "modified=$?" >> $GITHUB_OUTPUT
- name: Docker build
if: ${{ fromJSON(steps.diff.outputs.modified) }}
run: make -C docker build-image-${{ matrix.platform }}
run: make build-image-${{ matrix.platform }}

- name: Docker login
if: ${{ fromJSON(steps.diff.outputs.modified) }}
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username "${{ github.repository_owner }}" --password-stdin

- name: Docker push
if: ${{ fromJSON(steps.diff.outputs.modified) }}
run: make -C docker push-image-${{ matrix.platform }}
run: make push-image-${{ matrix.platform }}
25 changes: 13 additions & 12 deletions docker/makefile → dockerBuildEnv/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
# Capture top level folder before any Makefile includes
# Note: MAKEFILE_LIST's last entry is the last processed Makefile.
# That should be the current Makefile, assuming no includes
DockerFolder := $(abspath $(dir $(lastword ${MAKEFILE_LIST})))
TopLevelFolder := $(abspath $(DockerFolder)/..)
DockerBuildEnvFolder := $(abspath $(dir $(lastword ${MAKEFILE_LIST})))
TopLevelFolder := $(abspath $(DockerBuildEnvFolder)/..)

DockerRunFlags := --volume ${TopLevelFolder}:/code --workdir=/code --rm --tty
DockerUserFlags = --user="$(shell id --user):$(shell id --group)"
DockerRepository ?= outpostuniverse
DockerRepository ?= ghcr.io/lairworks

include $(wildcard $(DockerFolder)/nas2d-*.version.mk)
include $(wildcard $(DockerBuildEnvFolder)/nas2d-*.version.mk)

DockerFileName = ${DockerFolder}/nas2d-$*.Dockerfile
DockerFileName = ${DockerBuildEnvFolder}/nas2d-$*.Dockerfile

DockerImageName = ${DockerRepository}/nas2d-$*:${ImageVersion_$*}
DockerImageNameLatest = ${DockerRepository}/nas2d-$*:latest
DockerImageName = ${DockerRepository}/build-env-nas2d-$*
DockerImageNameTagged = ${DockerImageName}:${ImageVersion_$*}
DockerImageNameLatest = ${DockerImageName}:latest

DockerBuildRules := build-image-gcc build-image-clang build-image-mingw build-image-arch
DockerPushRules := push-image-gcc push-image-clang push-image-mingw push-image-arch
Expand All @@ -26,17 +27,17 @@ DockerDebugRootRules := root-debug-image-gcc root-debug-image-clang root-debug-i
.PHONY: ${DockerBuildRules} ${DockerPushRules} ${DockerRunRules} ${DockerDebugRules} ${DockerDebugRootRules}

${DockerBuildRules}: build-image-%:
docker build ${DockerFolder}/ --file ${DockerFileName} --tag ${DockerImageName} --tag ${DockerImageNameLatest}
docker build ${DockerBuildEnvFolder}/ --file ${DockerFileName} --tag ${DockerImageNameTagged} --tag ${DockerImageNameLatest}

${DockerPushRules}: push-image-%:
docker push ${DockerImageName}
docker push ${DockerImageNameTagged}
docker push ${DockerImageNameLatest}

${DockerRunRules}: run-image-%:
docker run ${DockerRunFlags} ${DockerUserFlags} ${DockerImageName}
docker run ${DockerRunFlags} ${DockerUserFlags} ${DockerImageNameTagged}

${DockerDebugRules}: debug-image-%:
docker run ${DockerRunFlags} --interactive ${DockerUserFlags} ${DockerImageName} bash
docker run ${DockerRunFlags} --interactive ${DockerUserFlags} ${DockerImageNameTagged} bash

${DockerDebugRootRules}: root-debug-image-%:
docker run ${DockerRunFlags} --interactive ${DockerImageName} bash
docker run ${DockerRunFlags} --interactive ${DockerImageNameTagged} bash
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ install-dependencies-darwin:

#### Docker related build rules ####

include docker/makefile
include dockerBuildEnv/makefile

#### CircleCI related build rules ####

Expand Down

0 comments on commit b853a3d

Please sign in to comment.