forked from appujet/lavamusic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
46 lines (32 loc) · 972 Bytes
/
Dockerfile
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
# Stage 1: Build TypeScript
FROM node:20 as builder
WORKDIR /opt/lavamusic/
# Copy package files and install dependencies
COPY package*.json ./
RUN apt-get update && \
apt-get install -y && \
npm install
# Copy source code
COPY . .
# Copy tsconfig.json
COPY tsconfig.json ./
# Build TypeScript
RUN npm run build
# Stage 2: Create production image
FROM node:20-slim
ENV NODE_ENV production
WORKDIR /opt/lavamusic/
# Copy compiled code
COPY --from=builder /opt/lavamusic/dist ./dist
COPY --from=builder /opt/lavamusic/src/utils/LavaLogo.txt ./src/utils/LavaLogo.txt
# Copy package files and install production dependencies
COPY package*.json ./
RUN npm install --only=production
# Run as non-root user
RUN addgroup --gid 322 --system lavamusic && \
adduser --uid 322 --system lavamusic
# Change ownership of the folder
RUN chown -R lavamusic:lavamusic /opt/lavamusic/
# Switch to the appropriate user
USER lavamusic
CMD [ "node", "dist/index.js" ]