From f6ef07590f127658184414620691a8bcd7a1fc12 Mon Sep 17 00:00:00 2001 From: Ashutosh Apurva Date: Tue, 8 Aug 2023 05:16:21 +0000 Subject: [PATCH] Added Dockerfile --- .github/workflows/build.yaml | 1 + .github/workflows/build_image.yaml | 28 ++++++++++++++++++++++++++++ Dockerfile | 14 ++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 .github/workflows/build_image.yaml create mode 100644 Dockerfile diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index bb6ed1a2..b451b95e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -37,6 +37,7 @@ jobs: uses: actions/download-artifact@v3 with: name: onlinebookstore + path: staging - name: Test the arifacts run: ls -R diff --git a/.github/workflows/build_image.yaml b/.github/workflows/build_image.yaml new file mode 100644 index 00000000..bb3aacb0 --- /dev/null +++ b/.github/workflows/build_image.yaml @@ -0,0 +1,28 @@ +name: OnlineBookStoreImageBuild + +on: [push] + +jobs: + build-image: + name: Build the image + runs-on: ubuntu:latest + + steps: + + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Setup java + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - run: mvn --batch-mode --update-snapshots verify + - run: mkdir staging && cp target/*.war staging + + - name: Image build using Dockerfile + run : + docker build -t aapurva/java-webapps:v1.0.0 ../Dockerfile + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..75d3daba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Use an official Tomcat image as the base +FROM tomcat:9.0-jdk11 + +# Remove the default Tomcat applications +RUN rm -rf /usr/local/tomcat/webapps/* + +# Copy the .war artifact from the artifacts directory to the Tomcat webapps directory +COPY ./staging/*.war /usr/local/tomcat/webapps/ROOT.war + +# Expose the Tomcat port +EXPOSE 8080 + +# Start Tomcat +CMD ["catalina.sh", "run"]