-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathDockerfile
82 lines (59 loc) · 2.03 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
# The version of Alpine to use for the final image
# This should match the version of Alpine that the release-builder image uses
# https://github.com/bitwalker/alpine-erlang/blob/master/Dockerfile
ARG ALPINE_VERSION=3.10
########################################################################
FROM node:slim as frontend-builder
ENV MIX_ENV=prod \
REPLACE_OS_VARS=true \
HOME=/app/
WORKDIR $HOME
RUN apt-get update && apt-get install --yes libgmp-dev netbase ca-certificates
COPY elm-package.json package.json package-lock.json ./
COPY priv ./priv
RUN npm install \
&& mkdir src \
&& printf 'module Main exposing (..)\nimport Html\nmain = Html.div [] []' > src/Main.elm \
&& ./node_modules/.bin/elm-make src/Main.elm --output priv/public/main.js --yes \
&& rm src/Main.elm \
&& rm priv/public/main.js
COPY src/* ./src/
RUN ./node_modules/.bin/elm-make src/Main.elm --output priv/public/main.js --yes
########################################################################
FROM bitwalker/alpine-elixir-phoenix:1.9.2 as release-builder
ENV MIX_ENV=prod \
REPLACE_OS_VARS=true \
HOME=/app/
WORKDIR $HOME
RUN apk add --update alpine-sdk coreutils
COPY --from=frontend-builder /app/priv /app/priv
# Compile deps
COPY mix.exs mix.lock ./
COPY config ./config
RUN mix do local.hex --force, local.rebar --force \
&& mix do deps.get --only $MIX_ENV, deps.compile
COPY lib ./lib
# Compile app
RUN mix do compile, release
########################################################################
FROM alpine:${ALPINE_VERSION}
LABEL maintainer="Louis Pilfold <louis@lpil.uk>"
EXPOSE 3000
ENV PORT=3000 \
MIX_ENV=prod \
REPLACE_OS_VARS=true \
SHELL=/bin/bash \
LANG=en_US.UTF-8 \
HOME=/app/ \
TERM=xterm \
APP_VERSION=1.0.0 \
APP_GIT_SHA=$SOURCE_VERSION
WORKDIR $HOME
COPY --from=release-builder /app/_build/prod/rel/elixre /app
RUN apk add --no-cache openssl-dev bash libgcc \
&& adduser -S www-elixre \
&& mkdir -p /app \
&& chown --recursive www-elixre /app
USER www-elixre
ENTRYPOINT ["/app/bin/elixre"]
CMD ["start"]