Skip to content

Commit

Permalink
Merge pull request #1162 from lairworks/refactorDockerMakeRules
Browse files Browse the repository at this point in the history
Split off Docker Make rules
  • Loading branch information
DanRStevens authored Jul 16, 2024
2 parents 3dbc879 + 6a2484c commit 9cf6e31
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 42 deletions.
45 changes: 45 additions & 0 deletions docker/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Build rules relating to Docker images

# 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)/..)

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
43 changes: 1 addition & 42 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Source http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/

# 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
TopLevelFolder := $(abspath $(dir $(lastword ${MAKEFILE_LIST})))

CONFIG = Debug
Debug_CXX_FLAGS := -Og -g
Release_CXX_FLAGS := -O3
Expand Down Expand Up @@ -237,43 +232,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

DockerImageName = ${DockerRepository}/nas2d-$*:${ImageVersion_$*}

DockerBuildRules := build-image-gcc build-image-clang build-image-mingw build-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
DockerPushRules := push-image-gcc push-image-clang push-image-mingw push-image-arch

.PHONY: ${DockerBuildRules} ${DockerRunRules} ${DockerDebugRules} ${DockerDebugRootRules} ${DockerPushRules}

${DockerBuildRules}: build-image-%:
docker build ${DockerFolder}/ --file ${DockerFolder}/nas2d-$*.Dockerfile --tag ${DockerImageName} --tag ${DockerRepository}/nas2d-$*:latest

${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

${DockerPushRules}: push-image-%:
docker push ${DockerImageName}
docker push ${DockerRepository}/nas2d-$*:latest
include docker/makefile

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

Expand Down

0 comments on commit 9cf6e31

Please sign in to comment.