-
Notifications
You must be signed in to change notification settings - Fork 45
/
Dockerfile
75 lines (54 loc) · 2.06 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
ARG ELIXIR_VERSION=1.17.3
ARG OTP_VERSION=27.1.2
ARG DEBIAN_VERSION=bullseye-20241016-slim
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
FROM ${BUILDER_IMAGE} as builder
ENV MIX_ENV prod
WORKDIR /app
COPY config/config.exs config/
COPY config/prod.exs config/
COPY config/runtime.exs config/
COPY . ./
COPY ./VERSION mix.exs mix.lock ./
COPY assets/package.json assets/package-lock.json assets/
# install build dependencies
RUN apt-get update -y && apt-get install -y curl bash build-essential git gcc make && \
# install nodejs
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs && \
# install rust
curl https://sh.rustup.rs -sSf | bash -s -- -y && \
# cleanup
apt-get clean && rm -f /var/lib/apt/lists/*_* && \
# app dependencies
mix do local.rebar --force, local.hex --force, deps.get, deps.compile && \
npm --prefix assets ci
# rust bin path
ENV PATH="/root/.cargo/bin:${PATH}"
# check installed correctly
RUN cargo version
# release
RUN mix release && \
npm run --prefix assets deploy && \
mix phx.digest
FROM ${RUNNER_IMAGE}
# Required for the BeamVM to run
RUN apt-get update -y && apt-get install -y curl libstdc++6 openssl libncurses5 locales \
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
# Set the locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Copy required files from builder step
COPY --from=builder app/_build/prod /opt/app
COPY --from=builder app/VERSION /opt/app/VERSION
COPY --from=builder app/priv/static /opt/app/rel/logflare/bin/priv/static
# Move files to the correct folder taking into consideration the VERSION
RUN cp -r /opt/app/rel/logflare/bin/priv/static /opt/app/rel/logflare/lib/logflare-$(cat /opt/app/VERSION)/priv/static
# Cleanup static assets not in use
RUN rm -r /opt/app/rel/logflare/bin/priv
WORKDIR /opt/app/rel/logflare/bin
COPY run.sh ./run.sh
CMD ["sh", "run.sh"]