From 48ff1982d22a81486129f5fc1c93afb63dd62f4b Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Sun, 10 Nov 2024 22:56:45 -0700 Subject: [PATCH 01/10] Rename Make variable to `DockerImageNameTagged` --- docker/makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker/makefile b/docker/makefile index 1f7f2c99..92f76a20 100644 --- a/docker/makefile +++ b/docker/makefile @@ -14,7 +14,7 @@ include $(wildcard $(DockerFolder)/nas2d-*.version.mk) DockerFileName = ${DockerFolder}/nas2d-$*.Dockerfile -DockerImageName = ${DockerRepository}/nas2d-$*:${ImageVersion_$*} +DockerImageNameTagged = ${DockerRepository}/nas2d-$*:${ImageVersion_$*} DockerImageNameLatest = ${DockerRepository}/nas2d-$*:latest DockerBuildRules := build-image-gcc build-image-clang build-image-mingw build-image-arch @@ -26,17 +26,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 ${DockerFolder}/ --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 From b4c85c7724e9c944571fd8f292e47d388d9cb7d9 Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Sun, 10 Nov 2024 22:59:23 -0700 Subject: [PATCH 02/10] Extra common Make variable `DockerImageName` --- docker/makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/makefile b/docker/makefile index 92f76a20..05654592 100644 --- a/docker/makefile +++ b/docker/makefile @@ -14,8 +14,9 @@ include $(wildcard $(DockerFolder)/nas2d-*.version.mk) DockerFileName = ${DockerFolder}/nas2d-$*.Dockerfile -DockerImageNameTagged = ${DockerRepository}/nas2d-$*:${ImageVersion_$*} -DockerImageNameLatest = ${DockerRepository}/nas2d-$*:latest +DockerImageName = ${DockerRepository}/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 From 120e9e2bd88f3788d53bc145504312f204aac28a Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Sun, 10 Nov 2024 23:05:34 -0700 Subject: [PATCH 03/10] Allow changes to the `makefile` to rebuild Docker images Naming is controlled by the `makefile`, and would require rebuilding images if it were to change. As such, it should be included in the set of changed files that will trigger a rebuild for any given platform. --- .github/workflows/dockerBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerBuild.yml b/.github/workflows/dockerBuild.yml index a94dbe35..350a60df 100644 --- a/.github/workflows/dockerBuild.yml +++ b/.github/workflows/dockerBuild.yml @@ -35,7 +35,7 @@ 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 docker/makefile docker/nas2d-${{ matrix.platform }}.* ; echo "modified=$?" >> $GITHUB_OUTPUT - name: Docker build if: ${{ fromJSON(steps.diff.outputs.modified) }} From a3c12fc4a0238c0a7972deed496be27b8214ddbc Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Sun, 10 Nov 2024 23:15:09 -0700 Subject: [PATCH 04/10] Rename Docker images to clearly indicate a build environment We don't want to confuse people by suggesting the images contain a fully built NAS2D library. Rather, they are the build environments needed to build NAS2D, as used by the CI workflows. --- docker/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/makefile b/docker/makefile index 05654592..f098ffae 100644 --- a/docker/makefile +++ b/docker/makefile @@ -14,7 +14,7 @@ include $(wildcard $(DockerFolder)/nas2d-*.version.mk) DockerFileName = ${DockerFolder}/nas2d-$*.Dockerfile -DockerImageName = ${DockerRepository}/nas2d-$* +DockerImageName = ${DockerRepository}/build-env-nas2d-$* DockerImageNameTagged = ${DockerImageName}:${ImageVersion_$*} DockerImageNameLatest = ${DockerImageName}:latest From 4b2452b2b8d2424bcd44c7782274ce30fff8b14a Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Sun, 10 Nov 2024 23:25:11 -0700 Subject: [PATCH 05/10] Update Docker image name used by GitHub Actions --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e26661a4..ac9b1d35 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 }}" From 100d398a92ee991a0794f96b00b3cdbd2ad30a99 Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Sun, 10 Nov 2024 23:46:50 -0700 Subject: [PATCH 06/10] Remove change folder before running `make` for Docker builds The Docker build commands and imported into the main `makefile`, so can be run from there. There is no need to explicitly specify the subfolder. This simplifies renaming the subfolder. --- .github/workflows/dockerBuild.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dockerBuild.yml b/.github/workflows/dockerBuild.yml index 350a60df..5ab01595 100644 --- a/.github/workflows/dockerBuild.yml +++ b/.github/workflows/dockerBuild.yml @@ -39,7 +39,7 @@ jobs: - 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) }} @@ -47,4 +47,4 @@ jobs: - name: Docker push if: ${{ fromJSON(steps.diff.outputs.modified) }} - run: make -C docker push-image-${{ matrix.platform }} + run: make push-image-${{ matrix.platform }} From 576eca89d306d935939e2de69c3adde1a2b20753 Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Sun, 10 Nov 2024 23:49:17 -0700 Subject: [PATCH 07/10] Rename Make variable to `DockerBuildEnvFolder` --- docker/makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/makefile b/docker/makefile index f098ffae..611e50d1 100644 --- a/docker/makefile +++ b/docker/makefile @@ -3,16 +3,16 @@ # 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 -include $(wildcard $(DockerFolder)/nas2d-*.version.mk) +include $(wildcard $(DockerBuildEnvFolder)/nas2d-*.version.mk) -DockerFileName = ${DockerFolder}/nas2d-$*.Dockerfile +DockerFileName = ${DockerBuildEnvFolder}/nas2d-$*.Dockerfile DockerImageName = ${DockerRepository}/build-env-nas2d-$* DockerImageNameTagged = ${DockerImageName}:${ImageVersion_$*} @@ -27,7 +27,7 @@ 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 ${DockerImageNameTagged} --tag ${DockerImageNameLatest} + docker build ${DockerBuildEnvFolder}/ --file ${DockerFileName} --tag ${DockerImageNameTagged} --tag ${DockerImageNameLatest} ${DockerPushRules}: push-image-%: docker push ${DockerImageNameTagged} From d629d1badff96489402aa0867ec17735703b83c8 Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Sun, 10 Nov 2024 23:49:42 -0700 Subject: [PATCH 08/10] Rename `docker` folder to `dockerBuildEnv` This is perhaps a better description of the folder contents. For apps, we might expect a "docker" folder to be for building images that contain the app. What we are doing here is building images that can be used to build the library. --- .github/workflows/dockerBuild.yml | 4 ++-- {docker => dockerBuildEnv}/makefile | 0 {docker => dockerBuildEnv}/nas2d-arch.Dockerfile | 0 {docker => dockerBuildEnv}/nas2d-arch.version.mk | 0 {docker => dockerBuildEnv}/nas2d-clang.Dockerfile | 0 {docker => dockerBuildEnv}/nas2d-clang.version.mk | 0 {docker => dockerBuildEnv}/nas2d-gcc.Dockerfile | 0 {docker => dockerBuildEnv}/nas2d-gcc.version.mk | 0 {docker => dockerBuildEnv}/nas2d-mingw.Dockerfile | 0 {docker => dockerBuildEnv}/nas2d-mingw.version.mk | 0 makefile | 2 +- 11 files changed, 3 insertions(+), 3 deletions(-) rename {docker => dockerBuildEnv}/makefile (100%) rename {docker => dockerBuildEnv}/nas2d-arch.Dockerfile (100%) rename {docker => dockerBuildEnv}/nas2d-arch.version.mk (100%) rename {docker => dockerBuildEnv}/nas2d-clang.Dockerfile (100%) rename {docker => dockerBuildEnv}/nas2d-clang.version.mk (100%) rename {docker => dockerBuildEnv}/nas2d-gcc.Dockerfile (100%) rename {docker => dockerBuildEnv}/nas2d-gcc.version.mk (100%) rename {docker => dockerBuildEnv}/nas2d-mingw.Dockerfile (100%) rename {docker => dockerBuildEnv}/nas2d-mingw.version.mk (100%) diff --git a/.github/workflows/dockerBuild.yml b/.github/workflows/dockerBuild.yml index 5ab01595..4a2c56ae 100644 --- a/.github/workflows/dockerBuild.yml +++ b/.github/workflows/dockerBuild.yml @@ -9,7 +9,7 @@ on: - 'main' paths: - '.github/workflows/dockerBuild.yml' - - 'docker/*' + - 'dockerBuildEnv/*' workflow_dispatch: jobs: @@ -35,7 +35,7 @@ jobs: id: diff run: | set +e - git diff --exit-code --no-patch origin/main docker/makefile 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) }} diff --git a/docker/makefile b/dockerBuildEnv/makefile similarity index 100% rename from docker/makefile rename to dockerBuildEnv/makefile diff --git a/docker/nas2d-arch.Dockerfile b/dockerBuildEnv/nas2d-arch.Dockerfile similarity index 100% rename from docker/nas2d-arch.Dockerfile rename to dockerBuildEnv/nas2d-arch.Dockerfile diff --git a/docker/nas2d-arch.version.mk b/dockerBuildEnv/nas2d-arch.version.mk similarity index 100% rename from docker/nas2d-arch.version.mk rename to dockerBuildEnv/nas2d-arch.version.mk diff --git a/docker/nas2d-clang.Dockerfile b/dockerBuildEnv/nas2d-clang.Dockerfile similarity index 100% rename from docker/nas2d-clang.Dockerfile rename to dockerBuildEnv/nas2d-clang.Dockerfile diff --git a/docker/nas2d-clang.version.mk b/dockerBuildEnv/nas2d-clang.version.mk similarity index 100% rename from docker/nas2d-clang.version.mk rename to dockerBuildEnv/nas2d-clang.version.mk diff --git a/docker/nas2d-gcc.Dockerfile b/dockerBuildEnv/nas2d-gcc.Dockerfile similarity index 100% rename from docker/nas2d-gcc.Dockerfile rename to dockerBuildEnv/nas2d-gcc.Dockerfile diff --git a/docker/nas2d-gcc.version.mk b/dockerBuildEnv/nas2d-gcc.version.mk similarity index 100% rename from docker/nas2d-gcc.version.mk rename to dockerBuildEnv/nas2d-gcc.version.mk diff --git a/docker/nas2d-mingw.Dockerfile b/dockerBuildEnv/nas2d-mingw.Dockerfile similarity index 100% rename from docker/nas2d-mingw.Dockerfile rename to dockerBuildEnv/nas2d-mingw.Dockerfile diff --git a/docker/nas2d-mingw.version.mk b/dockerBuildEnv/nas2d-mingw.version.mk similarity index 100% rename from docker/nas2d-mingw.version.mk rename to dockerBuildEnv/nas2d-mingw.version.mk diff --git a/makefile b/makefile index 5ac3035c..02871f41 100644 --- a/makefile +++ b/makefile @@ -234,7 +234,7 @@ install-dependencies-darwin: #### Docker related build rules #### -include docker/makefile +include dockerBuildEnv/makefile #### CircleCI related build rules #### From 4ebeb9c86c35e37f799f772e28ac6fb1884069ad Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Sun, 10 Nov 2024 23:50:01 -0700 Subject: [PATCH 09/10] Rename GitHub Actions workflow to "Build Docker Build Env" --- .../workflows/{dockerBuild.yml => buildDockerBuildEnv.yml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{dockerBuild.yml => buildDockerBuildEnv.yml} (94%) diff --git a/.github/workflows/dockerBuild.yml b/.github/workflows/buildDockerBuildEnv.yml similarity index 94% rename from .github/workflows/dockerBuild.yml rename to .github/workflows/buildDockerBuildEnv.yml index 4a2c56ae..43961340 100644 --- a/.github/workflows/dockerBuild.yml +++ b/.github/workflows/buildDockerBuildEnv.yml @@ -1,4 +1,4 @@ -name: Docker Build +name: Build Docker Build Env on: push: @@ -8,7 +8,7 @@ on: branches-ignore: - 'main' paths: - - '.github/workflows/dockerBuild.yml' + - '.github/workflows/buildDockerBuildEnv.yml' - 'dockerBuildEnv/*' workflow_dispatch: From b12a3386775c85646d39a858cd1af4b03acb9bfc Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Sun, 10 Nov 2024 23:52:46 -0700 Subject: [PATCH 10/10] Switch default Docker repository from DockerHub to GitHub --- .github/workflows/buildDockerBuildEnv.yml | 2 -- dockerBuildEnv/makefile | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/buildDockerBuildEnv.yml b/.github/workflows/buildDockerBuildEnv.yml index 43961340..e7968994 100644 --- a/.github/workflows/buildDockerBuildEnv.yml +++ b/.github/workflows/buildDockerBuildEnv.yml @@ -20,8 +20,6 @@ jobs: matrix: platform: - 'arch' - env: - DockerRepository: ghcr.io/${{ github.repository_owner }} steps: - uses: actions/checkout@v4 diff --git a/dockerBuildEnv/makefile b/dockerBuildEnv/makefile index 611e50d1..bdfaa78d 100644 --- a/dockerBuildEnv/makefile +++ b/dockerBuildEnv/makefile @@ -8,7 +8,7 @@ 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 $(DockerBuildEnvFolder)/nas2d-*.version.mk)