首页 > 编程语言 > 详细

Dockerfile-For-Python

时间:2021-07-08 10:14:44      阅读:16      评论:0      收藏:0      [点我收藏+]

main

# -*- coding:utf-8 -*-
# @Author: 15b883
from fastapi import FastAPI
import uvicorn
 
app = FastAPI()

Dockerfile

FROM python:3.8.7-alpine3.12

ENV PORT 8080
ENV TIMEZONE=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TIMEZONE /etc/localtime && echo $TIMEZONE > /etc/timezone
EXPOSE 8080


WORKDIR /opt
ADD . /opt
RUN pip install -r requirements.txt

ENTRYPOINT ["sh", "/opt/entrypoint.sh"]

entrypoint

#!/bin/bash

set -e

# ================================================================================
exec python main.py

requirements

fastapi
uvicorn

build

docker build . -t fastapiweb:v1

run

docker run --name web1 -d -p 80:8080 fastapiweb:v1

check

http://localhost/

Dockerfile-For-Python

原文:https://www.cnblogs.com/syavingcs/p/14984222.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!