Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FROM python:2.7-alpine
MAINTAINER Nick Janetakis <nick.janetakis@gmail.com>
ENV INSTALL_PATH /bsawf
RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH
COPY requirements.txt requirements.txt
RUN apk add --no-cache --virtual .build-deps \
build-base postgresql-dev libffi-dev \
&& pip install -r requirements.txt \
&& find /usr/local \
\( -type d -a -name test -o -name tests \) \
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
-exec rm -rf '{}' + \
&& runDeps="$( \
scanelf --needed --nobanner --recursive /usr/local \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --virtual .rundeps $runDeps \
&& apk del .build-deps
COPY . .
CMD gunicorn -b 0.0.0.0:8000 --access-logfile - "bsawf.app:create()"
@nickjj

This comment has been minimized.

Copy link

@nickjj nickjj commented Apr 15, 2016

Thanks. Your gist has been incorporated (and credited) into http://nickjanetakis.com/blog/alpine-based-docker-images-make-a-difference-in-real-world-apps.

@JoeAlamo

This comment has been minimized.

Copy link

@JoeAlamo JoeAlamo commented Jun 14, 2018

With this example, what if a binary exists in /usr/bin and not /usr/local? Won't it's dependencies get wiped out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.