Docker:构建flask镜像的Dockerfile
2021-03-17 本文已影响0人
luffynoonepiece
Docker小白自己写的Dockerfile模板,有需要的自提~
FROM python:3.8-buster
LABEL maintainor="Mikasa"
# 配置一下国内的agt源
RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN apt-get clean
RUN apt-get update && apt-get install -y vim \
nginx
ENV FLASK_APP manage.py
ENV FLASK_CONFIG DevelopmentConfig
ENV FLASK_PORT 5000
# 添加新用户
RUN useradd -g root --create-home --no-log-init --shell /bin/bash mikasa
RUN adduser mikasa sudo
RUN echo 'mikasa:password'| chpasswd
USER mikasa
WORKDIR /home/mikasa
COPY requirements requirements
COPY app app
COPY static static
COPY templates templates
RUN python -m venv venv
# 也可以选择加上国内的pip镜像
RUN venv/bin/python -m pip install --upgrade pip
RUN venv/bin/python -m pip install -r requirements/requirements.txt
COPY manage.py start.sh ./
# run-time configuration
EXPOSE 5000
ENTRYPOINT ["./start.sh"]
蟹蟹