Skip to content

Commit

Permalink
WIP: use docker buildx bake
Browse files Browse the repository at this point in the history
Signed-off-by: Damien Duportal <[email protected]>
  • Loading branch information
dduportal committed May 8, 2021
1 parent e28094a commit 5c79a61
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 23 deletions.
24 changes: 1 addition & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,7 @@ PANDOC_VERSION ?= 2.10.1
all: build test README

build:
docker build \
--target main-minimal \
--tag="$(DOCKER_IMAGE_NAME_TO_TEST)-minimal" \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from="$(DOCKER_IMAGE_NAME_TO_TEST)-minimal" \
--file=Dockerfile \
$(CURDIR)/
docker build \
--target build-haskell \
--tag="$(DOCKER_IMAGE_NAME_TO_TEST)-build-haskell" \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from="$(DOCKER_IMAGE_NAME_TO_TEST)-build-haskell" \
--file=Dockerfile \
$(CURDIR)/
docker build \
--target main \
--tag="$(DOCKER_IMAGE_NAME_TO_TEST)" \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from="$(DOCKER_IMAGE_NAME_TO_TEST)-minimal" \
--cache-from="$(DOCKER_IMAGE_NAME_TO_TEST)-build-haskell" \
--cache-from="$(DOCKER_IMAGE_NAME_TO_TEST)" \
--file=Dockerfile \
$(CURDIR)/
docker buildx bake all

shell: build
docker run -it -v $(CURDIR)/tests/fixtures:/documents/ $(DOCKER_IMAGE_NAME_TO_TEST)
Expand Down
59 changes: 59 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
variable "CACHE_REGISTRY" {
default = ""
}

group "all" {
targets = [
"asciidoctor-minimal",
"build-haskell",
"asciidoctor"
]
}

target "asciidoctor-minimal" {
dockerfile = "Dockerfile"
context = "."
target = "main-minimal"
tags = [
"asciidoctor-minimal",
notequal("", CACHE_REGISTRY) ? "${CACHE_REGISTRY}/asciidoctor-minimal:cache" : "",
]
args = {
BUILDKIT_INLINE_CACHE = 1
}
cache-from = [
notequal("", CACHE_REGISTRY) ? "${CACHE_REGISTRY}/asciidoctor-minimal:cache" : "",
]
}

target "build-haskell" {
dockerfile = "Dockerfile"
context = "."
target = "build-haskell"
tags = [
"asciidoctor-build-haskell",
notequal("", CACHE_REGISTRY) ? "${CACHE_REGISTRY}/asciidoctor-build-haskell:cache" : "",
]
args = {
BUILDKIT_INLINE_CACHE = 1
}
cache-from = [
notequal("", CACHE_REGISTRY) ? "${CACHE_REGISTRY}/asciidoctor-build-haskell:cache" : "",
]
}

target "asciidoctor" {
dockerfile = "Dockerfile"
context = "."
target = "main"
tags = [
"asciidoctor",
notequal("", CACHE_REGISTRY) ? "${CACHE_REGISTRY}/asciidoctor:cache" : "",
]
args = {
BUILDKIT_INLINE_CACHE = 1
}
cache-from = [
notequal("", CACHE_REGISTRY) ? "${CACHE_REGISTRY}/asciidoctor:cache" : "",
]
}

0 comments on commit 5c79a61

Please sign in to comment.