forked from tolgee/react-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (41 loc) · 1.44 KB
/
Dockerfile
File metadata and controls
49 lines (41 loc) · 1.44 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
# Multi-stage build for React app and Node.js server
# Stage 1: Build the React app
FROM docker.io/library/node:25.9.0-alpine3.23 as frontend-build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
# Set default environment variables for the build
ARG VITE_APP_URL=https://vote.tolgee.io
ENV VITE_APP_URL=${VITE_APP_URL}
ARG VITE_APP_TOLGEE_API_URL
ENV VITE_APP_TOLGEE_API_URL=${VITE_APP_TOLGEE_API_URL}
ARG VITE_APP_TOLGEE_API_KEY
ENV VITE_APP_TOLGEE_API_KEY=${VITE_APP_TOLGEE_API_KEY}
ARG VITE_APP_TOLGEE_CDN_URL
ENV VITE_APP_TOLGEE_CDN_URL=${VITE_APP_TOLGEE_CDN_URL}
ARG VITE_APP_TOLGEE_PROJECT_ID
ENV VITE_APP_TOLGEE_PROJECT_ID=${VITE_APP_TOLGEE_PROJECT_ID}
RUN npm run build
# Stage 2: Build the Node.js server
FROM docker.io/library/node:25.9.0-alpine3.23 as server-build
WORKDIR /app
COPY server/package*.json ./
RUN npm install
COPY server ./
RUN npm run build
# Stage 3: Production environment
FROM docker.io/library/node:25.9.0-alpine3.23
WORKDIR /app
# Copy built server
COPY --from=server-build /app/dist ./server/dist
COPY --from=server-build /app/node_modules ./server/node_modules
COPY --from=server-build /app/package.json ./server/
# Copy built frontend
COPY --from=frontend-build /app/dist ./dist
# Create data directory for SQLite
RUN mkdir -p /app/server/data
# Expose port 80 for the server
EXPOSE 80
# Start the server only (it will serve the frontend)
CMD ["sh", "-c", "cd server && PORT=80 NODE_ENV=production node dist/index.js"]