Switching to multistage builds! Shrinks the container by an entire gigabyte

This commit is contained in:
ein 2021-01-06 11:47:06 -08:00
parent 36ab44d8e9
commit d3e79d2097
2 changed files with 9 additions and 4 deletions

View File

@ -1,8 +1,10 @@
FROM python:3.8 as build
RUN apt-get update && apt-get install -y gcc python-pip
# RUN apk add --no-cache build-base g++ gcc libxml2-dev libxslt-dev libffi-dev openssl-dev make
ADD app/requirements.txt /requirements.txt
RUN pip install -r requirements.txt
FROM python:3.8-slim
COPY --from=0 /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
ADD app /app
CMD python /app/bot.py

View File

@ -1,7 +1,10 @@
FROM python as builder
RUN apt-get update && apt-get install -y gcc make automake
# RUN apk update && apk add --no-cache make python3-dev automake gcc libxml2-dev libxslt-dev g++
FROM python:3.8 as build
RUN apt-get update && apt-get install -y gcc python-pip
ADD app/requirements.txt /requirements.txt
RUN pip install -r requirements.txt
FROM python:3.8-slim
COPY --from=0 /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
ADD app /app
WORKDIR /app