Skip to content

Instantly share code, notes, and snippets.

@funkybob
Created February 8, 2019 10:29
Show Gist options
  • Save funkybob/756e1901c541f8f60f06d0e5573f3e79 to your computer and use it in GitHub Desktop.
Save funkybob/756e1901c541f8f60f06d0e5573f3e79 to your computer and use it in GitHub Desktop.
FROM python/3.7
# Install system dev packages
RUN apt update -y && \
apt install -y libmariadbclient-dev gcc
# Build wheels of all our requirements
COPY requirements/requirements.txt requirements/requirements.txt
RUN mkdir wheels/ && \
pip install -U pip && \
pip wheel -w wheels/ -r requirements/requirements.txt
# Start with a clean image
FROM python/3.7
# Only install what we need for runtime
RUN apt update -y && \
apt install -y libmariadbclient18 && \
rm -rf /var/cache/apt/*
# This last line above cleans up apt's caches, to avoid image bloat
# Copy the wheels over from stage 0
COPY --from=0 wheels/ wheels/
RUN pip install -U pip && \
pip install wheels/* && \
rm -rf /root/.cache
# Again, remove the .cache to avoid image bloat. YMMV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment