Merge pull request #654 from LordChunk/master

Improved Docker image size
This commit is contained in:
Son Nguyen Kim 2021-10-18 09:45:34 +02:00 committed by GitHub
commit 9f36f3e2a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 7 deletions

View File

@ -5,19 +5,34 @@ COPY ./static/package*.json /code/static/
RUN cd /code/static && npm install
# Main image
FROM python:3.7
FROM python:3.7-slim
# install poetry, "pip3 install poetry==1.1.5" doesn't work
# poetry will be available at /root/.poetry/bin/poetry
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE 1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1
# Add poetry to PATH
ENV PATH="${PATH}:/root/.poetry/bin"
WORKDIR /code
# install dependencies
# Copy poetry files
COPY poetry.lock pyproject.toml ./
RUN /root/.poetry/bin/poetry config virtualenvs.create false \
&& /root/.poetry/bin/poetry install --no-root
# Install and setup poetry
RUN pip install -U pip \
&& apt-get update \
&& apt install -y curl netcat gcc python3-dev \
&& curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - \
# Remove curl and netcat from the image
&& apt-get purge -y curl netcat \
# Run poetry
&& poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi --no-root \
# Clear apt cache
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# copy npm packages
COPY --from=npm /code /code