Skip to content

Commit d2d90c9

Browse files
committed
(wip)
1 parent a841163 commit d2d90c9

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

.github/workflows/docker-build.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Docker image version
1+
name: Build & Publish
22

33
on:
44
workflow_call:
@@ -35,8 +35,8 @@ on:
3535
required: true
3636

3737
jobs:
38-
push_to_registry:
39-
name: Push Docker image to Docker Hub
38+
build:
39+
name: Build Docker image
4040
runs-on: ubuntu-latest
4141

4242
permissions:
@@ -99,12 +99,12 @@ jobs:
9999
tags: ${{ steps.meta.outputs.tags }}
100100
labels: ${{ steps.meta.outputs.labels }}
101101

102-
push_children:
103-
name: Push children Docker image to Docker Hub
102+
build_variations:
103+
name: Build Docker image variation
104104
runs-on: ubuntu-latest
105105

106106
needs:
107-
- push_to_registry
107+
- build
108108

109109
strategy:
110110
fail-fast: false

.github/workflows/setup-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
echo "versions=$(cat config.json | jq . --compact-output)" >> "$GITHUB_OUTPUT"
2626
2727
docker_build_push:
28-
name: Docker Build and Push
28+
name: Build and Push
2929
needs:
3030
- setup
3131

Makefile

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
11
all: build
22

33
IMAGE=lojassimonetti/php-apache-oci8-composer
4-
tag=$(shell git branch | grep \* | cut -d ' ' -f2)
5-
TAG=$(shell [[ "$(tag)" == "master" ]] && echo "latest" || echo $(tag))
64
FILE=Dockerfile
75

6+
list-names:
7+
@cat config.json|jq '.[]|.name' --raw-output
8+
89
build:
9-
docker build --file $(FILE) --pull . -t $(IMAGE):$(TAG)
10+
ifndef name
11+
$(error No name was informed throught the "name" parameter)
12+
endif
13+
docker run --rm \
14+
`cat config.json | \
15+
jq '.[]|select(.name == "$(name)")|to_entries|map(select(.key != "variations"))' | \
16+
jq '.|map(" -e DOCKER_BUILD_" + (.key|ascii_upcase) + "=" + (.value|tostring) + "")|.[]' \
17+
--raw-output` \
18+
-v `pwd`:/work -w /work \
19+
webdevops/go-replace:latest \
20+
--mode=template ./`cat config.json | \
21+
jq '.[]|select(.name == "$(name)")|.template|if . == null then "Dockerfile.tmpl" else . end' --raw-output` \
22+
-o Dockerfile
23+
docker build . --pull -t $(IMAGE):$(name)
24+
rm Dockerfile
1025

1126
push: build
1227
docker push $(IMAGE):$(TAG)
1328

1429
build-var:
15-
make build TAG=$(TAG)-$(var) FILE=$(FILE).$(var)
30+
ifndef name
31+
$(error No variation was informed throught the "var" parameter)
32+
endif
33+
make build name=$(name)
34+
docker build --build-arg IMAGE_BASE=$(IMAGE):$(name) --file Dockerfile.$(var) -t $(IMAGE):$(name)-$(var) .
1635

1736
push-var: build-var
1837
docker push $(IMAGE):$(TAG)-$(var)

0 commit comments

Comments
 (0)