From bbd53553ccc43f0765975be61c5055b9f7ca9b8d Mon Sep 17 00:00:00 2001 From: Nathan Mo <54135657+QizhengMo@users.noreply.github.com> Date: Mon, 6 Nov 2023 15:24:12 +0800 Subject: [PATCH 1/3] feat: docker image ci --- .github/workflows/docker-image.yml | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 00000000..e8dd1d13 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,52 @@ +name: Docker Image CI + +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: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: arexadmin01/arex-replay-schedule:$RELEASE_VERSION From 609f2682cda074b9b1812c0469e1577122a38df0 Mon Sep 17 00:00:00 2001 From: qzmo Date: Mon, 6 Nov 2023 15:27:28 +0800 Subject: [PATCH 2/3] feat: docker file --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..09cc46e8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM tomcat:9.0-jdk8-openjdk + +ARG WAR_FILE=./target/arex-schedule-web-api.war +ADD $WAR_FILE /usr/local/tomcat/webapps/ + +WORKDIR /usr/local/tomcat/conf +RUN sed -i 'N;152a\\t' server.xml + +WORKDIR /usr/local/tomcat +EXPOSE 8080 +CMD ["catalina.sh","run"] From b1364ea85e3658f0d59e042379a514825971e996 Mon Sep 17 00:00:00 2001 From: qzmo Date: Mon, 6 Nov 2023 15:51:38 +0800 Subject: [PATCH 3/3] feat: docker file --- .github/workflows/docker-image.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index e8dd1d13..ed4415e2 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -28,6 +28,7 @@ jobs: run: mvn -B -ntp clean package -DskipTests=true -Pjar docker: + needs: build runs-on: ubuntu-latest steps: - name: Checkout @@ -49,4 +50,5 @@ jobs: context: . platforms: linux/amd64,linux/arm64 push: true - tags: arexadmin01/arex-replay-schedule:$RELEASE_VERSION + tags: ${{ secrets.DOCKER_USERNAME }}/arex-replay-schedule:${{ $RELEASE_VERSION }} +