-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
42 lines (31 loc) · 1.11 KB
/
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
# stage1 as builder
FROM node:16 as builder
WORKDIR /app
# copy the package.json to install dependencies
COPY package.json .
COPY package-lock.json .
COPY .env.example .env
# Set env variables
ARG NEXT_PUBLIC_SPACE_ID
RUN sed -i "s|{{NEXT_PUBLIC_SPACE_ID}}|${NEXT_PUBLIC_SPACE_ID}|g" ./.env
ARG NEXT_PUBLIC_CONTENT_DELIVERY_TOKEN
RUN sed -i "s|{{NEXT_PUBLIC_CONTENT_DELIVERY_TOKEN}}|${NEXT_PUBLIC_CONTENT_DELIVERY_TOKEN}|g" ./.env
ARG NEXT_PUBLIC_SENDGRID_API_KEY
RUN sed -i "s|{{NEXT_PUBLIC_SENDGRID_API_KEY}}|${NEXT_PUBLIC_SENDGRID_API_KEY}|g" ./.env
# Install the dependencies and make the folder
RUN npm install
COPY . .
# Build the project and copy the files
RUN npm run build
RUN rm -rf node_modules
RUN npm install --production
FROM node:alpine
COPY --from=builder /app/node_modules /app/node_modules
COPY --from=builder /app/package.json /app
COPY --from=builder /app/.next /app/.next
COPY --from=builder /app/public /app/public
COPY --from=builder /app/next.config.js /app/next.config.js
COPY --from=builder /app/next-i18next.config.js /app/next-i18next.config.js
WORKDIR /app
EXPOSE 3000 80
ENTRYPOINT ["npm", "start"]