From 11863f4aceb4de16c73866b0c5e27c518c8d8941 Mon Sep 17 00:00:00 2001 From: Zicklag Date: Wed, 3 May 2023 16:02:01 -0500 Subject: [PATCH] refactor: slim down the matchmaker docker image. - Make the server doesn't run as root. - Remove old Bevy dependencies. --- Dockerfile | 26 +++++++++----------------- rust-toolchain | 2 +- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 42c804e978..a01839f1d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,15 +4,7 @@ # Bones Matchmaker Docker image # -FROM rust:1.64-slim as builder - -RUN apt-get update && \ - apt-get install -y \ - curl \ - pkg-config \ - libudev-dev \ - libasound2-dev && \ - rm -rf /var/lib/apt/lists/* +FROM rust:1.69.0-slim as builder WORKDIR /usr/src/bones COPY . . @@ -20,15 +12,15 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry/cache \ --mount=type=cache,target=/usr/local/cargo/registry/index \ --mount=type=cache,target=/usr/local/cargo/git/db \ --mount=type=cache,target=/usr/src/bones/target \ - cargo build -p bones_matchmaker + # Uncomment if building with behind custom CA cert + --mount=type=bind,src=./cacert.gitignore.crt,target=/etc/ssl/certs/ca-certificates.crt \ + cargo build --release -p bones_matchmaker RUN --mount=type=cache,target=/usr/src/bones/target \ - cp target/debug/bones_matchmaker /usr/local/bin/bones_matchmaker + cp target/release/bones_matchmaker /usr/local/bin/bones_matchmaker -# TODO: Slim down this container. We need to try and strip all unneeded deps from Bevy for the -# matchmaker. -FROM debian:bullseye -RUN apt-get update && apt-get install -y libasound2 && rm -rf /var/lib/apt/lists/* -COPY --from=builder /usr/local/bin/bones_matchmaker /usr/local/bin/bones_matchmaker +FROM ubuntu:23.04 +USER 1001 +COPY --from=builder /usr/local/bin/bones_matchmaker /bones_matchmaker EXPOSE 8943/udp -ENTRYPOINT /usr/local/bin/bones_matchmaker +CMD /bones_matchmaker diff --git a/rust-toolchain b/rust-toolchain index 9ebd7af328..4934985655 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.67 +1.69.0