-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (35 loc) · 1.17 KB
/
Dockerfile
File metadata and controls
48 lines (35 loc) · 1.17 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
# Stage 1: Builder stage
FROM node:22.22.2 AS builder
WORKDIR /app
# Copy package.json and yarn.lock files
COPY package.json yarn.lock ./
# Copy the rest of the application code
COPY . .
# Install dependencies
RUN rm -rf node_modules
RUN yarn install --frozen-lockfile --network-timeout 600000
RUN yarn global add patch-package
# Build the application
RUN yarn build
# Stage 2: Production stage
FROM node:22.22.2-slim
# Update system packages and install security updates
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
ca-certificates && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /app
# Copy built files and node_modules from the builder stage
COPY --from=builder /app/build ./build
COPY --from=builder /app/bin ./bin
COPY --from=builder /app/package.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/patches ./patches
# Create non-root user for security
RUN groupadd -r appuser && useradd -r -g appuser appuser && \
chown -R appuser:appuser /app && \
chmod -R 755 /app
USER appuser
# Set entry point
ENTRYPOINT ["node", "./bin/afj-rest.js", "start"]