1
1
# Stage 1: Compile and Build the app
2
2
3
3
# Node veersion
4
- FROM node:14.15.1 as build
4
+ FROM node:14.17.3-alpine as build
5
5
6
- # update
7
-
8
- RUN apt-get update
9
- RUN apt-get -y install curl gnupg
10
- RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
11
- RUN apt-get -y install nodejs
6
+ # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
7
+ RUN apk add --no-cache libc6-compat git
12
8
13
9
# Set the working directory
14
- WORKDIR /usr/local/ app
10
+ WORKDIR /app
15
11
16
12
# Add the source code to app
17
- COPY ./ /usr/local/ app/
13
+ COPY ./js / app
18
14
19
- WORKDIR js
20
15
# Install all the dependencies
21
- RUN yarn install
16
+ RUN yarn install --frozen-lockfile
22
17
RUN yarn bootstrap
23
18
24
19
# HERE ADD YOUR STORE WALLET ADDRESS
25
20
ENV REACT_APP_STORE_OWNER_ADDRESS_ADDRESS=""
26
21
27
22
# Generate the build of the application
28
- ENV GENERATE_SOURCEMAP=false
29
23
RUN yarn build
30
24
31
25
# Stage 2: Serve app with nginx server
32
26
33
- # Use official nginx image as the base image
34
- FROM nginx:latest
27
+ # Production image, copy all the files and run next
28
+ FROM node:14.17.3-alpine AS runner
29
+ WORKDIR /app
30
+
31
+ ENV NODE_ENV production
32
+
33
+ RUN addgroup -g 1001 -S nodejs
34
+ RUN adduser -S nextjs -u 1001
35
35
36
36
# Copy the build output to replace the default nginx contents.
37
- COPY --from=build /usr/local/app/js/build/web /usr/share/nginx/html
37
+ COPY --from=build /app/packages/web/next.config.js ./
38
+ COPY --from=build /app/packages/web/public ./public
39
+ COPY --from=build --chown=nextjs:nodejs /app/packages/web/.next ./.next
40
+ COPY --from=build /app/node_modules ./node_modules
41
+ COPY --from=build /app/packages/web/package.json ./package.json
42
+
43
+ USER nextjs
44
+
45
+ EXPOSE 3000
38
46
39
- # Expose port 80
40
- EXPOSE 80
47
+ CMD ["yarn" , "start:prod" ]
0 commit comments