|
|
|
FROM python:3.11-slim as builder |
|
|
|
|
|
ENV HOME=/home/user \ |
|
PATH=/home/user/.local/bin:$PATH |
|
|
|
|
|
RUN useradd -m -d $HOME -s /bin/bash user |
|
|
|
|
|
WORKDIR $HOME/app |
|
|
|
|
|
RUN apt-get update && apt-get install -y \ |
|
build-essential \ |
|
libmariadb-dev \ |
|
git \ |
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
RUN pip install --upgrade pip |
|
|
|
|
|
COPY --chown=user:user requirements.txt ./ |
|
|
|
|
|
RUN pip install --no-cache-dir -r requirements.txt |
|
|
|
|
|
FROM python:3.11-slim |
|
|
|
|
|
ENV HOME=/home/user \ |
|
PATH=/home/user/.local/bin:$PATH |
|
|
|
|
|
RUN useradd -m -d $HOME -s /bin/bash user |
|
|
|
|
|
WORKDIR $HOME/app |
|
|
|
|
|
RUN apt-get update && apt-get install -y \ |
|
libmariadb-dev \ |
|
wget \ |
|
git \ |
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages |
|
COPY --from=builder /usr/local/bin /usr/local/bin |
|
|
|
|
|
COPY --chown=user:user . . |
|
|
|
|
|
EXPOSE 8000 |
|
|
|
|
|
RUN mkdir -p $HOME/app/uploaded_files && \ |
|
chown -R user:user $HOME/app/uploaded_files && \ |
|
chmod -R 777 $HOME/app/uploaded_files |
|
|
|
|
|
USER user |
|
|
|
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] |
|
|