Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
js/node_modules
target
.git
.DS_Store
dist
js/dist
41 changes: 41 additions & 0 deletions infra/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Build the React frontend
FROM mirror.gcr.io/library/node:20 AS frontend-build

WORKDIR /js
COPY js/package.json js/pnpm-lock.yaml ./
RUN corepack enable pnpm && pnpm i --frozen-lockfile

COPY js/ ./
RUN pnpm run build

# Build the Spring Boot backend and package the frontend into the app
FROM mirror.gcr.io/library/eclipse-temurin:25-jdk-jammy AS backend-build

WORKDIR /app
COPY mvnw pom.xml ./
COPY .mvn/ .mvn/
RUN ./mvnw dependency:resolve -B

COPY src ./src
COPY --from=frontend-build /js/dist/ src/main/resources/static/
RUN ./mvnw package -B -DskipTests

# Create the final runtime image
FROM mirror.gcr.io/library/eclipse-temurin:25-jre-jammy

RUN groupadd --system spring \
&& useradd --system --gid spring --home-dir /app spring \
&& mkdir -p /app \
&& chown spring:spring /app

WORKDIR /app

COPY --from=backend-build --chown=spring:spring /app/target/*.jar app.jar

ARG SERVER_PROFILES=prod
ENV SPRING_PROFILES_ACTIVE=${SERVER_PROFILES}

USER spring:spring

EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
Loading