Skip to content

Commit 1852436

Browse files
authored
Merge pull request #46 from eifrach/change_to_pip
Change to Centos with non-Root user
2 parents 681db12 + c737228 commit 1852436

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

Containerfile

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
1-
FROM ghcr.io/astral-sh/uv:alpine
1+
FROM quay.io/centos/centos:stream9
22

33
# Set default MCP transport if not provided
44
ENV MCP_TRANSPORT=stdio
55

6-
# Install Python 3.11 and required build dependencies
7-
RUN apk add --no-cache python3 python3-dev py3-pip build-base
6+
# Install Python 3.11, pip, and build dependencies
7+
RUN dnf -y install --setopt=install_weak_deps=False --setopt=tsflags=nodocs \
8+
python3.12 python3.12-devel python3.12-pip gcc make git && \
9+
dnf clean all
10+
11+
# Install uv (universal virtualenv/dependency manager)
12+
RUN pip3.12 install --no-cache-dir --upgrade pip && \
13+
pip3.12 install --no-cache-dir uv
14+
15+
# Copy project files to working directory
16+
WORKDIR /app
17+
18+
# Set ownership to the user we created. Group 0 (root) is important for OpenShift compatibility.
19+
RUN chown 1001:0 /app
20+
21+
# Switch to the non-root user *before* copying files and installing dependencies
22+
USER 1001
823

9-
# Copy project files to user's home directory (no permission issues)
1024
COPY pyproject.toml ./
1125
COPY .python-version ./
1226
COPY uv.lock ./
1327
COPY README.md ./
1428
# Copy application files (needed for editable install)
1529
COPY ./src/ ./
1630

17-
# Install dependencies - no permission changes needed
31+
# Install dependencies
1832
RUN uv sync --no-cache --locked
1933

2034
# Environment variables (set these when running the container)
@@ -27,4 +41,4 @@ RUN uv sync --no-cache --locked
2741
# Expose metrics port
2842
EXPOSE 8000
2943

30-
CMD ["uv", "run","--no-cache", "python", "mcp_server.py"]
44+
CMD ["uv", "run", "--no-cache", "python", "mcp_server.py"]

openshift/template.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ objects:
8585
dnsPolicy: ClusterFirst
8686
restartPolicy: Always
8787
schedulerName: default-scheduler
88-
securityContext:
89-
runAsNonRoot: true
90-
fsGroup: 0
88+
securityContext: {}
9189
terminationGracePeriodSeconds: 30
9290
- apiVersion: v1
9391
kind: Service

0 commit comments

Comments
 (0)