-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (51 loc) · 1.75 KB
/
Dockerfile
File metadata and controls
69 lines (51 loc) · 1.75 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
FROM python:3.12-slim
WORKDIR /app
ARG NODE_VERSION=18.x
# Install necessary tools, Node.js, and unzip
RUN apt-get update && apt-get install -y \
curl \
libpq-dev \
gnupg \
unzip \
xclip \
libxkbcommon-x11-0 \
&& curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - \
&& apt-get install -y nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
rm -rf /var/lib/apt/lists/*
# Install CA certs and dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl gnupg && \
update-ca-certificates && \
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 makemigrations && reflex db migrate && reflex run --env prod --backend-only --loglevel debug"]