Skip to content

[REFACTOR] [CONFIG] Dockerfile optimizations #222

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

Merged
merged 1 commit into from
Sep 7, 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
34 changes: 19 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
###############################################################################
FROM gradle:8.10.0-jdk22-alpine AS base

ENV WORKDIR=/app
WORKDIR ${WORKDIR}
RUN apk add --update --no-cache make \
# FIX CVE-2024-5535
&& apk upgrade --update --no-cache openssl libcrypto3 libssl3 \
# FIX CVE-2024-5535 CVE-2024-4741
&& apk upgrade --update --no-cache --available

RUN apk add --update --no-cache make
RUN apk upgrade --update --no-cache openssl libcrypto3 libssl3 # FIX CVE-2024-5535
RUN apk upgrade --update --no-cache --available # FIX CVE-2024-5535 CVE-2024-4741
ENV WORKDIR=/app
WORKDIR ${WORKDIR}

###############################################################################
FROM base AS lint

ENV WORKDIR=/app
WORKDIR ${WORKDIR}

RUN apk add --update --no-cache make nodejs npm
RUN apk add --update --no-cache yamllint

RUN npm install -g --ignore-scripts markdownlint-cli
RUN apk add --update --no-cache make nodejs npm\
&& apk add --update --no-cache yamllint \
&& npm install -g --ignore-scripts markdownlint-cli

# [!TIP] Use a bind-mount to "/app" to override following "copys"
# for lint and test against "current" sources in this stage
Expand Down Expand Up @@ -94,19 +95,22 @@ CMD ["make", "test"]
## WORKDIR and USER are maintained
##
FROM eclipse-temurin:22.0.2_9-jre-alpine AS production
RUN apk upgrade --update --no-cache openssl libcrypto3 libssl3 # FIX CVE-2024-5535
RUN apk upgrade --update --no-cache --available # FIX CVE-2024-5535 CVE-2024-4741

RUN apk add --update --no-cache make \
# FIX CVE-2024-5535
&& apk upgrade --update --no-cache openssl libcrypto3 libssl3 \
# FIX CVE-2024-5535 CVE-2024-4741
&& apk upgrade --update --no-cache --available

ENV LOG_LEVEL=INFO
ENV BRUTEFORCE=false
ENV WORKDIR=/app
WORKDIR ${WORKDIR}

RUN adduser -D worker
RUN mkdir -p /app
RUN chown worker:worker /app
RUN adduser -D worker \
&& mkdir -p /app \
&& chown worker:worker /app

RUN apk add --update --no-cache make
COPY ./Makefile ${WORKDIR}/
COPY --from=builder /app/algorithm-exercises-java/build/libs/algorithm-exercises-java.jar ${WORKDIR}/algorithm-exercises-java.jar

Expand Down