Skip to content

Commit 78f2d90

Browse files
Copilotneilime
andcommitted
Add structure-test stage to Dockerfile for local builds
Co-authored-by: neilime <[email protected]>
1 parent b6d8c26 commit 78f2d90

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/super-linter/super-linter:slim-v8.0.0
1+
FROM ghcr.io/super-linter/super-linter:slim-v8.0.0 AS linter
22

33
HEALTHCHECK --interval=5m --timeout=10s --start-period=30s --retries=3 CMD ["/bin/sh","-c","test -d /github/home"]
44
ARG UID=1000
@@ -10,3 +10,7 @@ ENV RUN_LOCAL=true
1010
ENV USE_FIND_ALGORITHM=true
1111
ENV LOG_LEVEL=WARN
1212
ENV LOG_FILE="/github/home/logs"
13+
14+
FROM ghcr.io/googlecontainertools/container-structure-test:1.22.0 AS structure-test
15+
16+
HEALTHCHECK --interval=5m --timeout=10s --start-period=30s --retries=3 CMD ["container-structure-test", "version"]

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ define run_linter
3636
DEFAULT_WORKSPACE="$(CURDIR)"; \
3737
LINTER_IMAGE="linter:latest"; \
3838
VOLUME="$$DEFAULT_WORKSPACE:$$DEFAULT_WORKSPACE"; \
39-
docker build --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag $$LINTER_IMAGE .; \
39+
docker build --target linter --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag $$LINTER_IMAGE .; \
4040
docker run \
4141
-e DEFAULT_WORKSPACE="$$DEFAULT_WORKSPACE" \
4242
-e FILTER_REGEX_INCLUDE="$(filter-out $@,$(MAKECMDGOALS))" \
@@ -61,11 +61,13 @@ define run_tests
6161
fi; \
6262
echo "Building image $$IMAGE_NAME..."; \
6363
docker buildx build -t "$$IMAGE_NAME:test" "$$IMAGE_DIR" || exit 1; \
64+
echo "Building structure-test image..."; \
65+
docker build --target structure-test --tag structure-test:latest . || exit 1; \
6466
echo "Running tests for $$IMAGE_NAME..."; \
6567
docker run --rm \
6668
-v /var/run/docker.sock:/var/run/docker.sock \
6769
-v "$$IMAGE_DIR:/workspace" \
68-
ghcr.io/googlecontainertools/container-structure-test:v1.22.0 \
70+
structure-test:latest \
6971
test --image "$$IMAGE_NAME:test" --config /workspace/container-structure-test.yaml
7072
endef
7173

0 commit comments

Comments
 (0)