Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (58 loc) · 3 KB
/
Copy pathDockerfile
File metadata and controls
66 lines (58 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# syntax=docker/dockerfile:1
#
# Builds the plugin-proxy Velocity-plugin JAR and packages it for the
# platform-test environment. The output image carries the JAR at
# /jar/plugin.jar — the shape the `plugin-velocity-jar` Helm chart expects
# (oci://ghcr.io/groundsgg/charts/plugin-velocity-jar). Velocity proxy pods
# in a per-engineer vCluster fetch this image's JAR via the chart's
# init-container + httpd indirection.
#
# Pushed as `ghcr.io/groundsgg/plugin-proxy:edge` (main) / `:<semver>` (tag)
# by .github/workflows/docker-gradle-build-push.yml.
FROM eclipse-temurin:25-jdk AS build
WORKDIR /src
# GitHub Packages credentials for the gg.grounds.velocity convention plugin.
# The token comes from the `github_token` build secret (never a build-arg —
# that would leak it into the layer history).
ARG GITHUB_USER
# Copy gradle wrapper + root config first so dependency caches stay warm
# across source-only changes.
COPY .release-please-manifest.json ./
RUN version="$(sed -n 's/.*"\.": *"\([^"]*\)".*/\1/p' .release-please-manifest.json)" && \
test -n "$version" && \
printf 'versionOverride=%s\n' "$version" > /tmp/grounds-release-version.properties
COPY gradle/ gradle/
COPY gradlew settings.gradle.kts build.gradle.kts gradle.properties ./
COPY api/ api/
COPY velocity/ velocity/
# `:velocity:build` produces the shaded plugin JAR (the api module, the NATS
# client and the generated service-config stubs are bundled into it — the proxy
# plugin owns the ProxyServiceRegistry that plugin-chat resolves at runtime).
#
# Every module `settings.gradle.kts` includes has to be copied above: Gradle
# fails configuration on an included project with no directory, and the failure
# names the module rather than the missing COPY.
RUN --mount=type=secret,id=github_token,required=true \
--mount=type=secret,id=gradle_init,target=/root/.gradle/init.d/grounds-maven-mirror.init.gradle.kts,required=false \
/bin/sh -euc '\
: "${GITHUB_USER:?GITHUB_USER build arg is required}"; \
token="$(cat /run/secrets/github_token)"; \
version="$(cut -d= -f2 /tmp/grounds-release-version.properties)"; \
./gradlew --no-daemon :velocity:build \
-PversionOverride="${version}" \
-Pgithub.user="${GITHUB_USER}" \
-Pgithub.token="${token}" \
'
RUN mkdir -p /out && \
cp "$(ls -S /src/velocity/build/libs/*.jar | head -n1)" /out/plugin.jar
# Fail the image build if shaded metadata loses the producing release version.
RUN mkdir -p /tmp/manifest-check && cd /tmp/manifest-check && \
jar xf /out/plugin.jar META-INF/grounds/permissions/plugin-proxy.json && \
version="$(cut -d= -f2 /tmp/grounds-release-version.properties)" && \
grep -F "\"sourceVersion\": \"${version}\"" META-INF/grounds/permissions/plugin-proxy.json
FROM alpine:3
RUN mkdir -p /jar
COPY --from=build /out/plugin.jar /jar/plugin.jar
# No ENTRYPOINT — the plugin-velocity-jar chart's init-container `cp`s
# /jar/plugin.jar out, then the chart's main container (busybox httpd)
# serves the JAR. This image only carries data.