Created
May 24, 2021 01:02
-
-
Save eifuentes/c7a5916b99cdcd56f8a1c73d476f7dec to your computer and use it in GitHub Desktop.
Base Python Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.8 | |
# Set environment variables | |
ENV PYTHONDONTWRITEBYTECODE 1 | |
ENV PYTHONUNBUFFERED 1 | |
# System prerequisites | |
RUN apt-get update \ | |
&& apt-get -y install build-essential libpq-dev \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Install Poetry | |
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \ | |
cd /usr/local/bin && \ | |
ln -s /opt/poetry/bin/poetry && \ | |
poetry config virtualenvs.create false | |
# Copy poetry.lock* in case it doesn't exist in the repo | |
COPY pyproject.toml poetry.lock* /opt/app/ | |
# Working directory | |
WORKDIR /opt/app/ | |
# Allow installing dev dependencies to run tests | |
ARG INSTALL_DEV=false | |
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi" | |
ENV PYTHONPATH=/opt/app | |
COPY ./ /opt/app | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment