Kopieren / Synchronisieren von Dateien aus einem PIPPython

Python-Programme
Anonymous
 Kopieren / Synchronisieren von Dateien aus einem PIP

Post by Anonymous »

Ich bin in diesem Artikel (https://www.docker.com/blog/how-to-dock ... jango-app/) eine Django-App
Ich habe es Dramatiker == 1.50.0 In meinen Anforderungen >

Code: Select all

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
< /code>
Aber woher weiß ich, dass dies allein ausreicht, um den Browser (s) in die Stufe 2 (Produktion) zu kopieren? < /p>
Code unter "Verbesserungen an der Dockerfile" < /p>
# Copy the Python dependencies from the builder stage
COPY --from=builder /usr/local/lib/python3.13/site-packages/ /usr/local/lib/python3.13/site-packages/
COPY --from=builder /usr/local/bin/ /usr/local/bin/
Wo werden die Browser beim Ausführen von Dramatikern installiert ?

Code: Select all

# Stage 1: Base build stage
FROM python:3.13 AS builder

# Create the app directory
RUN mkdir /app

# Set the working directory
WORKDIR /app

# Set environment variables to optimize Python
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# Upgrade pip and install dependencies
RUN pip install --upgrade pip

# Copy the requirements file first (better caching)
COPY requirements.txt /app/

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
RUN playwright install

# Stage 2: Production stage
FROM python:3.13

RUN useradd -m -r appuser && \
mkdir /app && \
chown -R appuser /app

# Copy the Python dependencies from the builder stage
COPY --from=builder /usr/local/lib/python3.13/site-packages/ /usr/local/lib/python3.13/site-packages/
COPY --from=builder /usr/local/bin/ /usr/local/bin/

# Set the working directory
WORKDIR /app

# Copy application code
COPY --chown=appuser:appuser . .

# Set environment variables to optimize Python
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# Switch to non-root user
USER appuser

# Expose the application port
EXPOSE 8000

# Start the application using Gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "3", "nerul.wsgi:application"]
# CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
Ich habe Dramatiker Installation gleich nach dem Ausführen von PIP install .

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post