-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (29 loc) · 1.16 KB
/
Dockerfile
File metadata and controls
38 lines (29 loc) · 1.16 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
# Build argument must be declared before any FROM that uses it
ARG BUILD=prod
# Base stage with common dependencies (Python + system + PyCG)
FROM python:3.10-slim AS base
# Install system dependencies (git is needed for PyCG)
RUN apt-get update && \
apt-get install -y --no-install-recommends git && \
rm -rf /var/lib/apt/lists/*
# Install PyCG (shared across prod/dev builds)
RUN git clone --depth 1 https://github.com/gdrosos/PyCG.git /tmp/pycg && \
pip install --no-cache-dir /tmp/pycg && \
rm -rf /tmp/pycg
# Production stage: install PyTrim from PyPI
FROM base AS prod
RUN echo "Installing PyTrim from PyPI..." && \
pip install --no-cache-dir pytrim
# Development stage: install PyTrim from local source with dev dependencies
FROM base AS dev
COPY . /app/
RUN echo "Installing PyTrim from local source for development..." && \
cd /app && pip install --no-cache-dir -e ".[dev]"
# Final stage: select prod (default) or dev based on build arg
FROM ${BUILD} AS final
# Add PyCG binaries to PATH
ENV PATH="/root/.local/bin:${PATH}"
# Workspace for user projects
WORKDIR /project
VOLUME ["/project"]
CMD ["/bin/bash"]