-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile.production
More file actions
58 lines (42 loc) · 1.38 KB
/
Dockerfile.production
File metadata and controls
58 lines (42 loc) · 1.38 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
FROM python:3.11-slim
WORKDIR /app
ARG NODE_VERSION=20.x
# Install necessary tools, Node.js, and unzip
RUN apt-get update && apt-get install -y \
curl \
libpq-dev \
gnupg \
unzip \
&& curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - \
&& apt-get install -y nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Verify Node.js installation
RUN node --version && npm --version
# Create reflex user
RUN adduser --disabled-password --home /app reflex
# Set up Python environment
RUN python -m venv /app/.venv
ENV PATH="/app/.venv/bin:$PATH"
# Copy the application files
COPY --chown=reflex:reflex . /app
# Move .build-env to .env if it exists
RUN if [ -f .build-env ]; then mv .build-env .env; fi
# Set permissions
RUN chown -R reflex:reflex /app
# Switch to reflex user
USER reflex
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Initialize Reflex
RUN reflex init
# Remove .env file after reflex init
RUN rm -f .env
# Ensure all environment variables are set
ENV PATH="/app/.venv/bin:/usr/local/bin:/usr/bin:/bin:$PATH"
ENV NODE_PATH="/usr/lib/node_modules"
ENV REFLEX_DB_URL="sqlite:///reflex.db"
# Needed until Reflex properly passes SIGTERM on backend.
STOPSIGNAL SIGKILL
# Always apply migrations before starting the backend.
CMD ["sh", "-c", "reflex db migrate && reflex run --env prod --backend-only"]