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

OPSEXP-1257 make sure alpine base is updated #83

Merged
merged 3 commits into from
Feb 21, 2022
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
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ RUN yum update -y && \
JAVA_BIN_PATH=$(rpm -ql java-${JAVA_PKG_VERSION}-openjdk-${PKG_DEVEL:-headless} | grep '\/bin\/java$') && \
test -L $JAVA_HOME || ln -sf ${JAVA_BIN_PATH%*/bin/java} $JAVA_HOME

FROM alpine:3.15@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300 AS alpine3.15
FROM alpine:3.15.0 AS alpine3.15

ARG JDIST
ARG JAVA_MAJOR
Expand All @@ -70,7 +70,10 @@ ENV JAVA_HOME=/usr/lib/jvm/java-${JAVA_MAJOR}-openjdk
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

RUN apk add openjdk${JAVA_MAJOR}-${JDIST}-headless
RUN apk update && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use the short form apk -U upgrade and add --no-cache to all commands or add rm -vrf /var/cache/apk/* after to save a few MB of package index - see: https://newbedev.com/alpine-dockerfile-advantages-of-no-cache-vs-rm-var-cache-apk

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing that will download index two times (one for the upgrade and again for the apk add), it's better to delete index at the end

apk upgrade && \
apk add openjdk${JAVA_MAJOR}-${JDIST}-headless && \
rm -rf /var/cache/apk/*

FROM ${DISTRIB_NAME}${DISTRIB_MAJOR} AS JAVA_BASE_IMAGE
ARG DISTRIB_NAME
Expand Down