Skip to content

Commit

Permalink
Merge pull request #3 from telekom/chore/multi-stage-build-adjustments
Browse files Browse the repository at this point in the history
Added maven -DskipTests flag to account for open Testcontainers issues.
  • Loading branch information
chrisingenhaag authored Aug 29, 2024
2 parents 630f7ec + 54b1fb9 commit 23693b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Dockerfile.multi-stage
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
#
# SPDX-License-Identifier: Apache-2.0

# This multi-stage Dockerfile is used to build a Java application with Maven and run it with a JRE.
# It skips the tests during the build process and uses a slim JRE image for the final container.
# USE WITH CAUTION: This Dockerfile is intended for demonstration purposes only and should be adjusted to your needs.
# The final container is started with a non-root user.


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
RUN mvn -f /usr/app/pom.xml clean package -DskipTests


FROM eclipse-temurin:17-jre-alpine
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ 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:
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.
**It will, however, skip the Maven unit test stage due to some issues with Testcontainers.** To build the image, run:

```bash
docker build --platform linux/amd64 -t jumper -f Dockerfile.multi-stage .
Expand Down

0 comments on commit 23693b7

Please sign in to comment.