-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotService.Dockerfile
More file actions
45 lines (35 loc) · 1.34 KB
/
plotService.Dockerfile
File metadata and controls
45 lines (35 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# This image is used by the PlotService in backend to generate plots
# in an isolated environment (AI-generated Python scripts).
FROM python:3.12.12-alpine
# Environment variables for safer and cleaner Python behavior
# Python runtime configuration:
# - PYTHONDONTWRITEBYTECODE: prevents creation of .pyc files and __pycache__ directories
# (keeps the container filesystem clean)
# - PYTHONUNBUFFERED: forces stdout/stderr to be flushed immediately
# (ensures logs from AI-generated scripts appear instantly)
# - PIP_NO_CACHE_DIR: disables pip's package cache
# (reduces image size and avoids unnecessary files in Docker layers)
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
# Dependencies needed for scientific Python packages
RUN apk add --no-cache \
build-base \
libpq-dev
WORKDIR /app
RUN mkdir /app/plotService
RUN pip install --upgrade pip && \
pip install \
matplotlib==3.9.2 \
pandas==2.2.3 \
numpy==2.1.3 \
psycopg2-binary==2.9.9 \
sqlalchemy==2.0.36 \
mysql-connector-python==9.5.0
# Create a non-root user for better security
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Ensure the working directory is owned by the non-root user
RUN chown -R appuser:appgroup /app
USER appuser
# Backend overrides the default command
CMD ["sh"]