-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.frontend
More file actions
41 lines (29 loc) · 861 Bytes
/
Dockerfile.frontend
File metadata and controls
41 lines (29 loc) · 861 Bytes
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
# Build stage
FROM node:22-alpine AS build
WORKDIR /app
# Install dependencies
COPY package.json package-lock.json ./
RUN npm ci
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Production stage
FROM node:22-alpine AS production
WORKDIR /app
# Create a non-root user to run the application
RUN addgroup --system --gid 1001 sveltekit && \
adduser --system --uid 1001 sveltekit
# Copy built assets from build stage
COPY --from=build --chown=sveltekit:sveltekit /app/build ./build
COPY --from=build --chown=sveltekit:sveltekit /app/node_modules ./node_modules
COPY --from=build --chown=sveltekit:sveltekit /app/package.json ./
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3000
# Switch to non-root user
USER sveltekit
# Expose the port the app runs on
EXPOSE 3000
# Start the application
CMD ["node", "build"]