From 4c196048630729f115081f85d3b6749db55e2a53 Mon Sep 17 00:00:00 2001 From: Daniel Stevens Date: Sat, 4 May 2024 13:48:08 -0600 Subject: [PATCH] Move Docker rules to separate `makefile` By splitting these rules off from the main makefile, it makes it possible to watch for changes in to either the Dockerfiles or to the build rules in the `makefile` that generate Docker images from the Dockerfiles. This can be accomplished by watching for changes in the folder `docker/` to trigger builds of Docker images. Having Docker images built using CI can potentially speed up the uplaod of large Docker images. Docker images can be quite large, particularly for the Mingw builds, which are close to 4GB. Having to upload them after a local build can take quite a bit of time. It might make sense to use the GitHub Docker Registry rather than DockerHub, as that could allow for building and uploading all using GitHub infrastructure. --- docker/makefile | 40 ++++++++++++++++++++++++++++++++++++++++ makefile | 41 +---------------------------------------- 2 files changed, 41 insertions(+), 40 deletions(-) create mode 100644 docker/makefile diff --git a/docker/makefile b/docker/makefile new file mode 100644 index 00000000..0625d3d8 --- /dev/null +++ b/docker/makefile @@ -0,0 +1,40 @@ +# Build rules relating to Docker images + +DockerFolder := ${TopLevelFolder}/docker +DockerRunFlags := --volume ${TopLevelFolder}:/code --workdir=/code --rm --tty +DockerUserFlags = --user="$(shell id --user):$(shell id --group)" +DockerRepository := outpostuniverse + +ImageVersion_gcc := 1.5 +ImageVersion_clang := 1.4 +ImageVersion_mingw := 1.10 +ImageVersion_arch := 1.4 + +DockerFileName = ${DockerFolder}/nas2d-$*.Dockerfile + +DockerImageName = ${DockerRepository}/nas2d-$*:${ImageVersion_$*} +DockerImageNameLatest = ${DockerRepository}/nas2d-$*: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 +DockerRunRules := run-image-gcc run-image-clang run-image-mingw run-image-arch +DockerDebugRules := debug-image-gcc debug-image-clang debug-image-mingw debug-image-arch +DockerDebugRootRules := root-debug-image-gcc root-debug-image-clang root-debug-image-mingw root-debug-image-arch + +.PHONY: ${DockerBuildRules} ${DockerPushRules} ${DockerRunRules} ${DockerDebugRules} ${DockerDebugRootRules} + +${DockerBuildRules}: build-image-%: + docker build ${DockerFolder}/ --file ${DockerFileName} --tag ${DockerImageName} --tag ${DockerImageNameLatest} + +${DockerPushRules}: push-image-%: + docker push ${DockerImageName} + docker push ${DockerImageNameLatest} + +${DockerRunRules}: run-image-%: + docker run ${DockerRunFlags} ${DockerUserFlags} ${DockerImageName} + +${DockerDebugRules}: debug-image-%: + docker run ${DockerRunFlags} --interactive ${DockerUserFlags} ${DockerImageName} bash + +${DockerDebugRootRules}: root-debug-image-%: + docker run ${DockerRunFlags} --interactive ${DockerImageName} bash diff --git a/makefile b/makefile index 0f9ad877..69ec69ec 100644 --- a/makefile +++ b/makefile @@ -237,46 +237,7 @@ install-dependencies-darwin: #### Docker related build rules #### -# Build rules relating to Docker images - -DockerFolder := ${TopLevelFolder}/docker -DockerRunFlags := --volume ${TopLevelFolder}:/code --workdir=/code --rm --tty -DockerUserFlags = --user="$(shell id --user):$(shell id --group)" -DockerRepository := outpostuniverse - -ImageVersion_gcc := 1.5 -ImageVersion_clang := 1.4 -ImageVersion_mingw := 1.10 -ImageVersion_arch := 1.4 - -DockerFileName = ${DockerFolder}/nas2d-$*.Dockerfile - -DockerImageName = ${DockerRepository}/nas2d-$*:${ImageVersion_$*} -DockerImageNameLatest = ${DockerRepository}/nas2d-$*: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 -DockerRunRules := run-image-gcc run-image-clang run-image-mingw run-image-arch -DockerDebugRules := debug-image-gcc debug-image-clang debug-image-mingw debug-image-arch -DockerDebugRootRules := root-debug-image-gcc root-debug-image-clang root-debug-image-mingw root-debug-image-arch - -.PHONY: ${DockerBuildRules} ${DockerPushRules} ${DockerRunRules} ${DockerDebugRules} ${DockerDebugRootRules} - -${DockerBuildRules}: build-image-%: - docker build ${DockerFolder}/ --file ${DockerFileName} --tag ${DockerImageName} --tag ${DockerImageNameLatest} - -${DockerPushRules}: push-image-%: - docker push ${DockerImageName} - docker push ${DockerImageNameLatest} - -${DockerRunRules}: run-image-%: - docker run ${DockerRunFlags} ${DockerUserFlags} ${DockerImageName} - -${DockerDebugRules}: debug-image-%: - docker run ${DockerRunFlags} --interactive ${DockerUserFlags} ${DockerImageName} bash - -${DockerDebugRootRules}: root-debug-image-%: - docker run ${DockerRunFlags} --interactive ${DockerImageName} bash +include docker/makefile #### CircleCI related build rules ####