docker:一个支持django的dockerfile

宋建柏
2023-12-01

其中,包括了主要的生产环境模块,

从alpine作起,镜像不大。保存用。

FROM alpine:3.7
COPY . /target-dir
WORKDIR /target-dir

RUN sed -i 's/dl-cdn.alpinelinux.org/mirror.tuna.tsinghua.edu.cn/g' /etc/apk/repositories &&\
    apk add --update-cache --virtual=build-dependencies \
    mariadb-dev\
    g++ \
    build-base libffi-dev python3-dev \
    libffi openssl ca-certificates \
    jpeg-dev zlib-dev freetype-dev \
    lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev \
    linux-headers pcre-dev &&\
    apk add --no-cache pcre mailcap libuuid libffi py3-lxml py3-pillow python3  && \
    pip3 install --upgrade pip \
        --no-cache-dir -i http://mirrors.aliyun.com/pypi/simple/ \
        --trusted-host mirrors.aliyun.com &&\
    pip3 install -r /target-dir/requirements.txt \
    --no-cache-dir -i http://mirrors.aliyun.com/pypi/simple/ \
    --trusted-host mirrors.aliyun.com &&\
    apk del --purge build-dependencies && \
    rm -rf /var/cache/apk/* && \
    rm -rf /var/lib/apk/* && \
    rm -rf /etc/apk/cache/* && \
    rm -rf ~/.cache/ && \
    rm -rf /root/.cache /tmp/*

CMD ["/bin/sh"]

requirements.txt

Django==2.1.3
djangorestframework==3.9.0
channels==2.1.4
gunicorn==19.9.0
PyMySQL==0.9.2
python-jenkins==1.4.0
uWSGI==2.0.17
requests==2.20.1

其间,安装channels时,那个Twisted的安装,可能要小心。

 类似资料: