Skip to content

Commit 12edfa9

Browse files
committed
passing BUILD_VERSION arg to docker build
Signed-off-by: Dan <[email protected]>
1 parent 0dcdd56 commit 12edfa9

File tree

10 files changed

+23
-14
lines changed

10 files changed

+23
-14
lines changed

.github/workflows/publish_image_chart.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ jobs:
9292
context: .
9393
file: ${{ matrix.dockerfile }}
9494
platforms: linux/amd64,linux/arm64
95+
build-args: |
96+
BUILD_VERSION=${{ env.PIPECD_VERSION }}
9597
tags: ${{ matrix.container_registry }}/${{ matrix.image }}:${{ env.PIPECD_VERSION }}
9698
# parameter to use inline cache. ref; https://docs.docker.com/build/ci/github-actions/cache/#inline-cache
9799
cache-from: type=registry,ref=${{ matrix.container_registry }}/${{ matrix.image }}:latest

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ run/pipecd: CONTROL_PLANE_VALUES ?= ./quickstart/control-plane-values.yaml
159159
run/pipecd: PIPECD_VERSION ?= $(shell git describe --tags --always --dirty --abbrev=7 --match 'v[0-9]*.*')
160160
run/pipecd:
161161
@echo "Building docker image and pushing it to local registry..."
162-
docker build -f cmd/pipecd/Dockerfile -t localhost:5001/pipecd:$(BUILD_VERSION) --build-arg PIPECD_VERSION=$(PIPECD_VERSION) .
162+
docker build -f cmd/pipecd/Dockerfile -t localhost:5001/pipecd:$(BUILD_VERSION) --build-arg BUILD_VERSION=$(PIPECD_VERSION) .
163163
docker push localhost:5001/pipecd:$(BUILD_VERSION)
164164

165165
@echo "Installing Control Plane in kind..."
@@ -190,9 +190,9 @@ else
190190
endif
191191

192192
.PHONY: run/web
193-
run/web: PIPECD_VERSION ?= $(shell git describe --tags --always --dirty --abbrev=7 --match 'v[0-9]*.*')
193+
run/web: BUILD_VERSION ?= $(shell git describe --tags --always --dirty --abbrev=7 --match 'v[0-9]*.*')
194194
run/web:
195-
PIPECD_VERSION=$(PIPECD_VERSION) yarn --cwd web dev
195+
BUILD_VERSION=$(BUILD_VERSION) yarn --cwd web dev
196196

197197
.PHONY: run/site
198198
run/site:

cmd/helloworld/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM --platform=$BUILDPLATFORM golang:1.25.0 AS builder
33

44
ARG TARGETOS
55
ARG TARGETARCH
6+
ARG BUILD_VERSION
67

78
WORKDIR /app
89

@@ -11,7 +12,7 @@ RUN go mod download
1112

1213
COPY . ./
1314

14-
RUN make build/go MOD=helloworld BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH}
15+
RUN make build/go MOD=helloworld BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH} BUILD_VERSION=${BUILD_VERSION}
1516

1617
FROM alpine:3.21.3
1718

cmd/launcher/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM --platform=$BUILDPLATFORM golang:1.25.0 AS builder
33

44
ARG TARGETOS
55
ARG TARGETARCH
6+
ARG BUILD_VERSION
67

78
WORKDIR /app
89

@@ -11,7 +12,7 @@ RUN go mod download
1112

1213
COPY . ./
1314

14-
RUN make build/go MOD=launcher BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH}
15+
RUN make build/go MOD=launcher BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH} BUILD_VERSION=${BUILD_VERSION}
1516

1617
# https://github.com/pipe-cd/pipecd/pkgs/container/piped-base/459025001?tag=v0.52.0-97-g3e3df6d
1718
FROM ghcr.io/pipe-cd/piped-base@sha256:fc2bde38211a80ee0df6d90ed168c817f30a7d0dbe8a0aff872a93ffb7d40a66

cmd/launcher/Dockerfile-okd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM --platform=$BUILDPLATFORM golang:1.25.0 AS builder
33

44
ARG TARGETOS
55
ARG TARGETARCH
6+
ARG BUILD_VERSION
67

78
WORKDIR /app
89

@@ -11,7 +12,7 @@ RUN go mod download
1112

1213
COPY . ./
1314

14-
RUN make build/go MOD=launcher BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH}
15+
RUN make build/go MOD=launcher BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH} BUILD_VERSION=${BUILD_VERSION}
1516

1617
# https://github.com/pipe-cd/pipecd/pkgs/container/piped-base-okd/460487531?tag=v0.52.0-102-g2f29597
1718
FROM ghcr.io/pipe-cd/piped-base-okd@sha256:fc69a9d270e27e086381e8334885ea3d630db2e10fdd00d41759dc40d87fbafc

cmd/pipecd/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# because this stage builds only web assets, we can use any platform
44
FROM --platform=$BUILDPLATFORM node:20.19.0-alpine3.21 AS web
55

6-
ARG PIPECD_VERSION
6+
ARG BUILD_VERSION
77

88
WORKDIR /app
99

@@ -15,14 +15,14 @@ RUN yarn --cwd web install --prefer-offline
1515
COPY .git ./.git
1616
COPY web ./web
1717
COPY Makefile .
18-
RUN make build/web PIPECD_VERSION=${PIPECD_VERSION}
18+
RUN make build/web PIPECD_VERSION=${BUILD_VERSION}}
1919

2020
# pipecd builder
2121
FROM --platform=$BUILDPLATFORM golang:1.25.0 AS builder
2222

2323
ARG TARGETOS
2424
ARG TARGETARCH
25-
ARG PIPECD_VERSION
25+
ARG BUILD_VERSION
2626

2727
WORKDIR /app
2828

@@ -33,7 +33,7 @@ COPY .git ./.git
3333
COPY pkg/ ./pkg/
3434
COPY cmd/ ./cmd/
3535
COPY Makefile .
36-
RUN make build/go MOD=pipecd BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH} BUILD_VERSION=${PIPECD_VERSION}
36+
RUN make build/go MOD=pipecd BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH} BUILD_VERSION=${BUILD_VERSION}
3737

3838
FROM alpine:3.21.3
3939

cmd/pipectl/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM --platform=$BUILDPLATFORM golang:1.25.0 AS builder
33

44
ARG TARGETOS
55
ARG TARGETARCH
6+
ARG BUILD_VERSION
67

78
WORKDIR /app
89

@@ -11,7 +12,7 @@ RUN go mod download
1112

1213
COPY . ./
1314

14-
RUN make build/go MOD=pipectl BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH}
15+
RUN make build/go MOD=pipectl BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH} BUILD_VERSION=${BUILD_VERSION}
1516

1617
FROM alpine:3.21.3
1718

cmd/piped/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM --platform=$BUILDPLATFORM golang:1.25.0 AS builder
33

44
ARG TARGETOS
55
ARG TARGETARCH
6+
ARG BUILD_VERSION
67

78
WORKDIR /app
89

@@ -11,7 +12,7 @@ RUN go mod download
1112

1213
COPY . ./
1314

14-
RUN make build/go MOD=piped BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH}
15+
RUN make build/go MOD=piped BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH} BUILD_VERSION=${BUILD_VERSION}
1516

1617
# https://github.com/pipe-cd/pipecd/pkgs/container/piped-base/459025001?tag=v0.52.0-97-g3e3df6d
1718
FROM ghcr.io/pipe-cd/piped-base@sha256:fc2bde38211a80ee0df6d90ed168c817f30a7d0dbe8a0aff872a93ffb7d40a66

cmd/piped/Dockerfile-okd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM --platform=$BUILDPLATFORM golang:1.25.0 AS builder
33

44
ARG TARGETOS
55
ARG TARGETARCH
6+
ARG BUILD_VERSION
67

78
WORKDIR /app
89

@@ -11,7 +12,7 @@ RUN go mod download
1112

1213
COPY . ./
1314

14-
RUN make build/go MOD=piped BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH}
15+
RUN make build/go MOD=piped BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH} BUILD_VERSION=${BUILD_VERSION}
1516

1617
# https://github.com/pipe-cd/pipecd/pkgs/container/piped-base-okd/460487531?tag=v0.52.0-102-g2f29597
1718
FROM ghcr.io/pipe-cd/piped-base-okd@sha256:fc69a9d270e27e086381e8334885ea3d630db2e10fdd00d41759dc40d87fbafc

cmd/pipedv1/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM --platform=$BUILDPLATFORM golang:1.25.0 AS builder
33

44
ARG TARGETOS
55
ARG TARGETARCH
6+
ARG BUILD_VERSION
67

78
WORKDIR /app
89

@@ -11,7 +12,7 @@ RUN go mod download
1112

1213
COPY . ./
1314

14-
RUN make build/go MOD=pipedv1 BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH}
15+
RUN make build/go MOD=pipedv1 BUILD_OS=${TARGETOS} BUILD_ARCH=${TARGETARCH} BUILD_VERSION=${BUILD_VERSION}
1516

1617
# https://github.com/pipe-cd/pipecd/pkgs/container/piped-base/459025001?tag=v0.52.0-97-g3e3df6d
1718
FROM ghcr.io/pipe-cd/piped-base@sha256:fc2bde38211a80ee0df6d90ed168c817f30a7d0dbe8a0aff872a93ffb7d40a66

0 commit comments

Comments
 (0)