File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed
Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change 1+ # Multi-stage build: first stage for building the application
2+ FROM openjdk:8-jdk-alpine AS builder
3+
4+ # Install Maven
5+ RUN apk add --no-cache curl tar bash \
6+ && mkdir -p /usr/share/maven /usr/share/maven/ref \
7+ && curl -fsSL -o /tmp/apache-maven.tar.gz https://archive.apache.org/dist/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz \
8+ && tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
9+ && rm -f /tmp/apache-maven.tar.gz \
10+ && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
11+
12+ # Set Maven environment
13+ ENV MAVEN_HOME /usr/share/maven
14+ ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
15+
16+ # Copy source code
17+ WORKDIR /app
18+ COPY . .
19+
20+ # Build the application
21+ RUN mvn clean package -DskipTests
22+
23+ # Second stage: runtime image
124FROM openjdk:8-jre-alpine
225
326LABEL maintainer="AtomHopperTeam@rackspace.com" \
@@ -41,9 +64,8 @@ RUN apk --no-cache add curl wget \
4164 && rm /tmp/tomcat.tar.gz
4265COPY docker/start.sh .
4366
44- # Copy the locally built WAR file instead of downloading
45- # Note: Build the project first with 'mvn clean package' from the root directory
46- COPY atomhopper/target/atomhopper-*.war atomhopper.war
67+ # Copy the WAR file from the builder stage
68+ COPY --from=builder /app/atomhopper/target/atomhopper-*.war atomhopper.war
4769
4870RUN rm -rf ${CATALINA_HOME}/webapps/* \
4971 && mkdir -p ${CATALINA_HOME}/webapps \
You can’t perform that action at this time.
0 commit comments