Running it all in Docker
We are now at the stage where we can run our entire application in Docker. This enables us to have multiple workers pulling from the same Redis queue. First, we need to define the Dockerfile
for the build of our worker/server image. We are going to have a distroless build for the Docker build with the following code:
FROM rust:1.62.1 as build ENV PKG_CONFIG_ALLOW_CROSS=1 WORKDIR /app COPY . . cargo build --release FROM gcr.io/distroless/cc-debian10 COPY --from=build /app/target/release/task_queue /usr/local/bin/task_queue EXPOSE 3000 ENTRYPOINT ["task_queue"]
This distroless build should not be a surprise at this point in the book. We are merely compiling the application and then copying the static binary into the distroless image. Before we run the build in any way, we must ensure that we do not copy over excessive files from the target
directory into our Docker build with the following code in the .
dockerignore
file:
./target .github...