Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Merge patch-atomic-preparing-the-docker-image-01-07-2025-1736292330 into dev #3680

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/pydiscordsh/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
__pycache__/
*.pyc
*.pyo
*.pyd
*.log
.git
node_modules
tests
40 changes: 25 additions & 15 deletions apps/pydiscordsh/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Base image with Python and Poetry pre-installed
FROM python:3.12-slim
# Stage 1: Builder
FROM python:3.12-slim as builder

# Set environment variables for Poetry and Python
ENV PYTHONUNBUFFERED=1 \
Expand All @@ -11,30 +11,40 @@ ENV PYTHONUNBUFFERED=1 \

# Install system dependencies and Poetry
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
git \
curl git \
&& curl -sSL https://install.python-poetry.org | python3 - \
&& ln -s /opt/poetry/bin/poetry /usr/local/bin/poetry \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy only the relevant files for dependency installation first
# Copy and install dependencies
COPY pyproject.toml poetry.lock ./

# Install dependencies with Poetry (including project dependencies)
RUN poetry install --no-root --only main

# Copy the rest of the app code
# Stage 2: Final lightweight image
FROM python:3.12-slim

# Set the same environment variables for consistency
ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
POETRY_VERSION=1.8.2 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1

# Copy Poetry from the builder stage
COPY --from=builder /opt/poetry /opt/poetry
COPY --from=builder /usr/local/bin/poetry /usr/local/bin/poetry

WORKDIR /app
# Copy the installed dependencies and the rest of the app
COPY --from=builder /app /app
COPY . .

# Install the project itself (if it's structured as a package)
# Install the app without dev dependencies
RUN poetry install --no-dev

# Expose Port
# Expose the port and run the server
EXPOSE 3000

# Set the default command to run the application
CMD ["poetry", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "3000", "--ws-ping-interval", "25", "--ws-ping-timeout", "5"]
Loading