From 309d912985a2efba31a6287cf7f98065c48dab54 Mon Sep 17 00:00:00 2001 From: Kenson Man Date: Fri, 27 May 2022 12:47:19 +0100 Subject: [PATCH] Change the Docker base image from python:3-slim to python:3-alpine. The final image will be ~79.6MB instead of 163MB. It has 48% smaller. --- .dockerignore | 1 + Dockerfile | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..6b8710a7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.git diff --git a/Dockerfile b/Dockerfile index 38dd2e08..cbf7f71e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,17 @@ -FROM python:3.7-slim +FROM python:3-alpine + +LABEL maintainer='' +LABEL version='0.0.0-dev.0-build.0' + ADD . /code WORKDIR /code RUN \ - groupadd -r webssh && \ - useradd -r -s /bin/false -g webssh webssh && \ - chown -R webssh:webssh /code && \ - pip install -r requirements.txt + apk add --no-cache libc-dev libffi-dev gcc && \ + pip install -r requirements.txt --no-cache-dir && \ + apk del gcc libc-dev libffi-dev && \ + addgroup webssh && \ + adduser -Ss /bin/false -g webssh webssh && \ + chown -R webssh:webssh /code EXPOSE 8888/tcp USER webssh