-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
43 lines (33 loc) · 1.34 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
FROM rustlang/rust:nightly as builder
# Make a fake Rust app to keep a cached layer of compiled crates
RUN USER=root cargo new app
WORKDIR /usr/src/app
RUN mkdir ln-websocket-proxy
COPY Cargo.toml Cargo.lock ./
# cargo under QEMU building for ARM can consumes 10s of GBs of RAM...
# Solution: https://users.rust-lang.org/t/cargo-uses-too-much-memory-being-run-in-qemu/76531/2
ENV CARGO_NET_GIT_FETCH_WITH_CLI true
# Needs at least a main.rs file with a main function
# Since this is a rust workspace, we need to init the other things too
RUN mkdir src && echo "fn main(){}" > src/main.rs && echo "fn main(){}" > src/lib.rs
# Will build all dependent crates in release mode
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/src/app/target \
cargo build --release --features="server"
# Copy the rest
COPY . .
# Build (install) the actual binaries
RUN cargo install --path . --features="server"
# Runtime image
FROM debian:bullseye-slim
# Some general ENVs
ENV RUST_LOG=debug
ENV LN_PROXY_PORT=8080
# Run as "app" user
RUN useradd -ms /bin/bash app
USER app
WORKDIR /app
# Get compiled binaries from builder's cargo install directory
COPY --from=builder /usr/local/cargo/bin/ln_websocket_proxy /app/ln-websocket-proxy
# No CMD or ENTRYPOINT, see fly.toml with `cmd` override.
ENTRYPOINT [ "/app/ln-websocket-proxy" ]