Loading

Dockerfile-For-Python

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/

posted @ 2021-07-07 23:49  宋某人  阅读(108)  评论(0编辑  收藏  举报