美文网首页小资料工程师乐园
Docker:构建flask镜像的Dockerfile

Docker:构建flask镜像的Dockerfile

作者: luffynoonepiece | 来源:发表于2021-03-17 14:24 被阅读0次

    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"]
    
    蟹蟹

    相关文章

      网友评论

        本文标题:Docker:构建flask镜像的Dockerfile

        本文链接:https://www.haomeiwen.com/subject/gixecltx.html