-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (45 loc) · 1.13 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (45 loc) · 1.13 KB
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
FROM hexpm/elixir:1.14.5-erlang-25.3.2.21-debian-buster-20240612-slim AS base
RUN mkdir /ex_json_parser
WORKDIR /ex_json_parser
# Cache elixir deps
ADD mix.exs ./
RUN mix do local.hex --force, local.rebar --force, deps.get, deps.compile, tailwind.install
# Install all required packages in a single layer
RUN apt-get update && \
apt-get install -y --no-install-recommends \
npm \
inotify-tools \
curl \
bash \
git && \
rm -rf /var/lib/apt/lists/*
# -----------------
# BUILD
# -----------------
FROM base AS build
ARG MIX_ENV=prod
ENV MIX_ENV=$MIX_ENV
COPY . ./
# install application
RUN mix do deps.get, compile
# -----------------
# RELEASE
# -----------------
FROM build AS release
# digests and compresses static files
RUN mix assets.deploy
# generate release executable
RUN mix release
# -----------------
# PRODUCTION
# -----------------
FROM alpine:3.18.3
WORKDIR /ex_json_parser
ARG MIX_ENV=prod
# install dependencies
RUN apk add --no-cache \
ncurses-libs \
curl
COPY --from=release /ex_json_parser/_build/$MIX_ENV/rel/ex_json_parser ./
# start application
CMD ["bin/ex_json_parser", "start"]