Skip to content

Commit a1d18e9

Browse files
authored
Merge pull request #513 from dduportal/chore/golang
chore: fix lint issues and track golang build version
2 parents bf49ba9 + e05ffda commit a1d18e9

File tree

2 files changed

+102
-16
lines changed

2 files changed

+102
-16
lines changed

Dockerfile

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN apk add --no-cache ruby \
2828
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
2929
# Install erd-go (https://github.com/kaishuu0123/erd-go) as replacement for erd (https://github.com/BurntSushi/erd)
3030
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
31-
FROM golang:${ERD_GOLANG_BUILDER_TAG} as erd-builder
31+
FROM golang:${ERD_GOLANG_BUILDER_TAG} AS erd-builder
3232
ARG ERD_VERSION=v2.0.0
3333
## Always use the latest git package
3434
# go install or go get cannot be used the go.mod syntax of erd-go is not following the Golang semver properties,
@@ -43,7 +43,7 @@ RUN CGO_ENABLED=0 GOOS=linux go build
4343
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
4444
# Install ASCIIToSVG https://github.com/asciitosvg/asciitosvg
4545
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
46-
FROM golang:${A2S_GOLANG_BUILDER_TAG} as a2s-builder
46+
FROM golang:${A2S_GOLANG_BUILDER_TAG} AS a2s-builder
4747
# Expects a git reference as there are no tags in the A2S repository
4848
ARG A2S_VERSION=ca82a5c
4949
RUN GOBIN=/app go install github.com/asciitosvg/asciitosvg/cmd/a2s@"${A2S_VERSION}"
@@ -87,9 +87,8 @@ RUN apk add --no-cache \
8787
tzdata \
8888
unzip \
8989
which \
90-
font-noto-cjk
91-
92-
RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \
90+
font-noto-cjk \
91+
&& apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \
9392
pdf2svg
9493

9594
ARG asciidoctor_confluence_version=0.0.2
@@ -165,22 +164,22 @@ ENV PIPX_MAN_DIR=/usr/local/share/man
165164
## Always use the latest dependencies versions available for the current Alpine distribution
166165
# hadolint ignore=DL3018,DL3013
167166
RUN apk add --no-cache \
168-
pipx \
169-
py3-pip \
167+
pipx \
168+
py3-pip \
170169
&& apk add --no-cache --virtual .pythonmakedepends \
171-
build-base \
172-
freetype-dev \
173-
python3-dev \
174-
jpeg-dev \
170+
build-base \
171+
freetype-dev \
172+
python3-dev \
173+
jpeg-dev \
175174
&& for pipx_app in \
176-
actdiag \
177-
'blockdiag[pdf]' \
178-
nwdiag \
179-
seqdiag \
175+
actdiag \
176+
'blockdiag[pdf]' \
177+
nwdiag \
178+
seqdiag \
180179
;do pipx install --system-site-packages --pip-args='--no-cache-dir' "${pipx_app}"; \
181180
# Pin pillow to 9.5.0 as per https://github.com/asciidoctor/docker-asciidoctor/pull/403#issuecomment-1894323894
182181
pipx runpip "$(echo "$pipx_app" | cut -d'[' -f1)" install Pillow==9.5.0; done \
183-
&& apk del -r --no-cache .pythonmakedepends
182+
&& apk del -r --no-cache .pythonmakedepends
184183

185184
COPY --from=a2s-builder /app/a2s /usr/local/bin/
186185
COPY --from=erd-builder /app/erd-go /usr/local/bin/

updatecli/updatecli.d/golang.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
name: Bump Golang Build Version (for A2S and ERD)
3+
4+
scms:
5+
default:
6+
kind: github
7+
spec:
8+
user: "{{ .github.user }}"
9+
email: "{{ .github.email }}"
10+
owner: "{{ requiredEnv .github.owner }}"
11+
repository: "{{ requiredEnv .github.repository }}"
12+
token: "{{ requiredEnv .github.token }}"
13+
username: "{{ .github.username }}"
14+
branch: "{{ .github.branch }}"
15+
16+
sources:
17+
getCurrentAlpineStrippedVersion:
18+
kind: dockerfile
19+
name: "Get the current Alpine version with the patch stripped"
20+
spec:
21+
file: Dockerfile
22+
instruction:
23+
keyword: "ARG"
24+
matcher: "alpine_version"
25+
transformers:
26+
- findsubmatch:
27+
pattern: '^(\d*).(\d*)*'
28+
captureindex: 0
29+
getLatestGolangVersion:
30+
kind: golang
31+
transformers:
32+
- findsubmatch:
33+
pattern: '^(\d*).(\d*)*'
34+
captureindex: 0
35+
latestGolangDockerAlpineVersion:
36+
dependson:
37+
- getCurrentAlpineStrippedVersion
38+
- getLatestGolangVersion
39+
kind: shell
40+
spec:
41+
command: echo "{{ source `getLatestGolangVersion` }}-alpine{{ source `getCurrentAlpineStrippedVersion` }}"
42+
43+
conditions:
44+
testDockerImageExists:
45+
name: "Does the Docker Image exists on the Docker Hub?"
46+
kind: dockerimage
47+
sourceid: latestGolangDockerAlpineVersion
48+
spec:
49+
image: golang
50+
# tag come from the source
51+
architectures:
52+
- amd64
53+
- arm64
54+
55+
targets:
56+
updateERDGolangBuildInDockerfile:
57+
name: "Update ERD golang build image tag in the Dockerfile"
58+
kind: dockerfile
59+
sourceid: latestGolangDockerAlpineVersion
60+
spec:
61+
file: Dockerfile
62+
instruction:
63+
keyword: ARG
64+
matcher: ERD_GOLANG_BUILDER_TAG
65+
scmid: default
66+
updateA2SGolangBuildInDockerfile:
67+
name: "Update A2S golang build image tag in the Dockerfile"
68+
kind: dockerfile
69+
sourceid: latestGolangDockerAlpineVersion
70+
spec:
71+
file: Dockerfile
72+
instruction:
73+
keyword: ARG
74+
matcher: A2S_GOLANG_BUILDER_TAG
75+
scmid: default
76+
77+
actions:
78+
default:
79+
kind: github/pullrequest
80+
scmid: default
81+
title: Bump Golang Build Version (for A2S and ERD) {{ source `latestGolangDockerAlpineVersion` }}
82+
spec:
83+
labels:
84+
- dependencies
85+
- golang
86+
- erd
87+
- a2s

0 commit comments

Comments
 (0)