From b34479f928ac8a3c9fc1297e5e27f046fa1ed339 Mon Sep 17 00:00:00 2001 From: James Gilliland Date: Mon, 7 May 2018 13:54:23 -0500 Subject: [PATCH] Use one RUN to optimize layering Since each RUN creates its own layer that needs to be downloaded and layered to create the image, combining the cleanup steps into the same RUN shrinks the image size quite a bit. Before: 84MB After: 75.2MB --- swagger-ui/Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/swagger-ui/Dockerfile b/swagger-ui/Dockerfile index 6ca6166..3bf230d 100644 --- a/swagger-ui/Dockerfile +++ b/swagger-ui/Dockerfile @@ -15,11 +15,12 @@ ENV PORT 80 WORKDIR /app -RUN apk add --no-cache openssl -RUN wget -qO- https://github.com/swagger-api/swagger-ui/archive/$VERSION.tar.gz | tar xvz -RUN cp -r $FOLDER/dist/* . && rm -rf $FOLDER -RUN npm install -g http-server -RUN apk del openssl +RUN apk add --no-cache openssl \ + && wget -qO- https://github.com/swagger-api/swagger-ui/archive/$VERSION.tar.gz | tar xvz \ + && cp -r $FOLDER/dist/* . \ + && rm -rf $FOLDER \ + && npm install -g http-server \ + && apk del openssl ADD run.sh run.sh