Files
firezone/rust/Dockerfile
Jamil fa57d66965 Publish Releases (#2344)
- rebuild and publish gateway and relay binaries to currently drafted
release
- re-tag current relay/gateway images and push to ghcr.io

Stacked on #2341 to prevent conflicts

Fixes #2223 
Fixes #2205 
Fixes #2202
Fixes #2239 

~~Still TODO: `arm64` images and binaries...~~ Edit: added via
`cross-rs`
2023-10-20 14:20:43 -07:00

53 lines
1.5 KiB
Docker

# Global args to use in build commands
ARG ALPINE_VERSION="3.18"
ARG PACKAGE
FROM lukemathwalker/cargo-chef:latest-rust-alpine${ALPINE_VERSION} as chef
# See https://github.com/LukeMathWalker/cargo-chef/issues/231.
COPY rust-toolchain.toml rust-toolchain.toml
RUN rustup show
WORKDIR /build
FROM chef as planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef as builder
COPY --from=planner /build/recipe.json .
RUN cargo chef cook --recipe-path recipe.json
COPY . .
ARG TARGET
ARG PACKAGE
RUN cargo build -p ${PACKAGE} $([ -v "${TARGET}" ] && "--target ${TARGET}")
# Minimal test image for GH actions
FROM alpine:${ALPINE_VERSION} AS debug
WORKDIR /bin
ENV RUST_BACKTRACE=1
COPY ./docker-init.sh .
ARG PACKAGE
# Needed only by gateway for masquerading
RUN \[ "${PACKAGE}" = "firezone-gateway" ] && apk add --no-cache iptables ip6tables || true
ARG TARGET
COPY --from=builder /build/target/${TARGET}/debug/${PACKAGE} .
ENTRYPOINT ["docker-init.sh"]
ENV PACKAGE=${PACKAGE}
CMD $PACKAGE
# Minimal platform-agnostic release image
FROM alpine:${ALPINE_VERSION} AS release
WORKDIR /bin
ENV RUST_BACKTRACE=1
COPY ./docker-init.sh .
ARG PACKAGE
# Needed only by gateway for masquerading
RUN \[ "${PACKAGE}" = "firezone-gateway" ] && apk add --no-cache iptables ip6tables || true
ARG TARGET
# Build first with `cross build --target ${TARGET} -p ${PACKAGE} --release && mv /target/${TARGET}/release/${PACKAGE} .`
COPY ${PACKAGE} .
ENTRYPOINT ["docker-init.sh"]
ENV PACKAGE=${PACKAGE}
CMD $PACKAGE