From 5aadca5e4905aaa6401d50689dea406fe7ddad01 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 22 Apr 2021 11:41:09 +0200 Subject: [PATCH 01/15] test docker build --- .github/workflows/buildReporting.yml | 112 +++++++++++++++++++++++---- docker/Dockerfile | 19 +++++ docker/start-sebserver.sh | 21 +++++ 3 files changed, 138 insertions(+), 14 deletions(-) create mode 100644 docker/Dockerfile create mode 100644 docker/start-sebserver.sh diff --git a/.github/workflows/buildReporting.yml b/.github/workflows/buildReporting.yml index bc11cd6e..b10b5326 100644 --- a/.github/workflows/buildReporting.yml +++ b/.github/workflows/buildReporting.yml @@ -5,27 +5,111 @@ name: build on: push: - branches: [master, development] + branches: [master, development, docker-setup] pull_request: - branches: [master, development] + branches: [master, development, docker-setup] jobs: - build: - + maven-build: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 8 + - + name: Get short SHA + uses: benjlevesque/short-sha@v1.2 + id: short-sha + - + name: Store short SHA as environment variable + run: echo $SHA + env: + SHA: ${{ steps.short-sha.outputs.sha }} + - + name: Checkout repository + uses: actions/checkout@v2 + - + name: Set up JDK 8 uses: actions/setup-java@v2 with: java-version: '8' distribution: 'adopt' - - name: Build with Maven - run: mvn clean install -e -P let_reporting - - uses: codecov/codecov-action@v1 + - + name: Cache Maven packages + uses: actions/cache@v2 with: - flags: unittests # optional - name: SEB Server Build # optional - fail_ci_if_error: false # optional (default = false) - verbose: false # optional (default = false) + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - + name: Build with Maven + run: mvn clean install -e -P let_reporting -Dbuild-version="${{ env.SHA }}" + env: + sebserver-version: ${{ env.SHA }} + - + name: Reporting + uses: codecov/codecov-action@v1 + with: + flags: unittests + name: SEB Server Build + fail_ci_if_error: false + verbose: false + - + name: Simplify package name + run: mv target/seb-server-${{ env.SHA }}.jar target/seb-server.jar + - + uses: actions/upload-artifact@v2 + with: + name: Package + path: target/seb-server.jar + + docker-build: + # Run only on tagging + # if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Checkout repository + uses: actions/checkout@v2 + - + name: Download a single artifact + uses: actions/download-artifact@v2 + with: + name: Package + # - + # name: Generate tags + # id: docker_tags + # uses: dnaka91/action-docker-tags@v0.1 + # - + # name: Show generated tags + # run: echo "${{ steps.docker_tags.outputs.tags }}" + - + name: Get short SHA + uses: benjlevesque/short-sha@v1.2 + id: short-sha + - + name: Store short SHA as environment variable + run: echo $SHA + env: + SHA: ${{ steps.short-sha.outputs.sha }} + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + file: ./docker/Dockerfile + push: true + tags: | + anhefti/seb-server:latest + anhefti/seb-server:${{ env.SHA }} + diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..1dbfc4f5 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,19 @@ +FROM openjdk:11-jre-stretch + +ARG SEBSERVER_VERSION +ENV SEBSERVER_JAR="seb-server-${SEBSERVER_VERSION}.jar" +ENV SERVER_PORT="8080" +ENV JMX_PORT= +ENV JAVA_HEAP_MIN= +ENV JAVA_HEAP_MAX= + +RUN groupadd --system spring && useradd --system --gid spring spring && mkdir /sebserver && chown spring:spring /sebserver +USER spring:spring + +COPY docker/start-sebserver.sh seb-server.jar /sebserver/ + +WORKDIR /sebserver + +CMD /bin/sh /sebserver/start-sebserver.sh + +EXPOSE $SERVER_PORT $JMX_PORT \ No newline at end of file diff --git a/docker/start-sebserver.sh b/docker/start-sebserver.sh new file mode 100644 index 00000000..e0ee63cf --- /dev/null +++ b/docker/start-sebserver.sh @@ -0,0 +1,21 @@ +if [ "x${JMX_PORT}" = "x" ] ; \ + then exec java \ + -Xms${JAVA_HEAP_MIN} \ + -Xmx${JAVA_HEAP_MAX} \ + -jar "seb-server.jar" \ + --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; \ + else echo "admin ${SEBSERVER_SECRET}" > jmxremote.password && chown spring:spring /sebserver/jmxremote.password && chmod 400 /sebserver/jmxremote.password && exec java \ + -Xms${JAVA_HEAP_MIN} \ + -Xmx${JAVA_HEAP_MAX} \ + -Dcom.sun.management.jmxremote \ + -Dcom.sun.management.jmxremote.port=${JMX_PORT} \ + -Dcom.sun.management.jmxremote.rmi.port=${JMX_PORT} \ + -Djava.rmi.server.hostname=localhost \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -Dcom.sun.management.jmxremote.authenticate=true \ + -Dcom.sun.management.jmxremote.password.file=/sebserver/jmxremote.password \ + -Dcom.sun.management.jmxremote.access.file=/sebserver/config/jmx/jmxremote.access \ + -jar "seb-server.jar" \ + --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; \ +fi \ No newline at end of file From aa98ed6b8fe3af7d3bf0702196541ff2b6b8b02d Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 22 Apr 2021 11:56:12 +0200 Subject: [PATCH 02/15] fixed version tag for maven build --- .github/workflows/buildReporting.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/buildReporting.yml b/.github/workflows/buildReporting.yml index b10b5326..c77e9143 100644 --- a/.github/workflows/buildReporting.yml +++ b/.github/workflows/buildReporting.yml @@ -40,7 +40,7 @@ jobs: restore-keys: ${{ runner.os }}-m2 - name: Build with Maven - run: mvn clean install -e -P let_reporting -Dbuild-version="${{ env.SHA }}" + run: mvn clean install -e -P let_reporting -Dsebserver-version="${{ env.SHA }}" env: sebserver-version: ${{ env.SHA }} - @@ -61,6 +61,7 @@ jobs: path: target/seb-server.jar docker-build: + needs: maven-build # Run only on tagging # if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') runs-on: ubuntu-latest From 1b2be41e1e9d154f511a95da9536d7dc93be0489 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 22 Apr 2021 13:42:01 +0200 Subject: [PATCH 03/15] added build names to env --- .github/workflows/buildReporting.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/buildReporting.yml b/.github/workflows/buildReporting.yml index c77e9143..b70d005d 100644 --- a/.github/workflows/buildReporting.yml +++ b/.github/workflows/buildReporting.yml @@ -13,6 +13,23 @@ jobs: maven-build: runs-on: ubuntu-latest steps: + - + name: Branch name + id: branch_name + run: | + echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/} + echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/} + echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} + - + name: Put names to env + run: | + echo $SOURCE_NAME + echo $SOURCE_BRANCH + echo $SOURCE_TAG + env: + SOURCE_NAME: ${{ steps.branch_name.outputs.SOURCE_NAME }} + SOURCE_BRANCH: ${{ steps.branch_name.outputs.SOURCE_BRANCH }} + SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }} - name: Get short SHA uses: benjlevesque/short-sha@v1.2 From bf92e517343cdded86da5b3761c5b10fafec5761 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 22 Apr 2021 13:56:06 +0200 Subject: [PATCH 04/15] check version --- .github/workflows/buildReporting.yml | 215 ++++++++++++--------------- 1 file changed, 99 insertions(+), 116 deletions(-) diff --git a/.github/workflows/buildReporting.yml b/.github/workflows/buildReporting.yml index b70d005d..8c2f7a15 100644 --- a/.github/workflows/buildReporting.yml +++ b/.github/workflows/buildReporting.yml @@ -14,120 +14,103 @@ jobs: runs-on: ubuntu-latest steps: - - name: Branch name - id: branch_name + name: Set env + run: echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - + name: Test run: | - echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/} - echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/} - echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} - - - name: Put names to env - run: | - echo $SOURCE_NAME - echo $SOURCE_BRANCH - echo $SOURCE_TAG - env: - SOURCE_NAME: ${{ steps.branch_name.outputs.SOURCE_NAME }} - SOURCE_BRANCH: ${{ steps.branch_name.outputs.SOURCE_BRANCH }} - SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }} - - - name: Get short SHA - uses: benjlevesque/short-sha@v1.2 - id: short-sha - - - name: Store short SHA as environment variable - run: echo $SHA - env: - SHA: ${{ steps.short-sha.outputs.sha }} - - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up JDK 8 - uses: actions/setup-java@v2 - with: - java-version: '8' - distribution: 'adopt' - - - name: Cache Maven packages - uses: actions/cache@v2 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: Build with Maven - run: mvn clean install -e -P let_reporting -Dsebserver-version="${{ env.SHA }}" - env: - sebserver-version: ${{ env.SHA }} - - - name: Reporting - uses: codecov/codecov-action@v1 - with: - flags: unittests - name: SEB Server Build - fail_ci_if_error: false - verbose: false - - - name: Simplify package name - run: mv target/seb-server-${{ env.SHA }}.jar target/seb-server.jar - - - uses: actions/upload-artifact@v2 - with: - name: Package - path: target/seb-server.jar - - docker-build: - needs: maven-build - # Run only on tagging - # if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') - runs-on: ubuntu-latest - steps: - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Download a single artifact - uses: actions/download-artifact@v2 - with: - name: Package - # - - # name: Generate tags - # id: docker_tags - # uses: dnaka91/action-docker-tags@v0.1 - # - - # name: Show generated tags - # run: echo "${{ steps.docker_tags.outputs.tags }}" - - - name: Get short SHA - uses: benjlevesque/short-sha@v1.2 - id: short-sha - - - name: Store short SHA as environment variable - run: echo $SHA - env: - SHA: ${{ steps.short-sha.outputs.sha }} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - context: . - file: ./docker/Dockerfile - push: true - tags: | - anhefti/seb-server:latest - anhefti/seb-server:${{ env.SHA }} - + echo $TAG_NAME + echo ${{ env.TAG_NAME }} +# - +# name: Get short SHA +# uses: benjlevesque/short-sha@v1.2 +# id: short-sha +# - +# name: Store short SHA as environment variable +# run: echo $SHA +# env: +# SHA: ${{ steps.short-sha.outputs.sha }} +# - +# name: Checkout repository +# uses: actions/checkout@v2 +# - +# name: Set up JDK 8 +# uses: actions/setup-java@v2 +# with: +# java-version: '8' +# distribution: 'adopt' +# - +# name: Cache Maven packages +# uses: actions/cache@v2 +# with: +# path: ~/.m2 +# key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} +# restore-keys: ${{ runner.os }}-m2 +# - +# name: Build with Maven +# run: mvn clean install -e -P let_reporting -Dsebserver-version="${{ env.SHA }}" +# env: +# sebserver-version: ${{ env.SHA }} +# - +# name: Reporting +# uses: codecov/codecov-action@v1 +# with: +# flags: unittests +# name: SEB Server Build +# fail_ci_if_error: false +# verbose: false +# - +# name: Simplify package name +# run: mv target/seb-server-${{ env.SHA }}.jar target/seb-server.jar +# - +# uses: actions/upload-artifact@v2 +# with: +# name: Package +# path: target/seb-server.jar +# +# docker-build: +# needs: maven-build +# +# runs-on: ubuntu-latest +# steps: +# - +# name: Set up QEMU +# uses: docker/setup-qemu-action@v1 +# - +# name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v1 +# - +# name: Login to DockerHub +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} +# - +# name: Checkout repository +# uses: actions/checkout@v2 +# - +# name: Download a single artifact +# uses: actions/download-artifact@v2 +# with: +# name: Package +# - +# name: Get short SHA +# uses: benjlevesque/short-sha@v1.2 +# id: short-sha +# - +# name: Store short SHA as environment variable +# run: echo $SHA +# env: +# SHA: ${{ steps.short-sha.outputs.sha }} +# - +# name: Build and push +# id: docker_build +# uses: docker/build-push-action@v2 +# with: +# context: . +# file: ./docker/Dockerfile +# push: true +# tags: | +# anhefti/seb-server:latest +# anhefti/seb-server:${{ env.SHA }} +# From 778ad7b4fbd1935f42d74f85f778c86866ac824a Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 22 Apr 2021 14:09:02 +0200 Subject: [PATCH 05/15] github actions on tagging --- .github/workflows/buildReporting.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/buildReporting.yml b/.github/workflows/buildReporting.yml index 8c2f7a15..df4dd318 100644 --- a/.github/workflows/buildReporting.yml +++ b/.github/workflows/buildReporting.yml @@ -8,6 +8,8 @@ on: branches: [master, development, docker-setup] pull_request: branches: [master, development, docker-setup] + tags: + - v* jobs: maven-build: From 983931ec1a6e3047728d8cffd652b948672f1f56 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 22 Apr 2021 14:12:11 +0200 Subject: [PATCH 06/15] tagging --- .github/workflows/buildReporting.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildReporting.yml b/.github/workflows/buildReporting.yml index df4dd318..0711befa 100644 --- a/.github/workflows/buildReporting.yml +++ b/.github/workflows/buildReporting.yml @@ -6,10 +6,10 @@ name: build on: push: branches: [master, development, docker-setup] + tags: + - '*' pull_request: branches: [master, development, docker-setup] - tags: - - v* jobs: maven-build: From 4b90fdcb324e9db09235a776fa22f4f64d185b79 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 22 Apr 2021 14:27:16 +0200 Subject: [PATCH 07/15] build docker only on tagging --- .github/workflows/buildReporting.yml | 169 ++++++++++++++------------- 1 file changed, 85 insertions(+), 84 deletions(-) diff --git a/.github/workflows/buildReporting.yml b/.github/workflows/buildReporting.yml index 0711befa..920bd23a 100644 --- a/.github/workflows/buildReporting.yml +++ b/.github/workflows/buildReporting.yml @@ -13,6 +13,59 @@ on: jobs: maven-build: + runs-on: ubuntu-latest + steps: + - + name: Get short SHA + uses: benjlevesque/short-sha@v1.2 + id: short-sha + - + name: Store short SHA as environment variable + run: echo $SHA + env: + SHA: ${{ steps.short-sha.outputs.sha }} + - + name: Checkout repository + uses: actions/checkout@v2 + - + name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + - + name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - + name: Build with Maven + run: mvn clean install -e -P let_reporting -Dsebserver-version="${{ env.SHA }}" + env: + sebserver-version: ${{ env.SHA }} + - + name: Reporting + uses: codecov/codecov-action@v1 + with: + flags: unittests + name: SEB Server Build + fail_ci_if_error: false + verbose: false + - + name: Simplify package name + run: mv target/seb-server-${{ env.SHA }}.jar target/seb-server.jar + - + uses: actions/upload-artifact@v2 + with: + name: Package + path: target/seb-server.jar + + docker-build: + needs: maven-build + # Run only on tagging + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') runs-on: ubuntu-latest steps: - @@ -23,78 +76,26 @@ jobs: run: | echo $TAG_NAME echo ${{ env.TAG_NAME }} -# - -# name: Get short SHA -# uses: benjlevesque/short-sha@v1.2 -# id: short-sha -# - -# name: Store short SHA as environment variable -# run: echo $SHA -# env: -# SHA: ${{ steps.short-sha.outputs.sha }} -# - -# name: Checkout repository -# uses: actions/checkout@v2 -# - -# name: Set up JDK 8 -# uses: actions/setup-java@v2 -# with: -# java-version: '8' -# distribution: 'adopt' -# - -# name: Cache Maven packages -# uses: actions/cache@v2 -# with: -# path: ~/.m2 -# key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} -# restore-keys: ${{ runner.os }}-m2 -# - -# name: Build with Maven -# run: mvn clean install -e -P let_reporting -Dsebserver-version="${{ env.SHA }}" -# env: -# sebserver-version: ${{ env.SHA }} -# - -# name: Reporting -# uses: codecov/codecov-action@v1 -# with: -# flags: unittests -# name: SEB Server Build -# fail_ci_if_error: false -# verbose: false -# - -# name: Simplify package name -# run: mv target/seb-server-${{ env.SHA }}.jar target/seb-server.jar -# - -# uses: actions/upload-artifact@v2 -# with: -# name: Package -# path: target/seb-server.jar -# -# docker-build: -# needs: maven-build -# -# runs-on: ubuntu-latest -# steps: -# - -# name: Set up QEMU -# uses: docker/setup-qemu-action@v1 -# - -# name: Set up Docker Buildx -# uses: docker/setup-buildx-action@v1 -# - -# name: Login to DockerHub -# uses: docker/login-action@v1 -# with: -# username: ${{ secrets.DOCKERHUB_USERNAME }} -# password: ${{ secrets.DOCKERHUB_TOKEN }} -# - -# name: Checkout repository -# uses: actions/checkout@v2 -# - -# name: Download a single artifact -# uses: actions/download-artifact@v2 -# with: -# name: Package + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Checkout repository + uses: actions/checkout@v2 + - + name: Download a single artifact + uses: actions/download-artifact@v2 + with: + name: Package # - # name: Get short SHA # uses: benjlevesque/short-sha@v1.2 @@ -104,15 +105,15 @@ jobs: # run: echo $SHA # env: # SHA: ${{ steps.short-sha.outputs.sha }} -# - -# name: Build and push -# id: docker_build -# uses: docker/build-push-action@v2 -# with: -# context: . -# file: ./docker/Dockerfile -# push: true -# tags: | -# anhefti/seb-server:latest -# anhefti/seb-server:${{ env.SHA }} -# + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + file: ./docker/Dockerfile + push: true + tags: | + anhefti/seb-server:latest + anhefti/seb-server:${{ env.TAG_NAME }} + From 1963974bab86b95032edfc2607ae94fab8d59444 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 22 Apr 2021 15:22:01 +0200 Subject: [PATCH 08/15] separate workflows for reporting and docker build --- .github/workflows/buildDocker.yml | 97 ++++++++++++++++++++++++++++ .github/workflows/buildReporting.yml | 66 +------------------ 2 files changed, 98 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/buildDocker.yml diff --git a/.github/workflows/buildDocker.yml b/.github/workflows/buildDocker.yml new file mode 100644 index 00000000..b1f7c966 --- /dev/null +++ b/.github/workflows/buildDocker.yml @@ -0,0 +1,97 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: build + +on: + push: + tags: + - '*' +jobs: + maven-build: + runs-on: ubuntu-latest + steps: + - + name: Get short SHA + uses: benjlevesque/short-sha@v1.2 + id: short-sha + - + name: Store short SHA as environment variable + run: echo $SHA + env: + SHA: ${{ steps.short-sha.outputs.sha }} + - + name: Checkout repository + uses: actions/checkout@v2 + - + name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + - + name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - + name: Build with Maven + run: mvn clean install -Dmaven.test.skip=true -Dsebserver-version="${{ env.SHA }}" + env: + sebserver-version: ${{ env.SHA }} + - + name: Simplify package name + run: mv target/seb-server-${{ env.SHA }}.jar target/seb-server.jar + - + uses: actions/upload-artifact@v2 + with: + name: Package + path: target/seb-server.jar + + docker-build: + needs: maven-build + # Run only on tagging + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - + name: Set env + run: echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - + name: Test + run: | + echo $TAG_NAME + echo ${{ env.TAG_NAME }} + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Checkout repository + uses: actions/checkout@v2 + - + name: Download a single artifact + uses: actions/download-artifact@v2 + with: + name: Package + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + file: ./docker/Dockerfile + push: true + tags: | + anhefti/seb-server:latest + anhefti/seb-server:${{ env.TAG_NAME }} \ No newline at end of file diff --git a/.github/workflows/buildReporting.yml b/.github/workflows/buildReporting.yml index 920bd23a..b10e5ac2 100644 --- a/.github/workflows/buildReporting.yml +++ b/.github/workflows/buildReporting.yml @@ -52,68 +52,4 @@ jobs: flags: unittests name: SEB Server Build fail_ci_if_error: false - verbose: false - - - name: Simplify package name - run: mv target/seb-server-${{ env.SHA }}.jar target/seb-server.jar - - - uses: actions/upload-artifact@v2 - with: - name: Package - path: target/seb-server.jar - - docker-build: - needs: maven-build - # Run only on tagging - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') - runs-on: ubuntu-latest - steps: - - - name: Set env - run: echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: Test - run: | - echo $TAG_NAME - echo ${{ env.TAG_NAME }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Download a single artifact - uses: actions/download-artifact@v2 - with: - name: Package -# - -# name: Get short SHA -# uses: benjlevesque/short-sha@v1.2 -# id: short-sha -# - -# name: Store short SHA as environment variable -# run: echo $SHA -# env: -# SHA: ${{ steps.short-sha.outputs.sha }} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - context: . - file: ./docker/Dockerfile - push: true - tags: | - anhefti/seb-server:latest - anhefti/seb-server:${{ env.TAG_NAME }} - + verbose: false \ No newline at end of file From 6914045d48fb9e3b41110eda68ded6ca6ec81f82 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 22 Apr 2021 15:23:32 +0200 Subject: [PATCH 09/15] skip triggering reporting on tagging --- .github/workflows/buildReporting.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/buildReporting.yml b/.github/workflows/buildReporting.yml index b10e5ac2..207fcc2f 100644 --- a/.github/workflows/buildReporting.yml +++ b/.github/workflows/buildReporting.yml @@ -6,8 +6,6 @@ name: build on: push: branches: [master, development, docker-setup] - tags: - - '*' pull_request: branches: [master, development, docker-setup] From 4c79bbdc3cbb446dfa0d057b53aeb096691ff8f4 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 22 Apr 2021 17:44:57 +0200 Subject: [PATCH 10/15] fix docker image check permission problem --- docker/Dockerfile | 7 +++---- docker/start-sebserver.sh | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1dbfc4f5..9bd56538 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,14 +1,13 @@ FROM openjdk:11-jre-stretch -ARG SEBSERVER_VERSION -ENV SEBSERVER_JAR="seb-server-${SEBSERVER_VERSION}.jar" ENV SERVER_PORT="8080" ENV JMX_PORT= ENV JAVA_HEAP_MIN= ENV JAVA_HEAP_MAX= -RUN groupadd --system spring && useradd --system --gid spring spring && mkdir /sebserver && chown spring:spring /sebserver -USER spring:spring +#just try wihtout user to check if we habe a permission problem +#RUN groupadd --system spring && useradd --system --gid spring spring && mkdir /sebserver && chown spring:spring /sebserver +#USER spring:spring COPY docker/start-sebserver.sh seb-server.jar /sebserver/ diff --git a/docker/start-sebserver.sh b/docker/start-sebserver.sh index e0ee63cf..8dc36a19 100644 --- a/docker/start-sebserver.sh +++ b/docker/start-sebserver.sh @@ -1,3 +1,4 @@ +#!/bin/sh if [ "x${JMX_PORT}" = "x" ] ; \ then exec java \ -Xms${JAVA_HEAP_MIN} \ From e4890a0f1387b545564feada1dfe91f04f1f4b35 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 22 Apr 2021 17:58:18 +0200 Subject: [PATCH 11/15] fix docker image get back to roots --- docker/start-sebserver.sh | 48 ++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/docker/start-sebserver.sh b/docker/start-sebserver.sh index 8dc36a19..23dec483 100644 --- a/docker/start-sebserver.sh +++ b/docker/start-sebserver.sh @@ -1,22 +1,28 @@ #!/bin/sh -if [ "x${JMX_PORT}" = "x" ] ; \ - then exec java \ - -Xms${JAVA_HEAP_MIN} \ - -Xmx${JAVA_HEAP_MAX} \ - -jar "seb-server.jar" \ - --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; \ - else echo "admin ${SEBSERVER_SECRET}" > jmxremote.password && chown spring:spring /sebserver/jmxremote.password && chmod 400 /sebserver/jmxremote.password && exec java \ - -Xms${JAVA_HEAP_MIN} \ - -Xmx${JAVA_HEAP_MAX} \ - -Dcom.sun.management.jmxremote \ - -Dcom.sun.management.jmxremote.port=${JMX_PORT} \ - -Dcom.sun.management.jmxremote.rmi.port=${JMX_PORT} \ - -Djava.rmi.server.hostname=localhost \ - -Dcom.sun.management.jmxremote.local.only=false \ - -Dcom.sun.management.jmxremote.ssl=false \ - -Dcom.sun.management.jmxremote.authenticate=true \ - -Dcom.sun.management.jmxremote.password.file=/sebserver/jmxremote.password \ - -Dcom.sun.management.jmxremote.access.file=/sebserver/config/jmx/jmxremote.access \ - -jar "seb-server.jar" \ - --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; \ -fi \ No newline at end of file +exec java \ + -Xms${JAVA_HEAP_MIN} \ + -Xmx${JAVA_HEAP_MAX} \ + -jar "seb-server.jar" \ + --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; + +#if [ "x${JMX_PORT}" = "x" ] ; \ +# then exec java \ +# -Xms${JAVA_HEAP_MIN} \ +# -Xmx${JAVA_HEAP_MAX} \ +# -jar "seb-server.jar" \ +# --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; \ +# else echo "admin ${SEBSERVER_SECRET}" > jmxremote.password && chown spring:spring /sebserver/jmxremote.password && chmod 400 /sebserver/jmxremote.password && exec java \ +# -Xms${JAVA_HEAP_MIN} \ +# -Xmx${JAVA_HEAP_MAX} \ +# -Dcom.sun.management.jmxremote \ +# -Dcom.sun.management.jmxremote.port=${JMX_PORT} \ +# -Dcom.sun.management.jmxremote.rmi.port=${JMX_PORT} \ +# -Djava.rmi.server.hostname=localhost \ +# -Dcom.sun.management.jmxremote.local.only=false \ +# -Dcom.sun.management.jmxremote.ssl=false \ +# -Dcom.sun.management.jmxremote.authenticate=true \ +# -Dcom.sun.management.jmxremote.password.file=/sebserver/jmxremote.password \ +# -Dcom.sun.management.jmxremote.access.file=/sebserver/config/jmx/jmxremote.access \ +# -jar "seb-server.jar" \ +# --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; \ +#fi \ No newline at end of file From 7d78e412a9a4e035a685de69ff565d3641086a66 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 22 Apr 2021 18:15:25 +0200 Subject: [PATCH 12/15] fix docker build?!?!?!? --- docker/Dockerfile | 8 ++++++- docker/start-sebserver.sh | 48 +++++++++++++++++---------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 9bd56538..b2868860 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -13,6 +13,12 @@ COPY docker/start-sebserver.sh seb-server.jar /sebserver/ WORKDIR /sebserver -CMD /bin/sh /sebserver/start-sebserver.sh +#CMD /bin/sh /sebserver/start-sebserver.sh + +CMD exec java \ + -Xms${JAVA_HEAP_MIN} \ + -Xmx${JAVA_HEAP_MAX} \ + -jar "seb-server.jar" \ + --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; EXPOSE $SERVER_PORT $JMX_PORT \ No newline at end of file diff --git a/docker/start-sebserver.sh b/docker/start-sebserver.sh index 23dec483..8dc36a19 100644 --- a/docker/start-sebserver.sh +++ b/docker/start-sebserver.sh @@ -1,28 +1,22 @@ #!/bin/sh -exec java \ - -Xms${JAVA_HEAP_MIN} \ - -Xmx${JAVA_HEAP_MAX} \ - -jar "seb-server.jar" \ - --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; - -#if [ "x${JMX_PORT}" = "x" ] ; \ -# then exec java \ -# -Xms${JAVA_HEAP_MIN} \ -# -Xmx${JAVA_HEAP_MAX} \ -# -jar "seb-server.jar" \ -# --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; \ -# else echo "admin ${SEBSERVER_SECRET}" > jmxremote.password && chown spring:spring /sebserver/jmxremote.password && chmod 400 /sebserver/jmxremote.password && exec java \ -# -Xms${JAVA_HEAP_MIN} \ -# -Xmx${JAVA_HEAP_MAX} \ -# -Dcom.sun.management.jmxremote \ -# -Dcom.sun.management.jmxremote.port=${JMX_PORT} \ -# -Dcom.sun.management.jmxremote.rmi.port=${JMX_PORT} \ -# -Djava.rmi.server.hostname=localhost \ -# -Dcom.sun.management.jmxremote.local.only=false \ -# -Dcom.sun.management.jmxremote.ssl=false \ -# -Dcom.sun.management.jmxremote.authenticate=true \ -# -Dcom.sun.management.jmxremote.password.file=/sebserver/jmxremote.password \ -# -Dcom.sun.management.jmxremote.access.file=/sebserver/config/jmx/jmxremote.access \ -# -jar "seb-server.jar" \ -# --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; \ -#fi \ No newline at end of file +if [ "x${JMX_PORT}" = "x" ] ; \ + then exec java \ + -Xms${JAVA_HEAP_MIN} \ + -Xmx${JAVA_HEAP_MAX} \ + -jar "seb-server.jar" \ + --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; \ + else echo "admin ${SEBSERVER_SECRET}" > jmxremote.password && chown spring:spring /sebserver/jmxremote.password && chmod 400 /sebserver/jmxremote.password && exec java \ + -Xms${JAVA_HEAP_MIN} \ + -Xmx${JAVA_HEAP_MAX} \ + -Dcom.sun.management.jmxremote \ + -Dcom.sun.management.jmxremote.port=${JMX_PORT} \ + -Dcom.sun.management.jmxremote.rmi.port=${JMX_PORT} \ + -Djava.rmi.server.hostname=localhost \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -Dcom.sun.management.jmxremote.authenticate=true \ + -Dcom.sun.management.jmxremote.password.file=/sebserver/jmxremote.password \ + -Dcom.sun.management.jmxremote.access.file=/sebserver/config/jmx/jmxremote.access \ + -jar "seb-server.jar" \ + --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; \ +fi \ No newline at end of file From b1e69564dcd9dac4f20852f25d0eb3f1d181febb Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 22 Apr 2021 20:06:06 +0200 Subject: [PATCH 13/15] fixed docker build --- docker/Dockerfile | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index b2868860..1f72da5f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,19 +6,36 @@ ENV JAVA_HEAP_MIN= ENV JAVA_HEAP_MAX= #just try wihtout user to check if we habe a permission problem -#RUN groupadd --system spring && useradd --system --gid spring spring && mkdir /sebserver && chown spring:spring /sebserver -#USER spring:spring +RUN groupadd --system spring && useradd --system --gid spring spring && mkdir /sebserver && chown spring:spring /sebserver +USER spring:spring COPY docker/start-sebserver.sh seb-server.jar /sebserver/ WORKDIR /sebserver +# NOTE: This seems not to work, maybe some permission problems, how knows!? #CMD /bin/sh /sebserver/start-sebserver.sh -CMD exec java \ - -Xms${JAVA_HEAP_MIN} \ - -Xmx${JAVA_HEAP_MAX} \ - -jar "seb-server.jar" \ - --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; +CMD if [ "x${JMX_PORT}" = "x" ] ; \ + then exec java \ + -Xms${JAVA_HEAP_MIN} \ + -Xmx${JAVA_HEAP_MAX} \ + -jar "seb-server.jar" \ + --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; \ + else echo "admin ${SEBSERVER_SECRET}" > jmxremote.password && chown spring:spring /sebserver/jmxremote.password && chmod 400 /sebserver/jmxremote.password && exec java \ + -Xms${JAVA_HEAP_MIN} \ + -Xmx${JAVA_HEAP_MAX} \ + -Dcom.sun.management.jmxremote \ + -Dcom.sun.management.jmxremote.port=${JMX_PORT} \ + -Dcom.sun.management.jmxremote.rmi.port=${JMX_PORT} \ + -Djava.rmi.server.hostname=localhost \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -Dcom.sun.management.jmxremote.authenticate=true \ + -Dcom.sun.management.jmxremote.password.file=/sebserver/jmxremote.password \ + -Dcom.sun.management.jmxremote.access.file=/sebserver/config/jmx/jmxremote.access \ + -jar "seb-server.jar" \ + --spring.config.location=file:/sebserver/config/spring/,classpath:/config/; \ +fi EXPOSE $SERVER_PORT $JMX_PORT \ No newline at end of file From d2928b207da75e2a0f5c7f754eba0c58e94513a1 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 27 Apr 2021 09:00:59 +0200 Subject: [PATCH 14/15] join github workflows --- .github/workflows/buildDocker.yml | 97 ----------------------- .github/workflows/buildReporting.yml | 112 +++++++++++++++++++++++---- 2 files changed, 96 insertions(+), 113 deletions(-) delete mode 100644 .github/workflows/buildDocker.yml diff --git a/.github/workflows/buildDocker.yml b/.github/workflows/buildDocker.yml deleted file mode 100644 index b1f7c966..00000000 --- a/.github/workflows/buildDocker.yml +++ /dev/null @@ -1,97 +0,0 @@ -# This workflow will build a Java project with Maven -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven - -name: build - -on: - push: - tags: - - '*' -jobs: - maven-build: - runs-on: ubuntu-latest - steps: - - - name: Get short SHA - uses: benjlevesque/short-sha@v1.2 - id: short-sha - - - name: Store short SHA as environment variable - run: echo $SHA - env: - SHA: ${{ steps.short-sha.outputs.sha }} - - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - - - name: Cache Maven packages - uses: actions/cache@v2 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: Build with Maven - run: mvn clean install -Dmaven.test.skip=true -Dsebserver-version="${{ env.SHA }}" - env: - sebserver-version: ${{ env.SHA }} - - - name: Simplify package name - run: mv target/seb-server-${{ env.SHA }}.jar target/seb-server.jar - - - uses: actions/upload-artifact@v2 - with: - name: Package - path: target/seb-server.jar - - docker-build: - needs: maven-build - # Run only on tagging - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') - runs-on: ubuntu-latest - steps: - - - name: Set env - run: echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: Test - run: | - echo $TAG_NAME - echo ${{ env.TAG_NAME }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Download a single artifact - uses: actions/download-artifact@v2 - with: - name: Package - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - context: . - file: ./docker/Dockerfile - push: true - tags: | - anhefti/seb-server:latest - anhefti/seb-server:${{ env.TAG_NAME }} \ No newline at end of file diff --git a/.github/workflows/buildReporting.yml b/.github/workflows/buildReporting.yml index 207fcc2f..ff2cbc96 100644 --- a/.github/workflows/buildReporting.yml +++ b/.github/workflows/buildReporting.yml @@ -5,23 +5,15 @@ name: build on: push: - branches: [master, development, docker-setup] + branches: + - '**' pull_request: - branches: [master, development, docker-setup] + branches: [master, development] jobs: - maven-build: + maven-build-reporting: runs-on: ubuntu-latest steps: - - - name: Get short SHA - uses: benjlevesque/short-sha@v1.2 - id: short-sha - - - name: Store short SHA as environment variable - run: echo $SHA - env: - SHA: ${{ steps.short-sha.outputs.sha }} - name: Checkout repository uses: actions/checkout@v2 @@ -40,9 +32,7 @@ jobs: restore-keys: ${{ runner.os }}-m2 - name: Build with Maven - run: mvn clean install -e -P let_reporting -Dsebserver-version="${{ env.SHA }}" - env: - sebserver-version: ${{ env.SHA }} + run: mvn clean install -e -P let_reporting - name: Reporting uses: codecov/codecov-action@v1 @@ -50,4 +40,94 @@ jobs: flags: unittests name: SEB Server Build fail_ci_if_error: false - verbose: false \ No newline at end of file + verbose: false + + maven-build-docker: + needs: maven-build-reporting + # Run only on tagging + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - + name: Get short SHA + uses: benjlevesque/short-sha@v1.2 + id: short-sha + - + name: Store short SHA as environment variable + run: echo $SHA + env: + SHA: ${{ steps.short-sha.outputs.sha }} + - + name: Checkout repository + uses: actions/checkout@v2 + - + name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + - + name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - + name: Build with Maven + run: mvn clean install -Dmaven.test.skip=true -Dsebserver-version="${{ env.SHA }}" + env: + sebserver-version: ${{ env.SHA }} + - + name: Simplify package name + run: mv target/seb-server-${{ env.SHA }}.jar target/seb-server.jar + - + uses: actions/upload-artifact@v2 + with: + name: Package + path: target/seb-server.jar + + docker-build: + needs: maven-build-docker + # Run only on tagging + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - + name: Set env + run: echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - + name: Test + run: | + echo $TAG_NAME + echo ${{ env.TAG_NAME }} + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Checkout repository + uses: actions/checkout@v2 + - + name: Download a single artifact + uses: actions/download-artifact@v2 + with: + name: Package + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + file: ./docker/Dockerfile + push: true + tags: | + anhefti/seb-server:${{ env.TAG_NAME }} \ No newline at end of file From f6ddf6bb4d30606dde7902bc24d450f346485194 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 27 Apr 2021 11:04:09 +0200 Subject: [PATCH 15/15] build workflow --- .github/workflows/buildReporting.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/buildReporting.yml b/.github/workflows/buildReporting.yml index ff2cbc96..cabc6bee 100644 --- a/.github/workflows/buildReporting.yml +++ b/.github/workflows/buildReporting.yml @@ -7,6 +7,8 @@ on: push: branches: - '**' + tags: + - '**' pull_request: branches: [master, development]