Skip to content

Commit 6d22e46

Browse files
committed
CF-4258: review comment changes
1 parent 0c61ed3 commit 6d22e46

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

docker/Dockerfile

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
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
124
FROM openjdk:8-jre-alpine
225

326
LABEL maintainer="AtomHopperTeam@rackspace.com" \
@@ -41,9 +64,8 @@ RUN apk --no-cache add curl wget \
4164
&& rm /tmp/tomcat.tar.gz
4265
COPY 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

4870
RUN rm -rf ${CATALINA_HOME}/webapps/* \
4971
&& mkdir -p ${CATALINA_HOME}/webapps \

0 commit comments

Comments
 (0)