From ff05a7a688cc4daadf4c3aa4462c64a1cb83f468 Mon Sep 17 00:00:00 2001 From: Fmar Date: Fri, 8 Nov 2024 12:55:14 +0100 Subject: [PATCH] change Dockerfile to build .war and add simple build docker workflow --- .github/workflows/build-docker.yml | 24 ++++++++++++++++++++++++ java/Dockerfile | 14 +++++++++----- 2 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build-docker.yml diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 0000000..21a5280 --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,24 @@ +name: Continuous Integration + +on: [push, pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Docker build + uses: mr-smithers-excellent/docker-build-push@v5 + id: build + with: + image: ${{ env.IMAGENAME }} + registry: ${{ env.REGISTRY }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} diff --git a/java/Dockerfile b/java/Dockerfile index 83a49fb..3417a91 100644 --- a/java/Dockerfile +++ b/java/Dockerfile @@ -1,12 +1,16 @@ +FROM gradle:jdk17-jammy as builder + +WORKDIR /build +COPY . ./ +RUN gradle wrapper --gradle-version 8.1.1 +RUN ./gradlew build -x test + +########################################################################## # Use official Tomcat base image FROM tomcat:jre17 # Copy WAR file -COPY app/build/libs/vss-1.0.war /usr/local/tomcat/webapps/vss.war - -ENV vss.jdbc.url="jdbc:postgresql://postgres:5432/postgres" -ENV vss.jdbc.username=postgres -ENV vss.jdbc.password=YOU_MUST_CHANGE_THIS_PASSWORD +COPY --from=builder /build/app/build/libs/vss-1.0.war /usr/local/tomcat/webapps/vss.war EXPOSE 8080 CMD ["catalina.sh", "run"]