Skip to content

Instantly share code, notes, and snippets.

@ianchen06
Created August 9, 2017 09:09
Show Gist options
  • Save ianchen06/8e18f3d779f0b150641306e5468ee812 to your computer and use it in GitHub Desktop.
Save ianchen06/8e18f3d779f0b150641306e5468ee812 to your computer and use it in GitHub Desktop.
Optimized Dockerfile for Python app
FROM alpine:3.5
WORKDIR /app
COPY requirements.txt /app/requirements.txt
RUN apk add --no-cache nodejs python3 libstdc++ python3-dev libxml2-dev libxslt-dev linux-headers && \
npm install -g pm2 && \
apk add --no-cache \
--virtual=.build-dependencies \
g++ gfortran musl-dev git && \
ln -s locale.h /usr/include/xlocale.h && \
ln -s /usr/include/libxml2/libxml/xmlversion.h /usr/include/xmlversion.h && \
mkdir /usr/include/libxml && \
ln -s /usr/include/libxml2/libxml/xmlversion.h /usr/include/libxml/xmlversion.h && \
ln -s /usr/include/libxml2/libxml/xmlexports.h /usr/include/xmlexports.h && \
ln -s /usr/include/libxml2/libxml/xmlexports.h /usr/include/libxml/xmlexports.h && \
pip3 install -r requirements.txt && \
pm2 install pm2-logrotate && \
pm2 set pm2-logrotate:max_size 10M && \
pm2 set pm2-logrotate:compress true && \
pm2 set pm2-logrotate:retain 7 && \
pm2 set pm2-logrotate:rotateInterval '0 0 * * *' && \
pm2 restart pm2-logrotate && \
rm /usr/include/xlocale.h && \
rm -r /root/.cache && \
apk del .build-dependencies
COPY . /app
ENV DJANGO_ENV=production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment