-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (48 loc) · 1.77 KB
/
Dockerfile
File metadata and controls
68 lines (48 loc) · 1.77 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
# Multi-stage Docker build for Ruuvi Home Lite monorepo
FROM node:22-alpine AS builder
# Install build dependencies
RUN apk add --no-cache python3 make g++ sqlite-dev
WORKDIR /app
# Copy root package files for workspace dependencies
COPY package*.json ./
COPY packages/shared/package*.json ./packages/shared/
COPY packages/backend/package*.json ./packages/backend/
COPY packages/frontend/package*.json ./packages/frontend/
# Install all dependencies including workspaces
RUN npm ci
# Copy source code
COPY packages/ ./packages
COPY tsconfig.json ./
# Build packages in dependency order
RUN npm run build
# Production stage
FROM node:22-alpine AS production
# Install runtime dependencies
RUN apk add --no-cache sqlite dumb-init curl
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S ruuvi -u 1001 -G nodejs
WORKDIR /app
# Copy node_modules (includes workspace links)
COPY --from=builder --chown=ruuvi:nodejs /app/node_modules ./node_modules
# Copy built backend application
COPY --from=builder --chown=ruuvi:nodejs /app/packages/backend/dist ./
# Copy built frontend to serve as static files
COPY --from=builder --chown=ruuvi:nodejs /app/packages/frontend/dist ./public
# Copy configuration files
COPY --from=builder --chown=ruuvi:nodejs /app/packages/backend/config ./config
# Create data and logs directories
RUN mkdir -p data logs certs && \
chown -R ruuvi:nodejs /app/data /app/logs /app/certs
# Copy environment example
COPY .env.example .env.docker
# Switch to non-root user
USER ruuvi
# Expose ports
EXPOSE 3000 3001
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost:3001/health || exit 1
# Use dumb-init for proper signal handling
ENTRYPOINT ["dumb-init", "--"]
CMD ["node", "server.js"]