change image version to bookworm

This commit is contained in:
leehk 2025-04-13 06:32:54 +08:00
parent 524f8f9c51
commit 28152eba1a

View File

@ -2,31 +2,31 @@
# BUILDER # # BUILDER #
########### ###########
# # pull official base image # pull official base image
# FROM python:3.11-slim as builder FROM python:3.11-slim-bookworm as builder
# # set working directory # set working directory
# WORKDIR /usr/src/app WORKDIR /usr/src/app
# # set environment variables # set environment variables
# ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONDONTWRITEBYTECODE=1
# ENV PYTHONUNBUFFERED=1 ENV PYTHONUNBUFFERED=1
# # install system dependencies # install system dependencies
# RUN apt-get update \ RUN apt-get update \
# && apt-get -y install build-essential netcat-traditional gcc \ && apt-get -y install build-essential netcat-traditional gcc \
# && apt-get clean && apt-get clean
# # install python dependencies # install python dependencies
# RUN pip install --upgrade pip setuptools wheel -i https://pypi.tuna.tsinghua.edu.cn/simple RUN pip install --upgrade pip setuptools wheel -i https://pypi.tuna.tsinghua.edu.cn/simple
# RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pipenv RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pipenv
# COPY ./Pipfile . COPY ./Pipfile .
# RUN pipenv install --deploy --dev RUN pipenv install --deploy --dev
# # add app # add app
# COPY . /usr/src/app COPY . /usr/src/app
# RUN pipenv run pip install black==23.12.1 flake8==7.0.0 isort==5.13.2 RUN pipenv run pip install black==23.12.1 flake8==7.0.0 isort==5.13.2
# RUN pipenv run flake8 . # RUN pipenv run flake8 .
# RUN pipenv run black --exclude=migrations . --check # RUN pipenv run black --exclude=migrations . --check
# RUN pipenv run isort . --check-only # RUN pipenv run isort . --check-only
@ -36,7 +36,7 @@
######### #########
# pull official base image # pull official base image
FROM python:3.11-slim FROM python:3.11-slim-bookworm
# create directory for the app user # create directory for the app user
RUN mkdir -p /home/app RUN mkdir -p /home/app
@ -63,10 +63,9 @@ RUN apt-get update \
&& apt-get clean && apt-get clean
# install python dependencies # install python dependencies
# COPY --from=builder /usr/src/app/Pipfile . COPY --from=builder /usr/src/app/Pipfile .
RUN pip install --upgrade pip setuptools wheel -i https://pypi.tuna.tsinghua.edu.cn/simple RUN pip install --upgrade pip setuptools wheel -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pipenv RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pipenv
COPY ./Pipfile .
RUN pipenv install --deploy --dev RUN pipenv install --deploy --dev
RUN pipenv run pip install "uvicorn[standard]==0.26.0" RUN pipenv run pip install "uvicorn[standard]==0.26.0"
@ -79,5 +78,6 @@ RUN chown -R app:app $APP_HOME
# change to the app user # change to the app user
USER app USER app
# run gunicorn # run gunicorn
CMD pipenv run gunicorn --bind 0.0.0.0:$PORT backend.main:app -k uvicorn.workers.UvicornWorker CMD pipenv run gunicorn --bind 0.0.0.0:$PORT backend.main:app -k uvicorn.workers.UvicornWorker