-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
76 lines (49 loc) · 1.66 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
FROM elixir:1.14.2 AS setup_base
WORKDIR /app
ENV NODE_VERSION=18 \
RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.64.0
RUN curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - && \
apt-get install -y nodejs
#todo ensure that Rust will always build with the x86_64 architecture
RUN curl https://sh.rustup.rs -sSf > rustup.sh
RUN chmod +x rustup.sh
RUN ./rustup.sh -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION
RUN chmod -R a+w $RUSTUP_HOME $CARGO_HOME
# install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force
FROM setup_base AS bake_release
ARG MIX_ENV
RUN apt install -y p7zip-full
COPY mix.exs mix.lock ./
RUN mix deps.get --only $MIX_ENV
RUN mkdir config
COPY assets/package.json assets/package-lock.json ./assets/
RUN npm ci --prefix ./assets
# we have to define runtime.exs as well,
# otherwise the release would be configured like it doesn't have a runtime.exs
COPY config/config.exs config/$MIX_ENV.exs config/runtime.exs config/
RUN mix deps.compile
COPY priv priv
COPY native native
COPY lib lib
COPY assets assets
RUN mix assets.deploy
COPY rel rel
RUN mix release
RUN 7z a global_api.7z /app/_build/$MIX_ENV/rel/global_api
FROM scratch AS release_7z
COPY --from=bake_release /app/global_api.7z .
CMD ["/bin/bash"]
FROM setup_base AS dev
RUN apt install -y inotify-tools
EXPOSE 80 443
CMD npm i --prefix ./assets && mix deps.get && mix ecto.migrate && mix phx.server
FROM debian:bullseye AS release
ARG MIX_ENV
WORKDIR /app
COPY --from=bake_release /app/_build/$MIX_ENV/rel/global_api .
CMD /app/bin/global_api start