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