-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (40 loc) · 1.36 KB
/
Copy pathDockerfile
File metadata and controls
52 lines (40 loc) · 1.36 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
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy server package files
COPY server/package*.json ./server/
# Install server dependencies
RUN cd server && npm install --production && cd ..
# Create client/app directory and its package.json
RUN mkdir -p ./client/app && \
echo '{"type": "module"}' > ./client/app/package.json
# Create shared directory and its package.json
RUN mkdir -p ./shared && \
echo '{"type": "module"}' > ./shared/package.json
# Copy source files
COPY shared/ ./shared/
COPY server/app/ ./server/app/
COPY client/css/ ./client/css/
COPY client/fonts/ ./client/fonts/
COPY client/images/ ./client/images/
COPY client/app/ ./client/app/
COPY index.html ./index.html
COPY version.json ./version.json
COPY help.json ./help.json
COPY client/manifests/PWA/manifest.json ./client/manifests/PWA/manifest.json
# Production stage
FROM node:20-alpine
WORKDIR /app
# Copy all files from builder
COPY --from=builder /app/ ./
# Create books directory
RUN mkdir -p /app/books
# Create .env file with production settings and generate random SESSION_SECRET
RUN echo "NODE_ENV=production" > /app/server/.env && \
echo "SESSION_SECRET=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 64 | head -n 1)" >> /app/server/.env
# Expose port
EXPOSE 8866
# Set books directory as a volume
VOLUME ["/app/books"]
# Start command
CMD ["node", "server/app/app.js"]