forked from Pymmdrza/BlockHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (34 loc) · 967 Bytes
/
Dockerfile
File metadata and controls
48 lines (34 loc) · 967 Bytes
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
# Stage 1: Build Stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files and install dependencies
COPY package*.json ./
RUN npm install
# Copy the rest of the application code
COPY . .
# Build the app
RUN npm run build
# Stage 2: Production Stage
FROM node:20-alpine
WORKDIR /app
# Install production dependencies only
COPY package*.json ./
RUN npm install --omit=dev
# Copy built application from the builder stage
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/server ./server
# Create directory for health checks
RUN mkdir -p /app/dist/health
RUN echo "OK" > /app/dist/health/status
# Create logs directory
RUN mkdir -p /app/logs
# Expose port
EXPOSE 80
# Set environment variables
ENV NODE_ENV=production \
PORT=80
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget -q -O- http://localhost/health/status || exit 1
# Start the server
CMD ["node", "server/index.js"]