diff --git a/Dockerfile b/Dockerfile index 6c99164..1f14f9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,21 +2,21 @@ # # SPDX-License-Identifier: Apache-2.0 -FROM azul/zulu-openjdk-alpine:17 +FROM eclipse-temurin:17-jre-alpine -RUN apk add --update \ - curl \ - && rm -rf /var/cache/apk/* +RUN apk add --update \ + curl \ + && rm -rf /var/cache/apk/* -RUN addgroup --gid 1000 jumper && adduser --uid 1000 -G jumper -D jumper --no-create-home +RUN addgroup -g 1000 -S app +RUN adduser -u 1000 -D -H -S -G app app USER 1000:1000 EXPOSE 8080 8082 -COPY target/*.jar /usr/share/jumper.jar +COPY target/*.jar /usr/share/app.jar WORKDIR /usr/share/ -CMD java $JVM_OPTS -jar /usr/share/jumper.jar - +CMD java $JVM_OPTS -jar /usr/share/app.jar diff --git a/Dockerfile.multi-stage b/Dockerfile.multi-stage new file mode 100644 index 0000000..df26b11 --- /dev/null +++ b/Dockerfile.multi-stage @@ -0,0 +1,30 @@ +# SPDX-FileCopyrightText: 2023 Deutsche Telekom AG +# +# SPDX-License-Identifier: Apache-2.0 + +FROM maven:3.9-eclipse-temurin-17-alpine AS build +RUN mkdir -p /usr/app +WORKDIR /usr/app +ADD . /usr/app + +RUN mvn -f /usr/app/pom.xml clean package + + +FROM eclipse-temurin:17-jre-alpine + +RUN apk add --update \ + curl \ + && rm -rf /var/cache/apk/* + +RUN addgroup -g 1000 -S app +RUN adduser -u 1000 -D -H -S -G app app + +USER 1000:1000 + +EXPOSE 8080 8082 + +COPY --from=build /usr/app/target/*.jar /usr/share/app.jar + +WORKDIR /usr/share/ + +CMD java $JVM_OPTS -jar /usr/share/app.jar \ No newline at end of file diff --git a/README.md b/README.md index 56eae52..b1d7e8c 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,36 @@ By participating in this project, you agree to abide by its [Code of Conduct](./ This project follows the [REUSE standard for software licensing](https://reuse.software/). Each file contains copyright and license information, and license texts can be found in the [./LICENSES](./LICENSES) folder. For more information visit https://reuse.software/. +## Building + +### Packaging the application + +This project is built with [Maven](https://maven.apache.org/). It is validated to be compatible with version 3.9.x. To build the project, run: + +```bash + ./mvnw clean package +``` + +This will build the project and run all tests. The resulting artifacts will be placed in the `target` directory. + +### Building the Docker image + +The project contains a Dockerfile that can be used to build a Docker image. To build the image, run: + +```bash + docker build --platform linux/amd64 -t jumper . +``` + +This will build the image and tag it as `jumper:latest`. + +### Multi-stage Docker build + +Alternatively, you can use the multi-stage Docker build to build the image. This will build the application in a Maven container and then copy the resulting artifacts into a smaller container. To build the image, run: + +```bash + docker build --platform linux/amd64 -t jumper -f Dockerfile.multi-stage . +``` + ## Scenarios Scenarios from various aspects of Jumper functionality perspective. Scenarios from different perspective can be overlapping! diff --git a/mvnw b/mvnw old mode 100644 new mode 100755