-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
84 lines (53 loc) · 1.79 KB
/
Copy pathDockerfile
File metadata and controls
84 lines (53 loc) · 1.79 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
FROM node:18-alpine AS build-web
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /app
COPY pnpm-lock.yaml ./
COPY pnpm-workspace.yaml ./
# Build web app
COPY apps/web/package.json ./
RUN pnpm install --no-frozen-lockfile
COPY apps/web .
RUN pnpm install
RUN pnpm run build
RUN mv dist/index.html dist/app.html
FROM node:18-alpine AS build-index
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /app
COPY pnpm-lock.yaml ./
COPY pnpm-workspace.yaml ./
# Build landing page
COPY landing-page/package.json ./
RUN pnpm install --no-frozen-lockfile
COPY landing-page .
RUN pnpm install
RUN pnpm run build
FROM amazoncorretto:21-alpine AS build
WORKDIR /app
# Install findutils (gradlew sometimes requires xargs/find)
RUN apk add --no-cache findutils
COPY ./api/build.gradle.kts ./api/settings.gradle.kts ./api/gradlew ./
COPY ./api/gradle ./gradle
COPY api/src ./src
# Inject the compiled frontends into Spring Boot's static resources
COPY --from=build-web /app/dist/ ./src/main/resources/static
COPY --from=build-index /app/dist ./src/main/resources/static
RUN chmod +x ./gradlew
# Build the standard JVM fat JAR.
# We use -x test to skip tests during the Docker build for speed.
RUN ./gradlew build --no-daemon -x test
FROM amazoncorretto:21-alpine AS runtime
WORKDIR /app
# Create a non-root user for security (Best practice for AWS Fargate)
RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring
# Copy the compiled JAR from the build stage.
# (Spring Boot creates the executable JAR in build/libs/)
COPY --from=build /app/build/libs/*.jar app.jar
EXPOSE 8080
# Run the JVM.
# We add MaxRAMPercentage so the JVM respects AWS Fargate container memory limits!
ENTRYPOINT ["java", "-XX:MaxRAMPercentage=75.0", "-jar", "app.jar"]