mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
chore(rust): remove dev stage in Dockerfile (#8688)
We don't ever use the `dev` stage within our Rust Dockerfile that actually builds the binaries within the container. In CI, we build the binaries on the host and then copy them in. During local development, I always do the same because it is much faster to iterate that way. Long story short: We don't need this stage within our Dockerfile and it causes confusion when people try to use `docker compose build`. If somebody really wanted to do that, they need to follow the instructions in the Dockerfile and build the binary first. Related: #8687 --------- Signed-off-by: Thomas Eizinger <thomas@eizinger.io> Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
This commit is contained in:
@@ -327,7 +327,7 @@ services:
|
||||
FIREZONE_API_URL: ws://api:8081
|
||||
init: true
|
||||
build:
|
||||
target: dev
|
||||
target: debug
|
||||
context: rust
|
||||
dockerfile: Dockerfile
|
||||
cache_from:
|
||||
@@ -359,7 +359,7 @@ services:
|
||||
FIREZONE_ID: 4694E56C-7643-4A15-9DF3-638E5B05F570
|
||||
init: true
|
||||
build:
|
||||
target: dev
|
||||
target: debug
|
||||
context: rust
|
||||
dockerfile: Dockerfile
|
||||
cache_from:
|
||||
@@ -446,7 +446,7 @@ services:
|
||||
FIREZONE_API_URL: ws://api:8081
|
||||
OTLP_GRPC_ENDPOINT: otel:4317
|
||||
build:
|
||||
target: dev
|
||||
target: debug
|
||||
context: rust
|
||||
dockerfile: Dockerfile
|
||||
cache_from:
|
||||
@@ -487,7 +487,7 @@ services:
|
||||
FIREZONE_API_URL: ws://api:8081
|
||||
OTLP_GRPC_ENDPOINT: otel:4317
|
||||
build:
|
||||
target: dev
|
||||
target: debug
|
||||
context: rust
|
||||
dockerfile: Dockerfile
|
||||
cache_from:
|
||||
|
||||
@@ -1,49 +1,7 @@
|
||||
# Keep synced with `rust-toolchain.toml`
|
||||
ARG RUST_VERSION="1.86.0"
|
||||
ARG ALPINE_VERSION="3.20"
|
||||
ARG CARGO_CHEF_VERSION="0.1.67"
|
||||
|
||||
ARG PACKAGE
|
||||
|
||||
# This image is used to prepare Cargo Chef which is used to cache dependencies
|
||||
# Keep the Rust version synced with `rust-toolchain.toml`
|
||||
FROM rust:${RUST_VERSION}-alpine${ALPINE_VERSION} AS chef
|
||||
|
||||
ARG CARGO_CHEF_VERSION
|
||||
RUN set -xe \
|
||||
&& apk add --no-cache musl-dev \
|
||||
&& cargo install cargo-chef --locked --version=${CARGO_CHEF_VERSION} \
|
||||
&& rm -rf $CARGO_HOME/registry/
|
||||
|
||||
## See https://github.com/LukeMathWalker/cargo-chef/issues/231.
|
||||
COPY rust-toolchain.toml rust-toolchain.toml
|
||||
|
||||
RUN rustup show
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
# Create a cache recipe for dependencies, which allows
|
||||
# to leverage Docker layer caching in a later build stage
|
||||
FROM chef AS planner
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN cargo chef prepare --recipe-path recipe.json
|
||||
|
||||
# Build dependencies and application application
|
||||
FROM chef AS builder
|
||||
|
||||
COPY --from=planner /build/recipe.json .
|
||||
|
||||
ARG PACKAGE
|
||||
RUN set -xe \
|
||||
&& cargo chef cook --recipe-path recipe.json --bin ${PACKAGE}
|
||||
|
||||
COPY . .
|
||||
|
||||
ARG TARGET
|
||||
RUN cargo build -p ${PACKAGE} $([ -n "${TARGET}" ] && "--target ${TARGET}")
|
||||
|
||||
# Base image which is used to run the application binary
|
||||
FROM alpine:${ALPINE_VERSION} AS runtime_base
|
||||
|
||||
@@ -85,27 +43,18 @@ ENV PACKAGE=${PACKAGE}
|
||||
|
||||
CMD ${PACKAGE}
|
||||
|
||||
# used as a base for dev and test
|
||||
FROM runtime AS test
|
||||
# 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
|
||||
|
||||
# used for local development
|
||||
FROM test AS dev
|
||||
ARG TARGET
|
||||
ARG PACKAGE
|
||||
COPY --from=builder /build/target/${TARGET}/debug/${PACKAGE} .
|
||||
|
||||
# Build an image for GitHub Actions which includes debug asserts and more test utilities
|
||||
FROM test AS debug
|
||||
|
||||
## Build first with `cross build --target ${TARGET} -p ${PACKAGE} && mv /target/${TARGET}/release/${PACKAGE} .`
|
||||
## 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 `cross build --target ${TARGET} -p ${PACKAGE} --release && mv /target/${TARGET}/release/${PACKAGE} .`
|
||||
## Build first with `cargo build --target ${TARGET} -p ${PACKAGE} --release && mv /target/${TARGET}/release/${PACKAGE} .`
|
||||
ARG PACKAGE
|
||||
COPY ${PACKAGE} .
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
# Meant to be used with docker-compose.yml
|
||||
services:
|
||||
client:
|
||||
build:
|
||||
target: test
|
||||
volumes:
|
||||
- ./rust/target/x86_64-unknown-linux-musl/debug/firezone-headless-client:/bin/firezone-headless-client
|
||||
|
||||
download.httpbin:
|
||||
build:
|
||||
target: test
|
||||
volumes:
|
||||
- ./rust/target/x86_64-unknown-linux-musl/debug/http-test-server:/bin/http-test-server
|
||||
|
||||
gateway:
|
||||
build:
|
||||
target: test
|
||||
volumes:
|
||||
- ./rust/target/x86_64-unknown-linux-musl/debug/firezone-gateway:/bin/firezone-gateway
|
||||
|
||||
relay-1:
|
||||
build:
|
||||
target: test
|
||||
volumes:
|
||||
- ./rust/target/x86_64-unknown-linux-musl/debug/firezone-relay:/bin/firezone-relay
|
||||
|
||||
relay-2:
|
||||
build:
|
||||
target: test
|
||||
volumes:
|
||||
- ./rust/target/x86_64-unknown-linux-musl/debug/firezone-relay:/bin/firezone-relay
|
||||
@@ -1,5 +1,4 @@
|
||||
[toolchain]
|
||||
# Keep synced with `Dockerfile`
|
||||
channel = "1.86.0"
|
||||
components = ["rust-src", "rust-analyzer", "clippy"]
|
||||
targets = ["x86_64-unknown-linux-musl"]
|
||||
|
||||
Reference in New Issue
Block a user