Skip to content

Commit

Permalink
chore(docker): add universal dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Jan 4, 2025
1 parent 38f5394 commit d0dca02
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions docker/server/Dockerfile → docker/universal/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# syntax=docker/dockerfile:1.2

# MARK: Builder
FROM rust:1.82.0-slim AS build
# TODO(RVT-4168): Compile libfdb from scratch for ARM
FROM --platform=linux/amd64 rust:1.82.0-bookworm AS builder

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
Expand All @@ -25,15 +26,15 @@ COPY . .
# included in the output because of cache mount)
RUN \
--mount=type=secret,id=netrc,target=/root/.netrc,mode=0600 \
--mount=type=cache,target=/usr/local/cargo/git,id=server-cargo-git \
--mount=type=cache,target=/usr/local/cargo/registry,id=server-cargo-registry \
--mount=type=cache,target=/app/target,id=server-target \
RUSTFLAGS="--cfg tokio_unstable" cargo build -vv --bin rivet-server --release && \
mv target/release/rivet-server /usr/bin/rivet-server && \
--mount=type=cache,target=/usr/local/cargo/git,id=univseral-cargo-git \
--mount=type=cache,target=/usr/local/cargo/registry,id=univseral-cargo-registry \
--mount=type=cache,target=/app/target,id=univseral-target \
RUSTFLAGS="--cfg tokio_unstable" cargo build -vv --bin rivet-server --bin rivet-client --bin rivet-isolate-v8-runner --bin rivet-container-runner && \
mv target/debug/{rivet-server,rivet-client,rivet-isolate-v8-runner,rivet-container-runner} /app/dist/
mkdir /etc/rivet-server

# MARK: Full
FROM debian:12.1-slim AS full
# MARK: Server (Full)
FROM debian:12.1-slim AS server-full

# - Install curl for health checks
# - Install go-migrate for running migrations
Expand All @@ -59,8 +60,8 @@ COPY --from=build /usr/bin/rivet-server /usr/bin/rivet-server

CMD ["/usr/bin/rivet-server"]

# MARK: Slim
FROM debian:12.1-slim AS slim
# MARK: Server (Slim)
FROM debian:12.1-slim AS server-slim

RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && \
apt-get install -y --no-install-recommends ca-certificates openssl && \
Expand All @@ -70,3 +71,25 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && \
COPY --from=build /usr/bin/rivet-server /usr/bin/rivet-server

CMD ["/usr/bin/rivet-server"]

# MARK: Runner base
FROM --platform=linux/amd64 debian:12-slim AS base-runner
RUN DEBIAN_FRONTEND=noninteractive apt-get update -y && \
apt-get install -y --no-install-recommends ca-certificates curl && \
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.1.60/libfdb_c.x86_64.so"

# MARK: Runner (Full)
FROM --platform=linux/amd64 runner-base AS full-runner
COPY --from=builder /app/dist/rivet-client /app/dist/rivet-isolate-v8-runner /app/dist/rivet-container-runner /usr/local/bin/
ENTRYPOINT ["rivet-client"]

# MARK: Runner (Isolate V8)
FROM --platform=linux/amd64 runner-base AS isolate-v8-runner
COPY --from=builder /app/dist/rivet-isolate-v8-runner /usr/local/bin/
ENTRYPOINT ["rivet-client"]

# MARK: Runner (Container)
FROM --platform=linux/amd64 runner-base AS container-runner
COPY --from=builder /app/dist/rivet-container-runner /usr/local/bin/
ENTRYPOINT ["rivet-client"]

0 comments on commit d0dca02

Please sign in to comment.