-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (36 loc) · 1.12 KB
/
Dockerfile
File metadata and controls
50 lines (36 loc) · 1.12 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
# Multi-stage build for optimization
# Use non-alpine image to avoid OpenSSL issues with old packages
FROM node:18 AS builder
# Set working directory
WORKDIR /app
# Copy package files first for better layer caching
COPY package*.json ./
# Install dependencies
RUN npm ci --only=production && \
npm cache clean --force
# Production stage
FROM node:18-slim AS production
# Add metadata
LABEL maintainer="SPK Network"
LABEL description="Trole - Role-based IPFS bridge controller"
LABEL version="1.0.0"
# Create non-root user (using Debian commands for slim image)
RUN groupadd -g 1001 trole && \
useradd -m -u 1001 -g trole trole
# Set working directory
WORKDIR /app
# Copy dependencies from builder stage
COPY --from=builder /app/node_modules ./node_modules
# Copy application code
COPY --chown=trole:trole . .
# Create necessary directories
RUN mkdir -p /app/db && chown -R trole:trole /app
# Switch to non-root user
USER trole
# Expose port
EXPOSE 5050
# Add health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node healthcheck.js || exit 1
# Start application
CMD ["node", "index.js"]