Skip to content

Commit

Permalink
Updated the workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Apurva14A committed Aug 9, 2023
1 parent f6ef075 commit d3cad56
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
distribution: 'temurin'
cache: maven
- run: mvn --batch-mode --update-snapshots verify
- run: mkdir staging && cp target/*.war staging
- run: mkdir staging && cp target/*.war staging/books.war

- name: Image build using Dockerfile
run :
docker build -t aapurva/java-webapps:v1.0.0 ../Dockerfile
docker build -t aapurva/java-webapps:v1.0.0 .


26 changes: 16 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Use an official Tomcat image as the base
FROM tomcat:9.0-jdk11
# the first stage of our build will use a maven 3.6.1 parent image
FROM maven:3.6.1-jdk-8-alpine AS MAVEN_BUILD

# Remove the default Tomcat applications
RUN rm -rf /usr/local/tomcat/webapps/*
# copy the pom and src code to the container
COPY ./ ./

# Copy the .war artifact from the artifacts directory to the Tomcat webapps directory
COPY ./staging/*.war /usr/local/tomcat/webapps/ROOT.war
# package our application code
RUN mvn clean package

# Expose the Tomcat port
EXPOSE 8080
# the second stage of our build will use open jdk 8 on alpine 3.9
FROM tomcat:8.5

# Start Tomcat
CMD ["catalina.sh", "run"]
# Removing files from tomact webapp directory and creating a new directory
RUN rm -rf /usr/local/tomcat/webapps/*

# copy only the artifacts we need from the first stage and discard the rest
COPY --from=MAVEN_BUILD /onlinebookstore/target/*war /usr/local/tomcat/webapps/books.war

# set the startup command to execute the jar
CMD ["java", "-jar", "/demo.jar"]

0 comments on commit d3cad56

Please sign in to comment.