forked from pkosiec/mongo-seeding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.Dockerfile
75 lines (53 loc) · 1.36 KB
/
dev.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Run with context of the upper level directory
#
# Stage 1: Core
#
FROM node:12-alpine AS coreBuilder
LABEL Maintainer="Pawel Kosiec <[email protected]>"
ENV CORE_DIR=./core
WORKDIR /app
# Copy sources
COPY $CORE_DIR/package.json $CORE_DIR/package-lock.json $CORE_DIR/tsconfig.json /app/
COPY $CORE_DIR/src /app/src/
# Install dependencies
RUN npm install --no-optional
# Build app
RUN npm run build
# Remove sources
RUN rm -rf /app/src/ && \
rm -rf /app/node_modules/
RUN npm i --production --no-optional
#
# Stage 2: CLI
#
FROM node:12-alpine as cliBuilder
ENV CLI_DIR=./cli
WORKDIR /app
# Install dependencies
COPY $CLI_DIR/package.json $CLI_DIR/package-lock.json $CLI_DIR/tsconfig.json /app/
RUN npm i --no-optional
# Copy built core
COPY --from=coreBuilder /app/ node_modules/mongo-seeding/
# Copy app sources
COPY $CLI_DIR/src/ /app/src/
COPY $CLI_DIR/bin/ /app/bin/
# Build app
RUN npm run build
# Remove unnecessary sources
RUN rm -rf /app/src/ && \
rm -rf /app/node_modules/
#
# Stage 3: Final Docker image
#
FROM node:12-alpine
LABEL Maintainer="Pawel Kosiec <[email protected]>"
WORKDIR /app
COPY --from=cliBuilder /app/ /app/
# Create a symlink
RUN npm i --production --no-optional && \
npm link && \
rm -rf /app/node_modules/mongo-seeding/
# Copy built core
COPY --from=coreBuilder /app/ /app/node_modules/mongo-seeding/
WORKDIR /data
CMD seed