Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: added build env for multi-stage Dockerfile to import a CA ce… #9

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions Dockerfile.multi-stage
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
# Copyright 2024 Deutsche Telekom IT GmbH
#
# SPDX-License-Identifier: Apache-2.0
FROM azul/zulu-openjdk-alpine:21 AS builder

WORKDIR /workspace/app
ARG BUILD_ENV=standard

# builder image for building the actual runnable jar
FROM azul/zulu-openjdk-alpine:21 AS builder
WORKDIR /workspace/app
COPY . .
RUN dos2unix ./gradlew
RUN ./gradlew build -x test

FROM azul/zulu-openjdk-alpine:21-jre

# standard image build
FROM azul/zulu-openjdk-alpine:21-jre AS standard
USER root
RUN apk add --no-cache --update gcompat --repository=https://dl-cdn.alpinelinux.org/alpine/v3.18/main/ > /dev/null

USER 1001:1001

WORKDIR /workspace/app

COPY --from=builder /workspace/app/build/libs/starlight.jar app.jar

EXPOSE 8080
# image build that includes a local cacert.pem and import it into the default truststore
FROM standard as with_cacert
USER root
RUN apk add --no-cache ca-certificates
COPY cacert.pem /usr/local/share/ca-certificates/cacert.pem
RUN update-ca-certificates
USER 1001:1001

CMD ["java", "-jar", "app.jar"]
# main
FROM ${BUILD_ENV}
EXPOSE 8080
CMD ["java", "-jar", "app.jar"]
Loading