-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathDockerfile.base
More file actions
49 lines (39 loc) · 1.6 KB
/
Dockerfile.base
File metadata and controls
49 lines (39 loc) · 1.6 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
ARG ELIXIR_VERSION=1.19.5
ARG OTP_VERSION=27.3.4.6
ARG DEBIAN_VERSION=trixie-20260112-slim
ARG RUST_VERSION=1.94.1
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
FROM ${BUILDER_IMAGE} AS builder
ARG RUST_VERSION
ENV MIX_ENV=prod
WORKDIR /app
# 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_22.x | bash - && \
apt-get install -y nodejs && \
# install rust
curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain ${RUST_VERSION} && \
# cleanup
apt-get clean && rm -f /var/lib/apt/lists/*_*
# app dependencies
COPY ./VERSION mix.exs mix.lock ./
COPY config/config.exs config/
COPY config/prod.exs config/
COPY config/runtime.exs config/
RUN mix do local.rebar --force + local.hex --force + deps.get + deps.compile
COPY assets/package.json assets/package-lock.json assets/
RUN npm --prefix assets ci
# rust bin path and release optimizations
ENV PATH="/root/.cargo/bin:${PATH}"
ENV CARGO_PROFILE_RELEASE_LTO="thin"
ENV CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
# check installed correctly
RUN cargo version
# pre-fetch cargo dependencies for layer caching
COPY Cargo.toml Cargo.lock ./
COPY --parents native/*/Cargo.toml ./
# TODO: Instead of creating an empty src/lib.rs, replace `cargo fetch --locked` with `cargo build --dependencies-only`
# once https://github.com/rust-lang/cargo/issues/2644 is resolved.
RUN for dir in native/*/; do mkdir -p "$dir/src" && touch "$dir/src/lib.rs"; done
RUN cargo fetch --locked