From e7b0c49e0c90664b0edcb5b127bc449dc25aae5e Mon Sep 17 00:00:00 2001 From: gipo355 <91525512+gipo355@users.noreply.github.com> Date: Wed, 29 May 2024 16:01:22 +0200 Subject: [PATCH] WIP rename to tomcat webapp boilerplate --- .github/{workflows => inactive}/gh-pages.yml | 0 .../{ => old}/dependency-review-on-push.yml | 0 .github/inactive/{ => old}/gradle.yml | 0 .github/inactive/{ => old}/maven-publish.yml | 0 .github/inactive/{ => old}/mirror-repo.yml | 0 .github/inactive/{ => old}/sonarqube.yml | 0 .github/inactive/{ => old}/test-signing.yml | 0 .github/{workflows => inactive}/publish.yml | 0 .github/workflows/publish-docker.yml | 80 +++++++++++++++++++ compose.dev.yml | 4 +- docker/builder.Dockerfile | 12 +-- http/queries.http | 4 +- settings.gradle | 2 +- 13 files changed, 91 insertions(+), 11 deletions(-) rename .github/{workflows => inactive}/gh-pages.yml (100%) rename .github/inactive/{ => old}/dependency-review-on-push.yml (100%) rename .github/inactive/{ => old}/gradle.yml (100%) rename .github/inactive/{ => old}/maven-publish.yml (100%) rename .github/inactive/{ => old}/mirror-repo.yml (100%) rename .github/inactive/{ => old}/sonarqube.yml (100%) rename .github/inactive/{ => old}/test-signing.yml (100%) rename .github/{workflows => inactive}/publish.yml (100%) create mode 100644 .github/workflows/publish-docker.yml diff --git a/.github/workflows/gh-pages.yml b/.github/inactive/gh-pages.yml similarity index 100% rename from .github/workflows/gh-pages.yml rename to .github/inactive/gh-pages.yml diff --git a/.github/inactive/dependency-review-on-push.yml b/.github/inactive/old/dependency-review-on-push.yml similarity index 100% rename from .github/inactive/dependency-review-on-push.yml rename to .github/inactive/old/dependency-review-on-push.yml diff --git a/.github/inactive/gradle.yml b/.github/inactive/old/gradle.yml similarity index 100% rename from .github/inactive/gradle.yml rename to .github/inactive/old/gradle.yml diff --git a/.github/inactive/maven-publish.yml b/.github/inactive/old/maven-publish.yml similarity index 100% rename from .github/inactive/maven-publish.yml rename to .github/inactive/old/maven-publish.yml diff --git a/.github/inactive/mirror-repo.yml b/.github/inactive/old/mirror-repo.yml similarity index 100% rename from .github/inactive/mirror-repo.yml rename to .github/inactive/old/mirror-repo.yml diff --git a/.github/inactive/sonarqube.yml b/.github/inactive/old/sonarqube.yml similarity index 100% rename from .github/inactive/sonarqube.yml rename to .github/inactive/old/sonarqube.yml diff --git a/.github/inactive/test-signing.yml b/.github/inactive/old/test-signing.yml similarity index 100% rename from .github/inactive/test-signing.yml rename to .github/inactive/old/test-signing.yml diff --git a/.github/workflows/publish.yml b/.github/inactive/publish.yml similarity index 100% rename from .github/workflows/publish.yml rename to .github/inactive/publish.yml diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml new file mode 100644 index 0000000..3d374d0 --- /dev/null +++ b/.github/workflows/publish-docker.yml @@ -0,0 +1,80 @@ +name: Publish Docker Image Workflow +on: + release: + types: [published] + workflow_dispatch: {} +jobs: + publish-docker: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + permissions: + contents: read + packages: write + name: Publish release Job + steps: + - name: Checkout latest code + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 + - uses: ./.github/actions/ci-setup + name: Setup CI environment + - name: Publish artifact Step + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # for com.vanniktech.maven.publish.SonatypeHost + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSWORD }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_PASSWORD }} + run: | + NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3 | cut -d "v" -f2-) # 1.0.0-dev.1 + echo "New version: ${NEW_VERSION}" + echo "Github username: ${GITHUB_ACTOR}" + ./gradlew -Pversion=${NEW_VERSION} publishAndReleaseToMavenCentral --no-configuration-cache + ./gradlew -Pversion=${NEW_VERSION} publishAllPublicationsToGitHubPackagesRepository + steps: + - name: Checkout latest code + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 + - name: Setup CI environment + uses: ./.github/actions/ci-setup + # build and deploy + - name: Build project + run: ./gradlew war + # prepare tags + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + ghcr.io/gipo999/webapp-boilerplate + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + ## DOCKER BUILD AND PUSH to GHCR + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{github.actor}} + password: ${{secrets.GITHUB_TOKEN}} + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,windows/amd64 + push: true + # tags: ghcr.io/${{ github.repository_owner }}/its-battistar-express:latest + tags: ${{ steps.meta.outputs.tags }}, ghcr.io/${{ github.repository_owner }}/wepapp-boilerplate:latest + labels: ${{ steps.meta.outputs.labels }} diff --git a/compose.dev.yml b/compose.dev.yml index a3c1946..288a600 100644 --- a/compose.dev.yml +++ b/compose.dev.yml @@ -1,10 +1,10 @@ services: - webapp-boilerplate: + tomcat-webapp-boilerplate: # environment: # image: tomcat:9-jdk21-temurin-jammy build: dockerfile: ./docker/tomcat.Dockerfile - container_name: webapp-boilerplate + container_name: tomcat-webapp-boilerplate develop: watch: - action: sync+restart diff --git a/docker/builder.Dockerfile b/docker/builder.Dockerfile index c5ebeee..caea505 100644 --- a/docker/builder.Dockerfile +++ b/docker/builder.Dockerfile @@ -22,18 +22,18 @@ FROM eclipse-temurin:21 # create a user to run the app to prevent filesystem access conflicts -RUN addgroup --system webapp-boilerplate && \ - adduser --system -G webapp-boilerplate webapp-boilerplate +RUN addgroup --system tomcat-webapp-boilerplate && \ + adduser --system -G tomcat-webapp-boilerplate tomcat-webapp-boilerplate -RUN mkdir -p /home/webapp-boilerplate +RUN mkdir -p /home/tomcat-webapp-boilerplate -COPY . /home/webapp-boilerplate +COPY . /home/tomcat-webapp-boilerplate RUN chown -R its-battistar-be-go:its-battistar-be-go . -WORKDIR /home/webapp-boilerplate +WORKDIR /home/tomcat-webapp-boilerplate -USER webapp-boilerplate +USER tomcat-webapp-boilerplate # RUN ./gradlew war diff --git a/http/queries.http b/http/queries.http index 41835f6..a7db8b5 100644 --- a/http/queries.http +++ b/http/queries.http @@ -1,5 +1,5 @@ --- -GET http://localhost:8080/webapp-boilerplate/app/base +GET http://localhost:8080/tomcat-webapp-boilerplate/app/base --- -POST http://localhost:8080/webapp-boilerplate/app/base/health +POST http://localhost:8080/tomcat-webapp-boilerplate/app/base/health diff --git a/settings.gradle b/settings.gradle index 8a0266d..123c7cf 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,4 +2,4 @@ plugins { id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' } -rootProject.name = 'webapp-boilerplate' +rootProject.name = 'tomcat-webapp-boilerplate'