Files
firezone/rust/Dockerfile
Jamil 6ad10c8f39 fix(ci): use etc-resolv-conf as default in headless image (#10126)
The headless client image we ship doesn't have systemd-resolved. By
default, if you try to run it without setting the `FIREZONE_DNS_CONTROL`
var, it will exit with an unhelpful error message that is difficult to
diagnose / debug for anyone unfamiliar to the inner workings of the
headless client:

```
Error: I/O error: No such file or directory (os error 2)

Caused by:
    No such file or directory (os error 2)

Stack backtrace:
   0: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
   1: firezone_bin_shared::network_changes::imp::Worker::new_dbus::{{closure}}
   2: firezone_headless_client::main::{{closure}}
   3: tokio::runtime::runtime::Runtime::block_on
   4: firezone_headless_client::main
   5: std::sys::backtrace::__rust_begin_short_backtrace
   6: std::rt::lang_start::{{closure}}
   7: main
```

To fix this, we set `FIREZONE_DNS_CONTROL=etc-resolv-conf` for the user
inside our headless-client image.

---------

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2025-08-05 16:24:00 +00:00

61 lines
1.8 KiB
Docker

ARG ALPINE_VERSION="3.20"
ARG PACKAGE
# Base image which is used to run the application binary
FROM alpine:${ALPINE_VERSION} AS runtime_base
ENV LANG=C.UTF-8 \
TERM=xterm \
RUST_BACKTRACE=1 \
RUST_LOG=info
WORKDIR /bin
## curl is needed to run tests (`main` runs CI against `release` images) and `firezone-relay` needs `curl` in its entry script.
RUN apk add --no-cache curl
# Gateway specific runtime base image
FROM runtime_base AS runtime_firezone-gateway
## iptables are needed only by gateway for masquerading
RUN apk add --no-cache iptables ip6tables
COPY ./docker-init-gateway.sh ./docker-init.sh
# Relay specific runtime base image
FROM runtime_base AS runtime_firezone-relay
COPY ./docker-init-relay.sh ./docker-init.sh
# Headless-client specific runtime base image
FROM runtime_base AS runtime_firezone-headless-client
COPY ./docker-init-client.sh ./docker-init.sh
# HTTP test server specific runtime base image
FROM runtime_base AS runtime_http-test-server
COPY ./docker-init-http-test-server.sh ./docker-init.sh
# Funnel package specific base image back into `runtime`
ARG PACKAGE
FROM runtime_${PACKAGE} AS runtime
ARG PACKAGE
ENTRYPOINT ["docker-init.sh"]
ENV PACKAGE=${PACKAGE}
CMD ${PACKAGE}
# Build an image for GitHub Actions which includes debug asserts and more test utilities
FROM runtime AS debug
RUN apk add --no-cache iperf3 bind-tools iproute2 jq procps iptables
## Build first with `cargo build --target ${TARGET} -p ${PACKAGE} && mv /target/${TARGET}/debug/${PACKAGE} .`
ARG PACKAGE
COPY ${PACKAGE} .
# Build a production image from including a binary compiled on the host
FROM runtime AS release
## Build first with `cargo build --target ${TARGET} -p ${PACKAGE} --release && mv /target/${TARGET}/release/${PACKAGE} .`
ARG PACKAGE
COPY ${PACKAGE} .