-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Package tunnelbroker into a docker image https://linear.app/comm/issue/ENG-4103 Test Plan: ``` ./services/tunnelbroker/make_docker_image.sh ``` or ``` # build all service images cd services/ && docker-compose build ``` Reviewers: varun, bartek, ashoat Reviewed By: varun Subscribers: michal, tomek Differential Revision: https://phab.comm.dev/D8230
- Loading branch information
1 parent
c9e4b84
commit ea5beb1
Showing
3 changed files
with
48 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,36 @@ | ||
FROM commapp/services-base:1.3.2 | ||
FROM rust:1.70-bullseye as builder | ||
|
||
ENV PATH=/root/.cargo/bin:$PATH | ||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
build-essential cmake git libgtest-dev libssl-dev zlib1g-dev \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& mkdir -p /home/root/app/ | ||
|
||
ARG COMM_TEST_SERVICES | ||
ARG COMM_SERVICES_SANDBOX | ||
WORKDIR /home/root/app | ||
|
||
ENV COMM_TEST_SERVICES=${COMM_TEST_SERVICES} | ||
ENV COMM_SERVICES_SANDBOX=${COMM_SERVICES_SANDBOX} | ||
# Install more recent version of protobuf, must be ran as root | ||
COPY scripts/install_protobuf.sh ../../scripts/install_protobuf.sh | ||
RUN ../../scripts/install_protobuf.sh | ||
|
||
# Install Curl | ||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y curl | ||
COPY services/tunnelbroker . | ||
|
||
# Install Rust | ||
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y | ||
COPY shared/protos ../../shared/protos | ||
COPY shared/tunnelbroker_messages ../../shared/tunnelbroker_messages | ||
|
||
# Copying of the installation scripts | ||
WORKDIR /transferred/services/tunnelbroker/docker | ||
COPY services/tunnelbroker/docker . | ||
RUN cargo install --path . | ||
|
||
# Copying of the shared code | ||
WORKDIR /transferred | ||
COPY services/lib/src/ services/lib/src/ | ||
COPY shared/ shared/ | ||
FROM debian:bullseye-slim as runner | ||
|
||
# Copying of the Tunnelbroker code | ||
WORKDIR /transferred/services/tunnelbroker | ||
COPY services/tunnelbroker/ . | ||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
ca-certificates \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& useradd -m comm \ | ||
&& mkdir -p /home/comm/app/tunnelbroker | ||
|
||
# Build Rust by Cargo | ||
WORKDIR /transferred/services/tunnelbroker | ||
RUN cargo build --release | ||
WORKDIR /home/comm/app/tunnelbroker | ||
|
||
CMD if [ "$COMM_TEST_SERVICES" -eq 1 ];\ | ||
then\ | ||
cargo test;\ | ||
else\ | ||
cargo run;\ | ||
fi | ||
COPY --from=builder /usr/local/cargo/bin/tunnelbroker \ | ||
/usr/local/bin/tunnelbroker | ||
|
||
USER comm | ||
|
||
CMD ["tunnelbroker"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This file exists to make a smaller docker context, so that building it is | ||
# significantly faster and requires less system resources | ||
|
||
SCRIPT_DIR="$(cd "$(dirname "$0")" || exit 1; pwd -P)" | ||
BUILD_DIR="${SCRIPT_DIR}/target/oci_image" | ||
|
||
rm -rf "$BUILD_DIR" | ||
mkdir -p "$BUILD_DIR"/{scripts,shared,services/tunnelbroker} | ||
|
||
cp "$SCRIPT_DIR/../../scripts/install_protobuf.sh" "$BUILD_DIR"/scripts | ||
cp -r "${SCRIPT_DIR}/../../shared/protos" "$BUILD_DIR"/shared/protos | ||
cp -r "${SCRIPT_DIR}/../../shared/tunnelbroker_messages" \ | ||
"$BUILD_DIR"/shared/tunnelbroker_messages | ||
cp -r "${SCRIPT_DIR}"/{Cargo.toml,Cargo.lock,build.rs,src} \ | ||
"$BUILD_DIR"/services/tunnelbroker/ | ||
|
||
docker build -f "${SCRIPT_DIR}/Dockerfile" "$BUILD_DIR" |