Last active
March 2, 2021 14:10
-
-
Save maciejgryka/b1694991d3146f966b5d67a3720ee506 to your computer and use it in GitHub Desktop.
A sample Dockerfile for shipping modern Python workers
This file contains hidden or 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 ubuntu:latest | |
ENV DEBIAN_FRONTEND=noninteractive | |
ENV LC_ALL C.UTF-8 | |
ENV LANG C.UTF-8 | |
# install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
curl \ | |
build-essential \ | |
git \ | |
libbz2-dev \ | |
libjpeg-turbo8-dev \ | |
libncurses5-dev \ | |
libncursesw5-dev \ | |
libffi-dev \ | |
liblzma-dev \ | |
libreadline-dev \ | |
libsqlite3-dev \ | |
libsm6 \ | |
libssl-dev \ | |
libxext6 \ | |
libxrender-dev \ | |
llvm \ | |
make \ | |
python3 \ | |
python3-pip \ | |
python3-dev \ | |
tk-dev \ | |
wget \ | |
xz-utils \ | |
zlib1g-dev \ | |
&& apt-get clean | |
# set up the app | |
WORKDIR /app | |
RUN chmod -R 777 /app | |
# set up the user | |
RUN useradd -m appuser | |
USER appuser | |
# install pyenv | |
RUN git clone git://github.com/pyenv/pyenv.git ~/.pyenv | |
ENV HOME /home/appuser | |
ENV PYENV_ROOT $HOME/.pyenv | |
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH | |
# build optimized python | |
ENV CFLAGS -O2 | |
# make sure pyenv python can use python3-dev | |
ENV PYTHON_CONFIGURE_OPTS --enable-shared | |
RUN pyenv install 3.7.1 | |
RUN pyenv global 3.7.1 | |
RUN pyenv rehash | |
# install python deps | |
COPY Pipfile Pipfile | |
COPY Pipfile.lock Pipfile.lock | |
RUN pip install -U pip pipenv setuptools | |
RUN pipenv install --system --deploy | |
RUN pyenv rehash | |
ADD . /app | |
ENTRYPOINT ["pytest"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment