-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
41 lines (29 loc) · 853 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
FROM node:18-alpine AS base
# Stage 1: Build the application
FROM base AS builder
# Set the working directory
WORKDIR /app
# Set environment variables
ENV NODE_ENV production
# Copy source code
COPY . .
# Install and build
RUN yarn && yarn build
# Stage 2: Create the final image
FROM base AS runner
# Set the working directory
WORKDIR /app
# Copy only necessary files from the builder stage
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.next/standalone ./app
COPY --from=builder /app/public ./app/public
COPY --from=builder /app/.next/static ./app/.next/static
# Link package to github repo
ARG repo
LABEL org.opencontainers.image.source https://github.com/${repo}
# Expose port 3000
EXPOSE 3000
# set hostname to localhost
ENV HOSTNAME "0.0.0.0"
# CMD to start the application
CMD ["node", "app/server.js"]