Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add server dockerfile #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
### ---------------------------------------------------
### How to build the image
## $ docker build -t bubbaloop:local .
### How to run the image
## $ docker run -it \
## # Define the name of the container
## --name bubbaloop-server \
## # Define the port mapping
## -p 3000:3000 \
## # Define the environment variables
## -e RUST_LOG=debug \
## # Map the local data folder to the container
## # --volume /tmp/data/:/tmp/data/ \
## # Define the image and tag
## bubbaloop:local
### ---------------------------------------------------

FROM rust:1.83.0-bookworm AS build

# create a new empty shell project
RUN USER=root cargo new --bin build-bubbaloop
WORKDIR /build-bubbaloop

# copy the manifests and build files
COPY ./Cargo.toml ./Cross.toml ./build.rs ./bubbaloop.ron ./

RUN \
# Install system dependencies
apt-get update \
&& apt-get install -y --no-install-recommends \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
# cache dependencies
&& cargo build --release \
# Clean up
&& apt-get clean \
## Remove apt cache
&& rm -rf /var/lib/apt/lists/* \
## Remove the dummy project (used to cache dependencies)
&& rm -rf src/ \
## Remove the dummy project's build artifacts
&& rm ./target/release/deps/bubbaloop*

# copy the source of the project
COPY ./src ./src

# compile the server binary
RUN cargo build --release --bin serve

# production image
FROM rust:1.83.0-slim-bookworm AS production

# define the workdir
WORKDIR /app/

RUN \
# Install system dependencies
apt-get update \
&& apt-get install -y --no-install-recommends \
# GStreamer required for video-stream handling
libgstreamer-plugins-base1.0 \
# Clean up
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# copy the build artifact from the build stage
COPY --from=build /build-bubbaloop/target/release/serve .

# Set entrypoint
ENTRYPOINT ["./serve"]
# Set the default command to run when starting the container
CMD ["-p", "3000"]