build: refine Dockerfile comments and dockerignore scope

Exclude Docker/compose/CI files from builder stage context to avoid
unnecessary cache invalidation. Update Dockerfile comments for
Podman compatibility. Remove package dependency from build target.
This commit is contained in:
pnoker
2026-05-17 19:18:24 +08:00
parent 946f5b7efe
commit a9c1908797
3 changed files with 15 additions and 5 deletions
+9
View File
@@ -17,6 +17,15 @@
**/*.ipr
**/*.md
# Container/build metadata is parsed by the build engine or used on the host,
# but Maven does not need it inside the builder stage. Keep it out of `COPY . .`
# so documentation or compose-only edits do not invalidate the Maven layer.
Dockerfile
.dockerignore
Makefile
dc3/docker-compose*.yml
.github
# Maven build outputs — must be excluded so the builder stage starts from
# clean sources and host-side jars never leak into the image.
**/target
+5 -4
View File
@@ -21,8 +21,9 @@
# Unified multi-target Dockerfile for IoT DC3.
#
# Build context MUST be the repo root. Maven runs INSIDE the builder stage —
# no host JDK / Maven required. BuildKit deduplicates the builder stage across
# multiple --target invocations, so 13 service images cost ONE Maven build.
# no host JDK / Maven required. When the build context and args are unchanged,
# Docker BuildKit / Podman Buildah reuse the builder stage cache across service
# targets, so multiple service images do not rerun Maven.
#
# Build a single service:
# docker build --target dc3-gateway -t pnoker/dc3-gateway:dev .
@@ -43,7 +44,7 @@
# JARs are platform-agnostic, so we never want Maven to run under QEMU
# emulation when producing arm64 + amd64 images.
#
# --mount=type=cache caches ~/.m2/repository across builds (BuildKit feature).
# --mount=type=cache caches ~/.m2/repository across builds.
# -----------------------------------------------------------------------------
FROM --platform=$BUILDPLATFORM pnoker/dc3-jdk:21 AS builder
LABEL dc3.author=pnoker
@@ -84,7 +85,7 @@ RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# Service targets — one per microservice. Each target:
# 1. inherits runtime-base
# 2. sets service-specific ENV / WORKDIR / EXPOSE / VOLUME
# 3. COPYs its prebuilt jar from the host build (build context = repo root)
# 3. COPYs its jar from the builder stage
# 4. copies the prebaked entrypoint.sh from the base image
# =============================================================================
+1 -1
View File
@@ -194,7 +194,7 @@ dev-all:
@$(MAKE) dev-optional REGISTRY=$(REGISTRY) COMPOSE='$(COMPOSE)' COMPOSE_DIR='$(COMPOSE_DIR)' $(MAKE_COMPOSE_OVERRIDE)
@$(MAKE) dev REGISTRY=$(REGISTRY) COMPOSE='$(COMPOSE)' COMPOSE_DIR='$(COMPOSE_DIR)' $(MAKE_COMPOSE_OVERRIDE)
build: package
build:
@$(MAKE) compose-build STACK=dev REGISTRY=$(REGISTRY) COMPOSE='$(COMPOSE)' COMPOSE_DIR='$(COMPOSE_DIR)' $(MAKE_COMPOSE_OVERRIDE)
deploy: package