Skip to content

Commit 8e9e388

Browse files
authored
optimise docker images size 348MB -> 223MB (#28)
1 parent 4210ae2 commit 8e9e388

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

Dockerfile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ WORKDIR /opt
1111

1212
#COPY OpenICF-java-framework/openicf-zip/target/*.zip ./
1313

14-
RUN apt-get update
15-
RUN apt-get install -y --no-install-recommends curl unzip
16-
RUN if [ ! -z "$VERSION" ] ; then rm -rf ./*.zip ; curl -L https://github.com/OpenIdentityPlatform/OpenICF/releases/download/$VERSION/openicf-$VERSION.zip --output openicf-$VERSION.zip ; fi
17-
RUN unzip openicf-*.zip && rm -rf *.zip
18-
RUN apt-get remove -y --purge unzip
19-
RUN rm -rf /var/lib/apt/lists/*
20-
RUN groupadd $USER
21-
RUN useradd -m -r -u 1001 -g $USER $USER
22-
RUN install -d -o $USER /opt/openicf
23-
RUN chown -R $USER:$USER /opt/openicf
24-
RUN chmod -R g=u /opt/openicf
25-
RUN chmod +x /opt/openicf/bin/*.sh
14+
RUN apt-get update \
15+
&& apt-get install -y --no-install-recommends curl unzip \
16+
&& bash -c 'if [ ! -z "$VERSION" ] ; then rm -rf ./*.zip ; curl -L https://github.com/OpenIdentityPlatform/OpenICF/releases/download/$VERSION/openicf-$VERSION.zip --output openicf-$VERSION.zip ; fi' \
17+
&& unzip openicf-*.zip && rm -rf *.zip \
18+
&& apt-get remove -y --purge unzip \
19+
&& rm -rf /var/lib/apt/lists/* \
20+
&& groupadd $USER \
21+
&& useradd -m -r -u 1001 -g $USER $USER \
22+
&& install -d -o $USER /opt/openicf \
23+
&& chown -R $USER:$USER /opt/openicf \
24+
&& chmod -R g=u /opt/openicf \
25+
&& chmod +x /opt/openicf/bin/*.sh
2626

2727
EXPOSE 8759
2828

Dockerfile-alpine

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ WORKDIR /opt
1111

1212
#COPY OpenICF-java-framework/openicf-zip/target/*.zip ./
1313

14-
RUN apk add --update --no-cache --virtual builddeps curl unzip
15-
RUN apk upgrade --update --no-cache
16-
RUN apk add bash
17-
RUN if [ ! -z "$VERSION" ] ; then rm -rf ./*.zip ; curl -L https://github.com/OpenIdentityPlatform/OpenICF/releases/download/$VERSION/openicf-$VERSION.zip --output openicf-$VERSION.zip ; fi
18-
RUN unzip openicf-*.zip && rm -rf *.zip
19-
RUN apk del unzip
20-
RUN addgroup -S $USER
21-
RUN adduser -S -u 1001 -G $USER $USER
22-
RUN install -d -o $USER /opt/openicf
23-
RUN chown -R $USER:$USER /opt/openicf
24-
RUN chmod -R g=u /opt/openicf
25-
RUN chmod +x /opt/openicf/bin/*.sh
14+
RUN apk add --update --no-cache --virtual builddeps curl unzip \
15+
&& apk upgrade --update --no-cache \
16+
&& apk add bash \
17+
&& bash -c 'if [ ! -z "$VERSION" ] ; then rm -rf ./*.zip ; curl -L https://github.com/OpenIdentityPlatform/OpenICF/releases/download/$VERSION/openicf-$VERSION.zip --output openicf-$VERSION.zip ; fi' \
18+
&& unzip openicf-*.zip && rm -rf *.zip \
19+
&& apk del unzip \
20+
&& addgroup -S $USER \
21+
&& adduser -S -u 1001 -G $USER $USER \
22+
&& install -d -o $USER /opt/openicf \
23+
&& chown -R $USER:$USER /opt/openicf \
24+
&& chmod -R g=u /opt/openicf \
25+
&& chmod +x /opt/openicf/bin/*.sh
2626

2727
EXPOSE 8759
2828

0 commit comments

Comments
 (0)