-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
129 lines (75 loc) · 1.85 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Development Application
FROM wunsh/alpine-elixir-elm as app
MAINTAINER Docdog Developers <dev@docdog.io>
ARG BUILD_ENV=prod
ARG PORT=4000
ENV \
APP_NAME=docdog \
\
MIX_ENV=$BUILD_ENV \
PORT=$PORT \
\
MIX_HOME=/opt/mix \
HEX_HOME=/opt/hex \
HOME=/opt/app
EXPOSE ${PORT}
RUN \
echo "Build Docker image for Mix env: ${MIX_ENV}." && \
\
mkdir -p ${HOME} && \
chmod -R 777 ${HOME} && \
apk update && \
apk --no-cache --update add \
g++ inotify-tools make python yarn && \
update-ca-certificates --fresh && \
rm -rf /var/cache/apk/* && \
\
mix local.hex --force && \
mix local.rebar --force
# Cache Mix dependencies
WORKDIR ${HOME}
ADD mix.exs mix.lock ./
RUN mix do deps.get --only=${MIX_ENV}, deps.compile
# Cache Yarn dependencies
WORKDIR assets
ADD assets/package.json assets/yarn.lock ./
RUN yarn install
# Cache Elm dependencies
WORKDIR elm
ADD assets/elm/elm-package.json ./
RUN elm package install -y
WORKDIR ${HOME}
ADD . .
WORKDIR assets/elm
RUN elm-make Main.elm --output=../js/main.js
WORKDIR assets
RUN if [ ${MIX_ENV} = "prod" ]; then yarn run deploy; else yarn run build; fi
WORKDIR ${HOME}
RUN mix do compile, phx.digest
RUN \
if [ ${MIX_ENV} = "prod" ]; then \
mix release --env=${MIX_ENV}; \
\
RELEASE_DIR=`ls -d _build/${MIX_ENV}/rel/${APP_NAME}/releases/*/` && \
mkdir /release && \
tar -xf "${RELEASE_DIR}${APP_NAME}.tar.gz" -C /release; \
fi
CMD ["mix", "phx.server"]
# Release Application
FROM bitwalker/alpine-erlang:21.0.3
MAINTAINER Docdog Developers <dev@docdog.io>
ARG BUILD_ENV=prod
ARG PORT=4000
ENV \
APP_NAME=docdog \
HOME=/opt/app \
MIX_ENV=$BUILD_ENV \
PORT=$PORT \
REPLACE_OS_VARS=true
EXPOSE ${PORT}
COPY --from=app /release/ .
RUN \
apk update && \
apk add inotify-tools
ENTRYPOINT ["/opt/app/bin/docdog"]
CMD ["foreground"]