From 54c6eec8b3da7bfcd04c1686aa140fdeb678811c Mon Sep 17 00:00:00 2001 From: "patrick.siegel" Date: Fri, 16 Apr 2021 10:35:59 +0200 Subject: [PATCH] Add workflow Add main Dockerfile Fix annotation --- .github/workflows/main.yaml | 65 +++++++++++++++++++ Dockerfile | 11 ++++ launch.sh | 15 +++++ pom.xml | 1 + .../ci/simpleprovider/IntegrationTest.kt | 2 +- 5 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/main.yaml create mode 100644 Dockerfile create mode 100644 launch.sh diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..6cbd763 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,65 @@ +name: ci + +on: push + +env: + GROUP: senacor + COMMIT_SHA: ${{ github.sha }} + REPO: simple-provider + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - 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 + verify + run: mvn -B verify + + docker: + needs: + - test + runs-on: ubuntu-latest + env: + PUSH_DOCKER_IMAGE: true + DOCKER_NAME: ghcr.io/${{ github.repository }} + DOCKER_REGISTRY: ghcr.io + steps: + - uses: actions/checkout@v2 + + - name: Package + run: mvn -B package -DskipTests -DskipITs + + - name: "Docker: Set up QEMU" + uses: docker/setup-qemu-action@v1 + + - name: "Docker: Set up Docker Buildx" + uses: docker/setup-buildx-action@v1 + + - name: "Docker: Login to Container Registry" + uses: docker/login-action@v1 + if: env.PUSH_DOCKER_IMAGE == 'true' + with: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: ${{ env.DOCKER_REGISTRY }} + + - name: "Docker: Build and push to Container Registry" + uses: docker/build-push-action@v2 + with: + context: . + tags: | + ${{ env.DOCKER_NAME }}:${{ env.COMMIT_SHA }} + push: ${{ env.PUSH_DOCKER_IMAGE }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..324ee4d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM adoptopenjdk/openjdk11:jre-11.0.10_9-alpine + + +RUN mkdir /app +COPY target/com.senacor.ci.simple-provider.jar /app/ +COPY launch.sh /app/ + +EXPOSE 8080 + +WORKDIR /app +CMD ["bash", "launch.sh"] diff --git a/launch.sh b/launch.sh new file mode 100644 index 0000000..2004cf0 --- /dev/null +++ b/launch.sh @@ -0,0 +1,15 @@ +#!/bin/bash +export +JAVA_OPTS=$(eval echo $JAVA_OPTS) +JAVA_OPTS="$JAVA_OPTS -XshowSettings:vm" +JAVA_OPTS="$JAVA_OPTS -XX:+UseContainerSupport" +JAVA_OPTS="$JAVA_OPTS -XX:InitialRAMPercentage=60.0" +JAVA_OPTS="$JAVA_OPTS -XX:MaxRAMPercentage=60.0" +JAVA_OPTS="$JAVA_OPTS -XX:+UseG1GC" +JAVA_OPTS="$JAVA_OPTS -XX:+ExitOnOutOfMemoryError" +JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8" + +echo JAVA_OPTS: $JAVA_OPTS +echo Starting: "java $JAVA_OPTS -jar /app/com.senacor.ci.simple-provider.jar" + +exec java $JAVA_OPTS -Dfile.encoding=UTF-8 -jar /app/com.senacor.ci.simple-provider.jar \ No newline at end of file diff --git a/pom.xml b/pom.xml index a5369f0..f533202 100644 --- a/pom.xml +++ b/pom.xml @@ -160,6 +160,7 @@ ${project.basedir}/src/main/kotlin ${project.basedir}/src/test/kotlin + ${project.groupId}.${project.artifactId} org.apache.maven.plugins diff --git a/src/test/kotlin/com/senacor/ci/simpleprovider/IntegrationTest.kt b/src/test/kotlin/com/senacor/ci/simpleprovider/IntegrationTest.kt index 5f60b77..c2bf930 100644 --- a/src/test/kotlin/com/senacor/ci/simpleprovider/IntegrationTest.kt +++ b/src/test/kotlin/com/senacor/ci/simpleprovider/IntegrationTest.kt @@ -10,6 +10,6 @@ import kotlin.annotation.AnnotationTarget.CLASS @Retention(RUNTIME) @Target(CLASS) @SpringBootTest(webEnvironment = RANDOM_PORT) -@ContextConfiguration(classes = [SimpleProviderApplication::class]) +@ContextConfiguration(classes = [SimpleProviderApp::class]) @ActiveProfiles("it") annotation class IntegrationTest