-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
82 lines (59 loc) · 1.6 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
70
71
72
73
74
75
76
77
78
79
80
81
82
# Development
# --------------------
# --------------------
FROM node:16.13-alpine3.14 as dev
LABEL maintainer="lagden@gmail.com"
# If Docker Host is Mac or Windows
ENV ENTR_INOTIFY_WORKAROUND=1
COPY --from=lagden/entr:5.0-alpine3.14 /usr/local/bin/entr /usr/local/bin/.
# Shared libraries
RUN apk add --no-cache --update libc6-compat
RUN ln -s /lib64/ld-linux-x86-64.so.2 /lib/ld-linux-x86-64.so.2
# Timezone
RUN apk add --no-cache --update tzdata
ENV TZ=America/Sao_Paulo
RUN ln -s /usr/share/zoneinfo/$TZ /etc/localtime
# Clear apk cache
RUN rm -rf /var/cache/apk/*
# Yarn
RUN yarn set version stable
ARG NODE_ENV="production"
ARG BASE="/home/node"
ENV NODE_ENV=$NODE_ENV
ENV BASE=$BASE
ENV BASE_APP=$BASE/app
WORKDIR $BASE
ADD --chown=node:node . $BASE_APP
USER node
WORKDIR $BASE_APP
RUN yarn install
# Main Backend
# --------------------
# --------------------
FROM node:16.13-alpine3.14 as main
LABEL maintainer="lagden@gmail.com"
# Shared libraries
RUN apk add --no-cache --update libc6-compat
RUN ln -s /lib64/ld-linux-x86-64.so.2 /lib/ld-linux-x86-64.so.2
# Timezone
RUN apk add --no-cache --update tzdata
ENV TZ=America/Sao_Paulo
RUN ln -s /usr/share/zoneinfo/$TZ /etc/localtime
# Clear apk cache
RUN rm -rf /var/cache/apk/*
# Yarn
RUN yarn set version stable
ARG NODE_ENV="production"
ARG BASE="/home/node"
ENV NODE_ENV=$NODE_ENV
ENV BASE=$BASE
ENV BASE_APP=$BASE/app
WORKDIR $BASE
ADD --chown=node:node . $BASE_APP
USER node
WORKDIR $BASE_APP
RUN bin/node/prod.js
RUN yarn install
RUN rm -rf bin/docker bin/local bin/node
RUN rm -rf .prettierrc* .eslintrc* .git* .yarnrc* yarn.lock
CMD ["node", "server"]