forked from Chronasorg/chronas-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
69 lines (56 loc) · 1.78 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
65
66
67
68
69
#https://blog.hasura.io/an-exhaustive-guide-to-writing-dockerfiles-for-node-js-web-apps-bbee6bd2f3c4
# ---- Base Node ----
FROM node:10 AS base
# Create app directory
WORKDIR /app
# ---- Dependencies ----
FROM base AS dependencies
COPY package.json ./
# install app dependencies including 'devDependencies'
RUN npm install
# ---- Copy Files/Build ----
FROM dependencies AS build
WORKDIR /app
COPY . /app
ARG BUILD_ID=123
#update commit and build id
RUN npm install appversion -g \
&& apv set-version 1.0.$BUILD_ID \
&& apv update commit \
&& apv update build
# Build the app and run the tests
RUN npm run build \
&& npm test
WORKDIR /app/dist
# --- Release with Alpine ----
FROM node:10-alpine AS release
# Create app directory
WORKDIR /app
# --- add env variables ---
ENV NODE_ENV=production
ENV MONGO_HOST=mongodb://localhost/chronas-api
ENV MONGO_PORT=27017
ENV PORT=80
ENV APPINSIGHTS_INSTRUMENTATIONKEY=placeholder
ENV TWITTER_CONSUMER_KEY=placeholder
ENV TWITTER_CONSUMER_SECRET=placeholder
ENV TWITTER_CALLBACK_URL=placeholder
ENV JWT_SECRET=placeholder
ENV MAILGUN_KEY=placeholder
ENV CHRONAS_HOST=https://chronas.org
ENV FACEBOOK_CALLBACK_URL=https://api.chronas.org/v1/auth/login/facebook?cb
ENV GOOGLE_CALLBACK_URL=https://api.chronas.org/v1/auth/login/google?cb
ENV GITHUB_CALLBACK_URL=https://api.chronas.org/v1/auth/login/github?cb
ENV TWITTER_CALLBACK_URL=https://api.chronas.org/v1/auth/login/twitter
# copy app from build
COPY --from=build /app/dist/ ./
#workaround to install python for bcrypt
RUN apk update && apk upgrade \
&& apk add --no-cache git \
&& apk --no-cache add --virtual builds-deps build-base python \
&& npm install --production\
&& npm rebuild bcrypt --build-from-source \
&& apk del builds-deps
EXPOSE 80
# cmd to start service
CMD [ "node", "index.js" ]