Skip to content

Commit

Permalink
Docker Integration of the PSPWizard
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinTaube committed Jan 11, 2024
1 parent 1db7ae2 commit 150e3d0
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
49 changes: 49 additions & 0 deletions .github/workflows/dockerBuildAndPush.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Docker build and publish to GHCR

on:
push:
branches:
- docker_integration
release:
types: [published] # will use tag name regardless of naming

jobs:
build_and_publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout current Repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}

- name: Log in to the Container registry
run: docker login --username Cambio-Project --password ${{secrets.PUBLISH_PACKAGES}} ghcr.io

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
EXECUTION_ENV=ci
GITHUB_PACKAGE_READ_TOKEN=${{ secrets.PUBLISH_PACKAGES }}
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Build stage
FROM maven:3.9.6-amazoncorretto-21-debian AS build

# create a new working directory
WORKDIR /app

# copy project files and folders to the current working directory (i.e. 'app' folder)
COPY . .

# installs the maven project from the base PSPWizard
RUN mvn install

# installs the restAPI Module from the PSPWizard
RUN mvn install -f ./restAPI/pom.xml

# Package stage
FROM eclipse-temurin:21-jdk-alpine AS package

# gets the *.jar file from the api application from the build stage
COPY --from=build /app/restAPI/target/*.jar app.jar

# exposes the port of the spring app e.g. 8080
EXPOSE 8080

# starts the application
ENTRYPOINT ["java","-jar","app.jar"]
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ ___
## Usage of the Rest-API

### Additional Requirements:
- min. Java 17
- min. Java 21

### Usage:

#### Manual Install
1. Install the main PSPWizard Maven Project
2. Install the restAPI Module Maven Project (needs to be second because of dependencies)
3. Start the application with the .jar in ``/restAPI/target/restAPI-0.0.1-SNAPSHOT.jar``

#### Install via Docker

You can either use the provided `Dockerfile` to create build the image locally or use the included ``docker-compose.yml`` which uses the lastest image from the GitHub Container Registry

0 comments on commit 150e3d0

Please sign in to comment.