diff --git a/Dockerfile b/Dockerfile index 007e637f..e7cfd0b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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