Last active
June 30, 2020 17:36
-
-
Save ConfidenceYobo/bc0a8e052f10b9c3d0e22ddd8634e1e6 to your computer and use it in GitHub Desktop.
Small docker container images based on Linux Alpine for Python | Django | Mysql
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 | |
# set work directory | |
WORKDIR /usr/src/app | |
# set environment variables | |
ENV PYTHONDONTWRITEBYTECODE 1 | |
ENV PYTHONUNBUFFERED 1 | |
################## BEGIN INSTALLATION ###################### | |
# Add the packages | |
RUN apk update \ | |
&& apk add --no-cache --virtual .build-deps gcc linux-headers musl-dev mariadb-dev zlib \ | |
python3-dev openssl-dev | |
# install dependencies | |
RUN pip install --upgrade pip | |
COPY ./requirements.txt . | |
RUN pip install -r requirements.txt | |
# Clean up disk space | |
RUN apk del gcc python3-dev musl-dev jpeg-dev zlib-dev linux-headers | |
RUN rm -Rf ~/.cache | |
##################### INSTALLATION END ##################### | |
# copy project | |
COPY . . | |
### 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