-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
57 lines (41 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
ARG ELIXIR_IMAGE_VERSION=1.12.2
ARG ERLANG_IMAGE_VERSION=24.0.5
ARG RELEASE_IMAGE_VERSION=3.13.5
FROM hexpm/elixir:${ELIXIR_IMAGE_VERSION}-erlang-${ERLANG_IMAGE_VERSION}-alpine-${RELEASE_IMAGE_VERSION} AS build
# install build dependencies
RUN apk add --no-cache build-base npm git && \
mix local.hex --force && \
mix local.rebar --force
# prepare build dir
WORKDIR /app
# set build ENV
ENV MIX_ENV=prod
# install mix dependencies
COPY mix.exs mix.lock ./
COPY config config
RUN mix do deps.get, deps.compile
# build assets
COPY assets/package.json assets/package-lock.json ./assets/
RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error
COPY priv priv
COPY assets assets
RUN npm run --prefix ./assets deploy
RUN mix phx.digest
# compile and build release
COPY lib lib
# uncomment COPY if rel/ exists
# COPY rel rel
RUN mix do compile, release
# prepare release image
FROM alpine:3.12.1 AS app
RUN apk add --no-cache openssl ncurses-libs
WORKDIR /app
# Setup non-root user
RUN addgroup -S app_group && \
adduser -s /bin/sh -G app_group -D app_user && \
chown app_user:app_group /app
COPY --from=build --chown=app_user:app_group /app/_build/prod/rel/gscraper ./
COPY bin/start.sh ./bin/start.sh
ENV HOME=/app
USER app_user
CMD bin/start.sh