fix: 运行时环境替换为alpine
This commit is contained in:
parent
61f91fa932
commit
6d69a18b03
|
|
@ -5,7 +5,7 @@ on:
|
|||
branches: [master]
|
||||
paths-ignore:
|
||||
- 'requirements.txt'
|
||||
- 'RuntimeDockerfile'
|
||||
- '*RuntimeDockerfile'
|
||||
- '.gitignore'
|
||||
- 'README.md'
|
||||
- '.gitea/workflows/**'
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ on:
|
|||
paths:
|
||||
- 'requirements.txt'
|
||||
- 'poetry.lock'
|
||||
- 'RuntimeDockerfile'
|
||||
- '*RuntimeDockerfile'
|
||||
|
||||
jobs:
|
||||
build-runtime:
|
||||
|
|
@ -26,7 +26,7 @@ jobs:
|
|||
repo=${var##*/}"-runtime"
|
||||
version=$(grep -oP '(?<=version = ")(.*)(?=")' "pyproject.toml")
|
||||
new_version="v${version}"
|
||||
docker build -t hub.airpig.cn/library/$repo:$new_version -f RuntimeDockerfile .
|
||||
docker build -t hub.airpig.cn/library/$repo:$new_version -f AlpineRuntimeDockerfile .
|
||||
docker push hub.airpig.cn/library/$repo:$new_version
|
||||
docker rmi hub.airpig.cn/library/$repo:$new_version
|
||||
- run: echo "This job's status is ${{ job.status }}."
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
FROM python:3.11-alpine as builder
|
||||
|
||||
RUN pip install poetry -i https://mirrors.aliyun.com/pypi/simple/
|
||||
|
||||
WORKDIR /venv
|
||||
|
||||
COPY poetry.lock pyproject.toml /venv/
|
||||
|
||||
RUN poetry config virtualenvs.options.no-pip true \
|
||||
&& poetry config virtualenvs.options.no-setuptools true \
|
||||
&& poetry config virtualenvs.in-project true \
|
||||
&& poetry install
|
||||
|
||||
|
||||
FROM python:3.11-alpine as release
|
||||
|
||||
COPY --from=builder /venv /venv
|
||||
|
||||
ENV PATH="/venv/.venv/bin:${PATH}"
|
||||
|
||||
RUN chmod a+x /venv/.venv/bin/activate \
|
||||
&& activate
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . /app
|
||||
|
||||
ENV FAST_API_ENV=prod
|
||||
|
||||
CMD ["/usr/local/bin/uvicorn", "main:fast_api_app", "--reload", "--host", "0.0.0.0", "--port", "80"]
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "fastapi-template"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
description = ""
|
||||
authors = ["chenwj113 <chenwj113@gmail.com>"]
|
||||
license = "MIT"
|
||||
|
|
|
|||
Loading…
Reference in New Issue