Created
June 12, 2016 16:16
-
-
Save maatthc/64d4a43f8bb3e12aae0140f7bd1958f0 to your computer and use it in GitHub Desktop.
Dockerfile to build Python / Django / Mysql small container images . Based on Linux Alpine.
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
############################################################ | |
# Dockerfile to build Python / Django / Mysql small container images | |
# Based on Linux Alpine | |
############################################################ | |
# Set the base image | |
FROM alpine | |
# File Author / Maintainer | |
MAINTAINER Alexandre Andrade [email protected] | |
# Update the repository sources list | |
RUN apk update | |
################## BEGIN INSTALLATION ###################### | |
# Add the packages | |
RUN apk add --no-cache python | |
RUN apk add --no-cache --virtual .build-deps py-pip python-dev musl-dev gcc mariadb-dev | |
RUN pip install mysql | |
# You can skip this step if your Django project has the correct version specified on requirements.txt | |
#RUN pip install django | |
# Copy the code | |
RUN mkdir -p /usr/src/ecommerce | |
COPY . /usr/src/ecommerce | |
# Work dir | |
WORKDIR /usr/src/ecommerce | |
# Install dependencies | |
RUN pip install -r requirements.txt | |
# Clean up disk space | |
RUN apk del .build-deps python-dev musl-dev gcc mariadb-dev zlib-dev openssl-dev | |
RUN rm -Rf ~/.cache | |
##################### INSTALLATION END ##################### | |
# Expose the default port | |
EXPOSE 8000 | |
# Set default container command | |
ENTRYPOINT python ecommerce/manage.py runserver 0.0.0.0:8000 | |
### Reduce the image size | |
## Run : docker export <CONTAINER ID> | docker import - some-image-name:latest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment