-
-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (40 loc) · 1.31 KB
/
Copy pathDockerfile
File metadata and controls
56 lines (40 loc) · 1.31 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
# Lunox Discord Music Bot
# Multi-stage build for optimized production image
# ================================
# Stage 1: Dependencies
# ================================
FROM node:20-alpine AS dependencies
WORKDIR /app
# Install build dependencies for native modules
RUN apk add --no-cache python3 make g++
# Copy package files
COPY package*.json ./
# Install production dependencies only
RUN npm ci --only=production --ignore-scripts && \
npm cache clean --force
# ================================
# Stage 2: Production
# ================================
FROM node:20-alpine AS production
# Set environment
ENV NODE_ENV=production
# Create non-root user for security
RUN addgroup -g 1001 -S lunox && \
adduser -S lunox -u 1001
WORKDIR /app
# Copy dependencies from build stage
COPY --from=dependencies /app/node_modules ./node_modules
# Copy source code
COPY --chown=lunox:lunox package*.json ./
COPY --chown=lunox:lunox src ./src
# Set proper permissions
RUN chown -R lunox:lunox /app
# Switch to non-root user
USER lunox
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD node -e "console.log('healthy')" || exit 1
# Expose no ports (bot connects outbound to Discord)
# If you add a web dashboard later, expose the port here
# Start the bot
CMD ["node", "src/index.js"]