Skip to content
Open
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
17 changes: 16 additions & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,39 @@ LABEL maintainer="Mihai Criveti" \
description="MCP Gateway: An enterprise-ready Model Context Protocol Gateway"

ARG PYTHON_VERSION=3.12
ARG TARGETPLATFORM
ARG GRPC_PYTHON_BUILD_SYSTEM_OPENSSL='False'

# Install Python and build dependencies
# hadolint ignore=DL3041
RUN microdnf update -y && \
microdnf install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-devel gcc git && \
microdnf install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-devel gcc git openssl-devel postgresql-devel gcc-c++ && \
microdnf clean all

# Set default python3 to the specified version
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1

WORKDIR /app

# ----------------------------------------------------------------------------
# s390x architecture does not support BoringSSL when building wheel grpcio.
# Force Python whl to use OpenSSL.
# ----------------------------------------------------------------------------
RUN if [ "$TARGETPLATFORM" = "linux/s390x" ]; then \
echo "Building for s390x."; \
echo "export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL='True'" > /etc/profile.d/use-openssl.sh; \
else \
echo "export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL='False'" > /etc/profile.d/use-openssl.sh; \
fi
RUN chmod 644 /etc/profile.d/use-openssl.sh

# Copy project files into container
COPY . /app

# Create virtual environment, upgrade pip and install dependencies using uv for speed
# Including observability packages for OpenTelemetry support
RUN python3 -m venv /app/.venv && \
. /etc/profile.d/use-openssl.sh && \
/app/.venv/bin/python3 -m pip install --upgrade pip setuptools pdm uv && \
/app/.venv/bin/python3 -m uv pip install ".[redis,postgres,mysql,alembic,observability]"

Expand Down
17 changes: 16 additions & 1 deletion Containerfile.lite
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ SHELL ["/bin/bash", "-euo", "pipefail", "-c"]

ARG PYTHON_VERSION
ARG ROOTFS_PATH
ARG TARGETPLATFORM
ARG GRPC_PYTHON_BUILD_SYSTEM_OPENSSL='False'

# ----------------------------------------------------------------------------
# 1) Patch the OS
Expand All @@ -45,12 +47,24 @@ RUN set -euo pipefail \
&& dnf install -y \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-devel \
binutils \
binutils openssl-devel gcc postgresql-devel gcc-c++ \
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1 \
&& dnf clean all

WORKDIR /app

# ----------------------------------------------------------------------------
# s390x architecture does not support BoringSSL when building wheel grpcio.
# Force Python whl to use OpenSSL.
# ----------------------------------------------------------------------------
RUN if [ "$TARGETPLATFORM" = "linux/s390x" ]; then \
echo "Building for s390x."; \
echo "export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL='True'" > /etc/profile.d/use-openssl.sh; \
else \
echo "export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL='False'" > /etc/profile.d/use-openssl.sh; \
fi
RUN chmod 644 /etc/profile.d/use-openssl.sh

# ----------------------------------------------------------------------------
# Copy only the files needed for dependency installation first
# This maximizes Docker layer caching - dependencies change less often
Expand All @@ -66,6 +80,7 @@ COPY pyproject.toml /app/
# - Remove build caches and build artifacts
# ----------------------------------------------------------------------------
RUN set -euo pipefail \
&& . /etc/profile.d/use-openssl.sh \
&& python3 -m venv /app/.venv \
&& /app/.venv/bin/pip install --no-cache-dir --upgrade pip setuptools wheel pdm uv \
&& /app/.venv/bin/uv pip install ".[redis,postgres,mysql,observability]" \
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,7 @@ endif
# =============================================================================

# Auto-detect container runtime if not specified - DEFAULT TO DOCKER
CONTAINER_RUNTIME ?= $(shell command -v docker >/dev/null 2>&1 && echo docker || echo podman)
CONTAINER_RUNTIME = $(shell command -v docker >/dev/null 2>&1 && echo docker || echo podman)

# Alternative: Always default to docker unless explicitly overridden
# CONTAINER_RUNTIME ?= docker
Expand Down Expand Up @@ -2105,14 +2105,14 @@ container-build-multi:
fi; \
docker buildx use $(PROJECT_NAME)-builder; \
docker buildx build \
--platform=linux/amd64,linux/arm64 \
--platform=linux/amd64,linux/arm64,linux/s390x \
-f $(CONTAINER_FILE) \
--tag $(IMAGE_BASE):$(IMAGE_TAG) \
--push \
.; \
elif [ "$(CONTAINER_RUNTIME)" = "podman" ]; then \
echo "πŸ“¦ Building manifest with Podman..."; \
$(CONTAINER_RUNTIME) build --platform=linux/amd64,linux/arm64 \
$(CONTAINER_RUNTIME) build --platform=linux/amd64,linux/arm64,linux/s390x \
-f $(CONTAINER_FILE) \
--manifest $(IMAGE_BASE):$(IMAGE_TAG) \
.; \
Expand Down
Loading