generated from api-platform/api-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
60 lines (36 loc) · 1.32 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
58
59
60
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
# https://docs.docker.com/compose/compose-file/#target
# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG NODE_VERSION=14
ARG NGINX_VERSION=1.19
# "common" stage
FROM node:${NODE_VERSION}-alpine AS api_platform_client_common
EXPOSE 3000
WORKDIR /usr/src/client
RUN yarn global add @api-platform/client-generator
# prevent the reinstallation of node modules at every changes in the source code
COPY package.json yarn.lock ./
RUN set -eux; \
yarn; \
npx next telemetry disable
COPY . ./
VOLUME /usr/src/client/node_modules
ENV HTTPS true
# "development" stage
# depends on the "common" stage above
FROM api_platform_client_common AS api_platform_client_development
CMD ["yarn", "dev:ssl"]
# "build" stage
# depends on the "common" stage above
FROM api_platform_client_common AS api_platform_client_build
ENV NODE_ENV production
ARG REACT_APP_API_ENTRYPOINT
RUN set -eux; \
yarn build
CMD ["yarn", "start:ssl"]
# "nginx" stage
# depends on the "build" stage above
FROM nginx:${NGINX_VERSION}-alpine AS api_platform_client_nginx
COPY docker/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
WORKDIR /usr/src/client/out
COPY --from=api_platform_client_build /usr/src/client/out ./