|
1 | | -FROM python:3.9-slim |
2 | | - |
3 | | -LABEL maintainer="Zipstack Inc." |
4 | | - |
5 | | -ENV \ |
6 | | - # Keeps Python from generating .pyc files in the container |
7 | | - PYTHONDONTWRITEBYTECODE=1 \ |
8 | | - # Set to immediately flush stdout and stderr streams without first buffering |
9 | | - PYTHONUNBUFFERED=1 \ |
10 | | - PYTHONPATH=/unstract \ |
11 | | - BUILD_CONTEXT_PATH=platform-service \ |
12 | | - BUILD_PACKAGES_PATH=unstract \ |
13 | | - PDM_VERSION=2.16.1 |
14 | | - |
15 | | -# Install system dependencies |
16 | | -RUN apt-get update; \ |
17 | | - apt-get --no-install-recommends install -y \ |
18 | | - # unstract sdk |
19 | | - build-essential libmagic-dev; \ |
20 | | - \ |
21 | | - apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*; \ |
22 | | - \ |
23 | | - pip install --no-cache-dir -U pip pdm~=${PDM_VERSION}; \ |
24 | | - \ |
25 | | - # Creates a non-root user with an explicit UID and adds permission to access the /app folder |
26 | | - # For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers |
27 | | - adduser -u 5678 --disabled-password --gecos "" unstract; |
28 | | - |
29 | | -USER unstract |
30 | | - |
31 | | -WORKDIR /app |
32 | | - |
33 | | -# Create venv and install gunicorn and other deps in it |
34 | | -RUN pdm venv create -w virtualenv --with-pip && \ |
35 | | - . .venv/bin/activate && \ |
36 | | - pip install --no-cache-dir \ |
37 | | - gunicorn \ |
38 | | - # Install opentelemetry for instrumentation |
39 | | - opentelemetry-distro \ |
40 | | - opentelemetry-exporter-otlp && \ |
41 | | - opentelemetry-bootstrap -a install |
42 | | - |
43 | | -# Read and execute access to non-root user to avoid security hotspot |
44 | | -# Write access to specific sub-directory need to be explicitly provided if required |
45 | | -COPY --chmod=755 ${BUILD_CONTEXT_PATH} /app/ |
46 | | -# Copy local dependency packages |
47 | | -COPY --chown=unstract ${BUILD_PACKAGES_PATH} /unstract |
48 | | - |
49 | | -# Install dependencies |
50 | | -RUN . .venv/bin/activate && \ |
51 | | - pdm sync --prod --no-editable |
52 | | - |
53 | | -EXPOSE 3001 |
54 | | - |
55 | | -# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug |
56 | | -CMD [".venv/bin/gunicorn", "--bind", "0.0.0.0:3001", "--timeout", "300", "unstract.platform_service.run:app"] |
| 1 | +FROM python:3.9-slim |
| 2 | + |
| 3 | +LABEL maintainer="Zipstack Inc." |
| 4 | + |
| 5 | +ENV \ |
| 6 | + # Keeps Python from generating .pyc files in the container |
| 7 | + PYTHONDONTWRITEBYTECODE=1 \ |
| 8 | + # Set to immediately flush stdout and stderr streams without first buffering |
| 9 | + PYTHONUNBUFFERED=1 \ |
| 10 | + PYTHONPATH=/unstract \ |
| 11 | + BUILD_CONTEXT_PATH=platform-service \ |
| 12 | + BUILD_PACKAGES_PATH=unstract \ |
| 13 | + PDM_VERSION=2.16.1 \ |
| 14 | + # OpenTelemetry configuration (disabled by default, enable in docker-compose) |
| 15 | + OTEL_TRACES_EXPORTER=none \ |
| 16 | + OTEL_METRICS_EXPORTER=none \ |
| 17 | + OTEL_LOGS_EXPORTER=none \ |
| 18 | + OTEL_SERVICE_NAME=unstract_platform |
| 19 | + |
| 20 | +# Install system dependencies |
| 21 | +RUN apt-get update; \ |
| 22 | + apt-get --no-install-recommends install -y \ |
| 23 | + # unstract sdk |
| 24 | + build-essential libmagic-dev; \ |
| 25 | + \ |
| 26 | + apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*; \ |
| 27 | + \ |
| 28 | + pip install --no-cache-dir -U pip pdm~=${PDM_VERSION}; \ |
| 29 | + \ |
| 30 | + # Creates a non-root user with an explicit UID and adds permission to access the /app folder |
| 31 | + # For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers |
| 32 | + adduser -u 5678 --disabled-password --gecos "" unstract; |
| 33 | + |
| 34 | +USER unstract |
| 35 | + |
| 36 | +WORKDIR /app |
| 37 | + |
| 38 | +# Create venv and install gunicorn and other deps in it |
| 39 | +RUN pdm venv create -w virtualenv --with-pip && \ |
| 40 | + . .venv/bin/activate |
| 41 | + |
| 42 | +# Read and execute access to non-root user to avoid security hotspot |
| 43 | +# Write access to specific sub-directory need to be explicitly provided if required |
| 44 | +COPY --chmod=755 ${BUILD_CONTEXT_PATH} /app/ |
| 45 | +# Copy local dependency packages |
| 46 | +COPY --chown=unstract ${BUILD_PACKAGES_PATH} /unstract |
| 47 | + |
| 48 | +# Install dependencies |
| 49 | +RUN . .venv/bin/activate && \ |
| 50 | + pdm sync --prod --no-editable --with deploy && \ |
| 51 | + opentelemetry-bootstrap -a install |
| 52 | + |
| 53 | +EXPOSE 3001 |
| 54 | + |
| 55 | +# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug |
| 56 | +CMD [".venv/bin/gunicorn", "--bind", "0.0.0.0:3001", "--timeout", "300", "unstract.platform_service.run:app"] |
0 commit comments