-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
56 lines (40 loc) · 1.24 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
# Development environment
FROM hexpm/elixir:1.11.3-erlang-23.2.1-ubuntu-focal-20201008 AS development
RUN apt-get update \
&& apt-get install -y curl ca-certificates inotify-tools wait-for-it \
&& curl -sL https://deb.nodesource.com/setup_12.x | bash - \
&& apt-get install -y nodejs \
&& mix do local.hex --force, local.rebar --force \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Build environment
FROM development AS build
COPY assets/package.json assets/package-lock.json /app/assets/
RUN npm i --prefix assets
ARG MIX_ENV=prod
ENV MIX_ENV=$MIX_ENV
COPY mix.exs mix.lock /app/
COPY config /app/config/
RUN mix do deps.get --only $MIX_ENV, deps.compile
COPY assets /app/assets/
RUN npm run deploy --prefix assets
COPY . /app/
RUN mix do compile, phx.digest
# Release environment
FROM build AS release
ARG MIX_ENV=prod
ENV MIX_ENV=$MIX_ENV
RUN mix release --quiet
# Production environment
FROM ubuntu:20.04 AS production
RUN apt-get update \
&& apt-get install -y openssl locales locales-all \
&& rm -rf /var/lib/apt/lists/*
ARG MIX_ENV=prod
ENV MIX_ENV=$MIX_ENV
WORKDIR /app
COPY --from=release /app/_build/$MIX_ENV/rel/mina/ /app
ENV LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8
ENV PATH=/app/bin:$PATH
EXPOSE 4000
CMD mina