Skip to content

Commit

Permalink
Add workflow
Browse files Browse the repository at this point in the history
Add main Dockerfile
Fix annotation
  • Loading branch information
gonzo12 committed Apr 16, 2021
1 parent 3058d79 commit 54c6eec
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 1 deletion.
65 changes: 65 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
15 changes: 15 additions & 0 deletions launch.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<finalName>${project.groupId}.${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 54c6eec

Please sign in to comment.