|
1 | | -FROM eclipse-temurin:17-jdk |
| 1 | +FROM eclipse-temurin:21-jdk AS base |
2 | 2 | MAINTAINER daynnnnn |
3 | 3 |
|
| 4 | +# Setting environment variables |
4 | 5 | ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 |
5 | 6 |
|
| 7 | +# Arguments for database configuration |
6 | 8 | ARG DB_HOST |
7 | 9 | ARG DB_USERNAME |
8 | 10 | ARG DB_PASSWORD |
9 | 11 | ARG DB_DATABASE |
10 | 12 | ARG DB_PORT |
11 | 13 |
|
| 14 | +# Build Stage |
| 15 | +FROM base as build |
| 16 | + |
| 17 | +# Set the working directory for the build stage |
12 | 18 | WORKDIR /code |
13 | 19 |
|
| 20 | +# Copy project files to the build stage |
14 | 21 | ADD /src /code/src |
15 | 22 | ADD /website /code/website |
16 | 23 | ADD /pom.xml /code/pom.xml |
| 24 | +ADD mvnw /code/mvnw |
| 25 | +ADD .mvn /code/.mvn |
17 | 26 |
|
| 27 | +# Replace placeholders in pom.xml with actual environment values |
18 | 28 | RUN sed -i 's|${db.ip}|${env.DB_HOST}|g' pom.xml |
19 | 29 | RUN sed -i 's|${db.port}|${env.DB_PORT}|g' pom.xml |
20 | 30 | RUN sed -i 's|${db.user}|${env.DB_USERNAME}|g' pom.xml |
21 | 31 | RUN sed -i 's|${db.password}|${env.DB_PASSWORD}|g' pom.xml |
22 | 32 | RUN sed -i 's|${db.schema}|${env.DB_DATABASE}|g' pom.xml |
| 33 | +RUN sed -i 's|${server.host}|${env.SERVER_HOST}|g' pom.xml |
| 34 | + |
| 35 | +# Make the Maven wrapper executable |
| 36 | +RUN chmod +x mvnw |
23 | 37 |
|
| 38 | +# Build the project |
24 | 39 | RUN ./mvnw clean package -Pkubernetes -Djdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2" |
25 | 40 |
|
26 | | -CMD java -jar target/steve.jar |
| 41 | +# Release Stage |
| 42 | +FROM base AS release |
| 43 | + |
| 44 | +# Copy relevant files from the build stage |
| 45 | +COPY --from=build /code/target/steve.jar /app/steve.jar |
| 46 | +COPY --from=build /code/target/libs /app/libs |
| 47 | + |
| 48 | +# Expose any necessary ports (example: 8080) |
| 49 | +EXPOSE 8080 |
27 | 50 |
|
| 51 | +# Define the entrypoint for the release stage |
| 52 | +CMD ["java", "-jar", "/app/steve.jar"] |
0 commit comments