-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from naviqore/feature/NAV-72-docker
Feature/nav 72 docker
- Loading branch information
Showing
6 changed files
with
113 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Docker CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build image | ||
run: | | ||
COMMIT_HASH=$(git rev-parse --short HEAD) | ||
IMAGE_TAG=ghcr.io/${{ github.repository }}:${COMMIT_HASH} | ||
docker build . --file Dockerfile --tag $IMAGE_TAG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Docker publish | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
tags: | ||
- 'v[0-9]+\.[0-9]+\.[0-9]+(-.*)?' | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up environment variables | ||
run: echo "IMAGE_TAG=ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ github.event.release.tag_name }}" >> $GITHUB_ENV | ||
|
||
- name: Login to ghcr | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Build image | ||
run: | | ||
docker build . --file Dockerfile --tag $IMAGE_TAG | ||
- name: Push image to ghcr | ||
run: | | ||
docker push $IMAGE_TAG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Maven publish | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
tags: | ||
- 'v[0-9]+\.[0-9]+\.[0-9]+(-.*)?' | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '21' | ||
cache: 'maven' | ||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | ||
settings-path: ${{ github.workspace }} # location for the settings.xml file | ||
|
||
- name: Build | ||
run: mvn -B package --file pom.xml | ||
|
||
- name: Publish | ||
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM openjdk:21-jdk-slim AS build | ||
WORKDIR /app | ||
COPY .mvn/ .mvn | ||
COPY mvnw pom.xml ./ | ||
RUN ./mvnw dependency:go-offline -B | ||
COPY src ./src | ||
RUN ./mvnw clean package -DskipTests | ||
|
||
FROM openjdk:21-jdk-slim | ||
WORKDIR /app | ||
COPY --from=build /app/target/*.jar app.jar | ||
EXPOSE 8080 | ||
ENTRYPOINT ["java", "-jar", "app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters