-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
61 lines (49 loc) · 1.84 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Use the rust build image from docker as our base
FROM rust:1.76-bookworm as base
# Set our working directory for the build
WORKDIR /usr/src/router
# Update our build image and install required packages
RUN set -eux; \
apt-get update; \
apt-get -y install \
clang \
libclang-dev \
cmake \
protobuf-compiler
RUN set -eux; \
mkdir -p ~/.ssh/; \
ssh-keyscan ssh.shipyard.rs >> ~/.ssh/known_hosts \
ssh-keyscan github.com >> ~/.ssh/known_hosts
ARG MOLD_VERSION=2.31.0
RUN set -eux; \
wget -qO /tmp/mold.tar.gz https://github.com/rui314/mold/releases/download/v${MOLD_VERSION}/mold-${MOLD_VERSION}-x86_64-linux.tar.gz; \
tar -xf /tmp/mold.tar.gz -C /usr/local --strip-components 1; \
rm /tmp/mold.tar.gz
FROM base as build
# Copy the router source to our build environment and build
COPY . .
RUN --mount=type=cache,target=/root/.rustup \
--mount=type=cache,target=/root/.cargo/registry \
--mount=type=cache,target=/root/.cargo/git \
--mount=type=cache,target=/usr/src/router/target \
--mount=type=ssh \
--mount=type=secret,id=shipyard-token \
set -eux; \
export CARGO_REGISTRIES_WAFFLEHACKS_TOKEN=$(cat /run/secrets/shipyard-token); \
export CARGO_REGISTRIES_WAFFLEHACKS_CREDENTIAL_PROVIDER=cargo:token; \
export CARGO_NET_GIT_FETCH_WITH_CLI=true; \
cargo build --release --bin router; \
mkdir -p /dist/config; \
mkdir /dist/schema; \
objcopy --compress-debug-sections ./target/release/router /dist/router
FROM debian:bookworm-slim
RUN set -eux; \
apt-get update; \
apt-get -y install ca-certificates; \
rm -rf /var/lib/apt/lists/*
# Copy in the required files from our build image
COPY --from=build --chown=root:root /dist /dist
WORKDIR /dist
ENV APOLLO_ROUTER_CONFIG_PATH="/dist/config.yaml"
# Default executable is the router
ENTRYPOINT ["/dist/router"]