-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (38 loc) · 1.96 KB
/
Copy pathDockerfile
File metadata and controls
49 lines (38 loc) · 1.96 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
# Multi-stage build for the GTFS Validator API.
# --- Build stage -------------------------------------------------------------
FROM maven:3.9-eclipse-temurin-17 AS build
WORKDIR /workspace
# Optional comma-separated Maven profiles to activate (e.g. "snapshot" to build
# against a pre-release SNAPSHOT of the GTFS validator core). Empty by default,
# which produces a stable build.
ARG MAVEN_PROFILES=""
# Cache dependencies first.
COPY pom.xml .
COPY .openapi-generator-ignore .
RUN mvn -B -q ${MAVEN_PROFILES:+-P}${MAVEN_PROFILES} dependency:go-offline
# Build the application.
COPY src ./src
COPY docs ./docs
RUN mvn -B -q ${MAVEN_PROFILES:+-P}${MAVEN_PROFILES} clean package -DskipTests
# --- Runtime stage -----------------------------------------------------------
FROM eclipse-temurin:17-jre
# Link the published GHCR package to its source repository so it appears in the
# repo's Packages section (and inherits the repo for permissions/visibility).
# Overridable so forks publish under their own repo: CI passes the lower-cased
# ${{ github.repository }}. The default keeps local builds labelled sensibly.
ARG IMAGE_SOURCE="https://github.com/mobilitydata/gtfs-validator-api.git"
LABEL org.opencontainers.image.source="${IMAGE_SOURCE}"
# Override the metadata inherited from the base image, which otherwise leaves the
# published image advertising itself as Ubuntu. CI repeats these as index
# annotations (see docker.yml) because a LABEL does not reach the OCI index of a
# multi-platform build.
LABEL org.opencontainers.image.title="gtfs-validator-api"
LABEL org.opencontainers.image.description="REST API wrapping the MobilityData GTFS validator."
LABEL org.opencontainers.image.licenses="Apache-2.0"
RUN groupadd -r spring && useradd -r -g spring spring
WORKDIR /app
COPY --from=build /workspace/target/gtfs-validator-api-*.jar /app/gtfs-validator-api.jar
USER spring:spring
EXPOSE 8080
ENV JAVA_OPTS=""
ENTRYPOINT ["sh", "-c", "exec java $JAVA_OPTS -jar /app/gtfs-validator-api.jar"]