-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
64 lines (47 loc) · 1.26 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
61
62
63
64
#---dependencies---#
#---install full test and build deps and separate copy of runtime deps---#
FROM node:10.15.3-alpine AS deps
ARG npmUri
ARG npmAuthToken
ARG NODE_ENV
COPY package.json /tmp
COPY yarn.lock /tmp
WORKDIR /tmp
RUN echo "\"registry\" \"https://${npmUri}/:_authToken=${npmAuthToken}\"" > ~/.yarnrc
RUN yarn --production
RUN rm ~/.yarnrc
RUN cp -R node_modules prod_node_modules
RUN yarn
#---build---#
#---build our typescript for release---#
FROM node:10.15.3-alpine AS build
ARG NODE_ENV
ARG TYPEORM_PASSWORD
COPY . /build
WORKDIR /build
COPY --from=deps /tmp/node_modules ./node_modules
RUN yarn run build
# #---tests---#
# #---run tests---#
FROM node:10.15.3-alpine AS test
ARG NODE_ENV
ARG TYPEORM_PASSWORD
COPY . /tests
WORKDIR /tests
COPY --from=deps /tmp/node_modules ./node_modules
# since routes.test is generated, we need to make sure it's present for tests
RUN yarn run build
ENV CI=true
RUN yarn run test
#---release---#
#---copy production dependencies and build typescript and run!---#
FROM build AS release
ARG NODE_ENV
ARG TYPEORM_PASSWORD
WORKDIR /app
COPY --from=build /build/build ./build
COPY --from=deps /tmp/package.json .
COPY --from=deps /tmp/prod_node_modules ./node_modules
RUN mkdir -p /app/.tmp
EXPOSE 3000
ENTRYPOINT ["yarn", "start"]