Skip to content

Commit 554ea43

Browse files
committed
Makefile.maker.yaml: add dockerfile.checkEnv
1 parent 05e2c46 commit 554ea43

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

.dockerignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@
77
# TODO: uncomment when applications no longer use git to get version information
88
#.git/
99
/.github/
10-
/.gitignore
11-
/.golangci.yaml
1210
/.goreleaser.yml
1311
/.vscode/
1412
/CONTRIBUTING.md
1513
/Dockerfile
16-
/LICENSE*
1714
/Makefile.maker.yaml
1815
/README.md
1916
/build/

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,39 @@ RUN make -C /src install PREFIX=/pkg GOTOOLCHAIN=local GO_BUILDFLAGS='-mod vendo
1111

1212
################################################################################
1313

14+
# To only build the tests run: docker build . --target test
15+
# We can't do `FROM builder AS test` here, as then make prepare-static-check would not be cached during interactive use when developing
16+
# and caching all the tools, especially golangci-lint, takes a few minutes.
17+
FROM golang:1.25.4-alpine3.22 AS test
18+
19+
COPY Makefile /src/Makefile
20+
21+
# used below by USER
22+
RUN addgroup -g 4200 appgroup \
23+
&& adduser -h /home/appuser -s /sbin/nologin -G appgroup -D -u 4200 appuser
24+
25+
RUN apk add --no-cache --no-progress git make py3-pip \
26+
&& pip3 install --break-system-packages reuse \
27+
&& make -C /src prepare-static-check
28+
29+
30+
# We only copy here because we want the "prepare-static-check" to be cacheable.
31+
# It is not a problem that we are overwriting the go cache from the earlier steps because we do not need to rebuild those tools.
32+
COPY --from=builder /go /go
33+
COPY --from=builder /src /src
34+
35+
RUN CHECK_SKIPS_FUNCTIONAL_TEST=true make -C /src static-check
36+
37+
# Some things like postgres do not like to run as root. For simplicity, just always run as an unprivileged user,
38+
# but for it to be able to read the go cache, we need to allow it.
39+
RUN chmod 777 -R /src/
40+
USER 4200:4200
41+
RUN cd /src \
42+
&& git config --global --add safe.directory /src \
43+
&& CHECK_SKIPS_FUNCTIONAL_TEST=true make build/cover.out
44+
45+
################################################################################
46+
1447
FROM alpine:3.22
1548

1649
RUN addgroup -g 4200 appgroup \

Makefile.maker.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ binaries:
1010

1111
dockerfile:
1212
enabled: true
13+
checkEnv:
14+
- CHECK_SKIPS_FUNCTIONAL_TEST=true
1315
extraIgnores:
1416
- examples/
1517
- make-config.sh

0 commit comments

Comments
 (0)