ساخت یک Dockerfile مناسب برای پروژه های پایتونی:
خیلی خوب توضیح داده.
https://luis-sena.medium.com/creating-the-perfect-python-dockerfile-51bdec41f1c8
#python #Dockerfile
@Syntax_fa
خیلی خوب توضیح داده.
https://luis-sena.medium.com/creating-the-perfect-python-dockerfile-51bdec41f1c8
#python #Dockerfile
@Syntax_fa
Medium
Creating the Perfect Python Dockerfile
Increase your python code performance and security without changing the project source code.
💋7🔥1👌1🎃1
Syntax | سینتکس
ساخت یک Dockerfile مناسب برای پروژه های پایتونی: خیلی خوب توضیح داده. https://luis-sena.medium.com/creating-the-perfect-python-dockerfile-51bdec41f1c8 #python #Dockerfile @Syntax_fa
و اما Docekrfile که من از توضیحات ایشون رسیدم بهش:
نظر بدید
#python #dockerfile
@Syntax_fa
FROM python:3.11-slim as builder
# avoid stuck build due to user prompt
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends ...
# create and activate virtual environment
RUN python -m venv /home/myuser/venv
ENV PATH="/home/myuser/venv/bin:$PATH"
# install requirements
COPY ./requirements .
RUN pip3 install --upgrade --no-cache-dir pip
RUN pip3 install --no-cache-dir wheel
RUN pip3 install --no-cache-dir -r production.txt
FROM python:3.11-slim
RUN useradd --create-home myuser
COPY --from=builder /home/myuser/venv /home/myuser/venv
USER myuser
RUN mkdir /home/myuser/code
WORKDIR /home/myuser/code
COPY . /home/myuser/code
EXPOSE $DJANGO_PORT
# make sure all messages always reach console
ENV PYTHONUNBUFFERED=1
# activate virtual environment
ENV VIRTUAL_ENV=/home/myuser/venv
ENV PATH="/home/myuser/venv/bin:$PATH"
# /dev/shm is mapped to shared memory and should be used for gunicorn heartbeat
# this will improve performance and avoid random freezes
# CMD ["gunicorn","-b", "0.0.0.0:8000", "-w", "4", "-k", "gevent", "--worker-tmp-dir", "/dev/shm", "--chdir", "config config.wsgi:application"]
نظر بدید
#python #dockerfile
@Syntax_fa
🔥6👍1🤣1🤨1