-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
62 lines (47 loc) · 1.5 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
FROM node:14-alpine AS base
WORKDIR /build
ARG NEXT_PUBLIC_API_URL=http://localhost:3333/api
ARG NEXT_PUBLIC_OMISE_PUBLIC_KEY=""
ARG NEXT_PUBLIC_SOCKET_API_URL=http://localhost:3333
# Prepare for installing dependencies
# Utilise Docker cache to save re-installing dependencies if unchanged
COPY package.json yarn.lock ./
# Install dependencies
RUN yarn --frozen-lockfile
# Copy the rest files
COPY . .
# Build storybook
RUN yarn build:storybook
# Build all application
RUN yarn build
# Install only production dependencies
RUN yarn install --frozen-lockfile --production --ignore-scripts --prefer-offline
# ------ stage 2 ---------
FROM ubuntu/nginx:1.18-20.04_beta
WORKDIR /etc/nginx/
ENV NODE_ENV production
# Run api update and upgrade
RUN apt update -y && apt upgrade -y
# Install curl
RUN apt -y install curl
# Install nodejs
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt install -y nodejs
# Install musl-dev
RUN apt-get install -y musl-dev \
&& ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1
# Copy application files
COPY nginx/nginx.conf .
WORKDIR /
COPY --from=base /build/package.json ./package.json
COPY --from=base /build/dist ./dist
COPY --from=base /build/apps ./apps
COPY --from=base /build/libs ./libs
COPY --from=base /build/tools ./tools
COPY --from=base /build/node_modules ./node_modules
COPY start_production_docker.sh .
# Expose nginx port
EXPOSE 80
# # Run Start command
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["./start_production_docker.sh"]