Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
149 lines (115 loc) · 3.31 KB
/
Copy pathDockerfile
File metadata and controls
149 lines (115 loc) · 3.31 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
ARG IMAGE_VERSION=python:3.10.9-slim
#
# Base Stage
FROM ${IMAGE_VERSION} AS base
# Set environment variables
ENV PATH=/app/.venv/bin:$PATH \
LANG=C.UTF-8 \
PYTHONUNBUFFERED=1
RUN mkdir /.cache && chmod -R 777 /.cache
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq-dev \
libjpeg-dev \
libcurl4-openssl-dev \
bash \
libxml2-dev \
libxslt-dev \
curl \
unzip \
&& rm -rf /var/lib/apt/lists/*
# Install Python tools
RUN pip install --no-cache-dir --upgrade pip setuptools poetry uv
# Install bun
RUN curl -fsSL https://bun.sh/install | bash && rm -rf /var/lib/apt/lists/*
ENV PATH=/root/.bun/bin:$PATH
#
# Builder Stage
FROM base AS builder
# Install additional build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
netcat \
gcc \
python3-dev \
libffi-dev \
libssl-dev \
curl \
socat \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy dependency files
COPY requirements.freeze.txt /app/
# Create virtual environment using uv
RUN uv venv /app/.venv
# Install Python dependencies
RUN uv pip install --no-cache-dir -r requirements.freeze.txt
# Install frontend dependencies
RUN mkdir -p /build-frontend
COPY frontend/package.json frontend/bun.lock /build-frontend/
RUN cd /build-frontend && /root/.bun/bin/bun install
# Move Node.js modules to application directory
# RUN mv /build-frontend/node_modules /app/frontend/
# Copy application code
COPY zeroindex/ /app/zeroindex
COPY infra/ /app/infra
COPY scripts/ /app/scripts
COPY manage.py /app/
#
# Developer Stage
FROM base AS dev
# Set environment variables for development
ENV PYTHONPATH=/app:$PYTHONPATH \
PYTHONSTARTUP=/app/.pythonrc \
PYTHONHISTORY=/app/.python_history \
VIRTUAL_ENV=/venv
# Install development dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
netcat \
gcc \
python3-dev \
libpq-dev \
libxml2-dev \
libxslt-dev \
libcurl4-openssl-dev \
libssl-dev \
libffi-dev \
curl \
socat \
unzip \
&& rm -rf /var/lib/apt/lists/*
# Install Python tools including uv and Poetry
RUN pip install --no-cache-dir --upgrade pip setuptools poetry uv
# Set working directory
WORKDIR /app
# Create virtual environment using uv
RUN uv venv /venv
# Install Python dependencies
COPY requirements.freeze.txt /app/
RUN uv pip install --no-cache-dir -r requirements.freeze.txt
# Set PATH for Node.js and virtual environment
ENV PATH="/venv/bin:/usr/local/bin:${PATH}"
# Copy application code
COPY zeroindex/ /app/zeroindex
COPY infra/ /app/infra
# Install the application in editable mode
RUN uv pip install -r requirements.freeze.txt
#
# Release Stage
FROM base AS release
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy application from builder
COPY --from=builder /app /app
# Set working directory
WORKDIR /app
# Create directories with appropriate permissions
RUN mkdir -p /app/static/uploads && chmod 777 /app/static/uploads
# Ensure the virtual environment is in PATH
ENV PATH=/app/.venv/bin:$PATH
# Collect static files
RUN python manage.py collectstatic --noinput