-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
55 lines (55 loc) · 3.05 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
# This is the base dockerfile. Here the base image is pulled and the ras setup is done for the project.
# Make sure to include the base setup for lerna here.
FROM node:16 as base
WORKDIR /app
COPY ./package.json ./
RUN npm install
COPY ./lerna.json ./
# Package utils
FROM base as utils-build
WORKDIR /app/packages/utils
# Here the dependencies will be installed and the local required packages bootstrapped.
# The --slim flag will cause the package json to only include the dependencies, so not all changes to the package json cause docker to reinstall all packages.
COPY packages/utils/package-slim.json package.json
WORKDIR /app/
RUN npx lerna bootstrap --scope=utils --includeDependencies
WORKDIR /app/packages/utils
# The normal package.json should be copied after the install into the container
COPY packages/utils/package.json ./
# This will only add the command to the dockerfile if the build script exists in the package otherwise its ignored.
# Package components
FROM base as components-build
WORKDIR /app/packages/components
# Here the dependencies will be installed and the local required packages bootstrapped.
# The --slim flag will cause the package json to only include the dependencies, so not all changes to the package json cause docker to reinstall all packages.
COPY packages/components/package-slim.json package.json
WORKDIR /app/
COPY --from=utils-build /app/packages/utils/package.json /app/packages/utils/
RUN npx lerna bootstrap --scope=components --includeDependencies
COPY --from=utils-build /app/packages/utils/ /app/packages/utils/
WORKDIR /app/packages/components
# The normal package.json should be copied after the install into the container
COPY packages/components/package.json ./
# This will only add the command to the dockerfile if the build script exists in the package otherwise its ignored.
# Package pokedex
FROM base as pokedex-build
WORKDIR /app/packages/pokedex
# Here the dependencies will be installed and the local required packages bootstrapped.
# The --slim flag will cause the package json to only include the dependencies, so not all changes to the package json cause docker to reinstall all packages.
COPY packages/pokedex/package-slim.json package.json
WORKDIR /app/
COPY --from=components-build /app/packages/components/package.json /app/packages/components/
COPY --from=utils-build /app/packages/utils/package.json /app/packages/utils/
RUN npx lerna bootstrap --scope=pokedex --includeDependencies
COPY --from=components-build /app/packages/components/ /app/packages/components/
COPY --from=utils-build /app/packages/utils/ /app/packages/utils/
WORKDIR /app/packages/pokedex
# The normal package.json should be copied after the install into the container
COPY packages/pokedex/package.json ./
# This will only add the command to the dockerfile if the build script exists in the package otherwise its ignored.
RUN npm run build
# final stage
FROM base
COPY --from=utils-build /app/packages/utils /app/packages/utils
COPY --from=components-build /app/packages/components /app/packages/components
COPY --from=pokedex-build /app/packages/pokedex /app/packages/pokedex