From 9d9204662bf0ff9406b1cfde9a49f2c3a27a5e2b Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Tue, 3 Dec 2024 16:38:54 -0700 Subject: [PATCH 1/4] Allow passing additional flags to run Docker containers This makes it easier to pass additional flags, without having to re-specify all existing run flags. In particular the `--jobs` flag can be added to compile in parallel with local Docker containers. --- dockerBuildEnv/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerBuildEnv/makefile b/dockerBuildEnv/makefile index bdfaa78d..ad5e0535 100644 --- a/dockerBuildEnv/makefile +++ b/dockerBuildEnv/makefile @@ -6,7 +6,7 @@ DockerBuildEnvFolder := $(abspath $(dir $(lastword ${MAKEFILE_LIST}))) TopLevelFolder := $(abspath $(DockerBuildEnvFolder)/..) -DockerRunFlags := --volume ${TopLevelFolder}:/code --workdir=/code --rm --tty +DockerRunFlags = --volume ${TopLevelFolder}:/code --workdir=/code --rm --tty ${DockerAdditionalFlags} DockerUserFlags = --user="$(shell id --user):$(shell id --group)" DockerRepository ?= ghcr.io/lairworks From 075e70e0e91c1e3c7dca69eb0ca2709d1acdea2d Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Tue, 3 Dec 2024 16:42:09 -0700 Subject: [PATCH 2/4] Use `CURDIR` instead of `TopLevelFolder` We probably want to run the Docker container from whatever folder the `make` command was run from, rather than always using the NAS2D folder. In particular, if a downstream project, such as OPHD, wants to compile it's code in the Docker container, it will be possible by running the `makefile` code from the downstream project folder. --- dockerBuildEnv/makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dockerBuildEnv/makefile b/dockerBuildEnv/makefile index ad5e0535..d74cd1bd 100644 --- a/dockerBuildEnv/makefile +++ b/dockerBuildEnv/makefile @@ -4,9 +4,8 @@ # Note: MAKEFILE_LIST's last entry is the last processed Makefile. # That should be the current Makefile, assuming no includes DockerBuildEnvFolder := $(abspath $(dir $(lastword ${MAKEFILE_LIST}))) -TopLevelFolder := $(abspath $(DockerBuildEnvFolder)/..) -DockerRunFlags = --volume ${TopLevelFolder}:/code --workdir=/code --rm --tty ${DockerAdditionalFlags} +DockerRunFlags = --volume ${CURDIR}:/code --workdir=/code --rm --tty ${DockerAdditionalFlags} DockerUserFlags = --user="$(shell id --user):$(shell id --group)" DockerRepository ?= ghcr.io/lairworks From 3ab41d35c57db4ea0c79a070458e59d8aa3a9a1e Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Tue, 3 Dec 2024 16:45:21 -0700 Subject: [PATCH 3/4] Use `${}` to wrap variable reference instead of `$()` This is to be consistent with the rest of the variable references. --- dockerBuildEnv/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerBuildEnv/makefile b/dockerBuildEnv/makefile index d74cd1bd..064211d8 100644 --- a/dockerBuildEnv/makefile +++ b/dockerBuildEnv/makefile @@ -9,7 +9,7 @@ DockerRunFlags = --volume ${CURDIR}:/code --workdir=/code --rm --tty ${DockerAdd DockerUserFlags = --user="$(shell id --user):$(shell id --group)" DockerRepository ?= ghcr.io/lairworks -include $(wildcard $(DockerBuildEnvFolder)/nas2d-*.version.mk) +include $(wildcard ${DockerBuildEnvFolder}/nas2d-*.version.mk) DockerFileName = ${DockerBuildEnvFolder}/nas2d-$*.Dockerfile From a0315598dc4757ec0bac8b59ac64daf23875ae85 Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Sun, 29 Dec 2024 14:00:42 -0700 Subject: [PATCH 4/4] Revert "Allow changes to the `makefile` to rebuild Docker images" This reverts commit 120e9e2bd88f3788d53bc145504312f204aac28a. Refactoring the `makefile` doesn't need to trigger a rebuild of all images. It was important during a name scheme change, since that was controlled by the `makefile`. Now that the name scheme change has been applied, we no longer need to trigger a build of all images for changes to the `makefile`. --- .github/workflows/buildDockerBuildEnv.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildDockerBuildEnv.yml b/.github/workflows/buildDockerBuildEnv.yml index 6912731e..3b6ea17d 100644 --- a/.github/workflows/buildDockerBuildEnv.yml +++ b/.github/workflows/buildDockerBuildEnv.yml @@ -37,7 +37,7 @@ jobs: id: diff run: | set +e - git diff --exit-code --no-patch "origin/${defaultBranch}" dockerBuildEnv/makefile dockerBuildEnv/nas2d-${{ matrix.platform }}.* ; echo "modified=$?" >> $GITHUB_OUTPUT + git diff --exit-code --no-patch "origin/${defaultBranch}" dockerBuildEnv/nas2d-${{ matrix.platform }}.* ; echo "modified=$?" >> $GITHUB_OUTPUT - name: Docker build if: ${{ fromJSON(steps.diff.outputs.modified) }}