From 924b8e652cf63648b1368b60f42a00158fc6e172 Mon Sep 17 00:00:00 2001 From: Nathan Mo <54135657+QizhengMo@users.noreply.github.com> Date: Mon, 6 Nov 2023 17:39:32 +0800 Subject: [PATCH] Fix dockerfile (#208) * feat: docker file --- .github/workflows/docker-image.yml | 24 ------------------------ Dockerfile | 10 ++++++---- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index f9c04b3d..134c11d4 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -4,31 +4,7 @@ on: workflow_dispatch: jobs: - - build: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'temurin' - server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml - server-username: MAVEN_USERNAME # env variable for username in deploy - server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy - gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import - gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase - - - name: Build with Maven - run: mvn -B -ntp clean package -DskipTests=true -Pjar - docker: - needs: build runs-on: ubuntu-latest steps: - name: Checkout diff --git a/Dockerfile b/Dockerfile index 09cc46e8..af8640b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ -FROM tomcat:9.0-jdk8-openjdk - -ARG WAR_FILE=./target/arex-schedule-web-api.war -ADD $WAR_FILE /usr/local/tomcat/webapps/ +FROM maven:3-openjdk-8-slim as builder +COPY . /usr/src/app/ +WORKDIR /usr/src/app/arex-schedule-web-api +RUN mvn clean package -DskipTests +FROM tomcat:9.0-jdk8-openjdk +COPY --from=builder /usr/src/app/arex-schedule-web-api/target/arex-schedule-web-api.war /usr/local/tomcat/webapps/arex-schedule-web-api.war WORKDIR /usr/local/tomcat/conf RUN sed -i 'N;152a\\t' server.xml