···11-# The following Dockerfile code has been taken from the uv documentation
22-# and adapted to suit my program: https://docs.astral.sh/uv/guides/integration/docker/
11+# syntax=docker/dockerfile:1
3244-# Use a Python image with uv pre-installed
55-FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
33+# Comments are provided throughout this file to help you get started.
44+# If you need more help, visit the Dockerfile reference guide at
55+# https://docs.docker.com/reference/dockerfile/
66+77+################################################################################
88+# Create a stage for building the application.
6977-# Install the project into `/app`
1010+ARG RUST_VERSION=1.85.0
1111+ARG APP_NAME=audquotes
1212+FROM rust:${RUST_VERSION}-bullseye AS build
813WORKDIR /app
9141010-# Enable bytecode compilation
1111-ENV UV_COMPILE_BYTECODE=1
1212-1313-# Copy from the cache instead of linking since it's a mounted volume
1414-ENV UV_LINK_MODE=copy
1515+# Build the application.
1616+# Leverage a cache mount to /usr/local/cargo/registry/
1717+# for downloaded dependencies and a cache mount to /app/target/ for
1818+# compiled dependencies which will speed up subsequent builds.
1919+# Leverage a bind mount to the src directory to avoid having to copy the
2020+# source code into the container. Once built, copy the executable to an
2121+# output directory before the cache mounted /app/target is unmounted.
2222+RUN --mount=type=bind,source=src,target=src \
2323+ --mount=type=bind,source=quotes,target=quotes \
2424+ --mount=type=bind,source=Cargo.toml,target=Cargo.toml \
2525+ --mount=type=bind,source=Cargo.lock,target=Cargo.lock \
2626+ --mount=type=cache,target=/app/target/ \
2727+ --mount=type=cache,target=/usr/local/cargo/registry/ \
2828+ <<EOF
2929+set -e
3030+cargo build --locked --release
3131+cp ./target/release/audquotes /bin/server
3232+cp -r ./quotes /bin/quotes
3333+EOF
15341616-# Install the project's dependencies using the lockfile and settings
1717-RUN --mount=type=cache,target=/root/.cache/uv \
1818- --mount=type=bind,source=uv.lock,target=uv.lock \
1919- --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
2020- uv sync --frozen --no-install-project --no-dev
3535+################################################################################
3636+# Create a new stage for running the application that contains the minimal
3737+# runtime dependencies for the application. This often uses a different base
3838+# image from the build stage where the necessary files are copied from the build
3939+# stage.
4040+#
4141+# The example below uses the debian bullseye image as the foundation for running the app.
4242+# By specifying the "bullseye-slim" tag, it will also use whatever happens to be the
4343+# most recent version of that tag when you build your Dockerfile. If
4444+# reproducibility is important, consider using a digest
4545+# (e.g., debian@sha256:ac707220fbd7b67fc19b112cee8170b41a9e97f703f588b2cdbbcdcecdd8af57).
4646+FROM debian:bullseye AS final
21472222-# Then, add the rest of the project source code and install it
2323-# Installing separately from its dependencies allows optimal layer caching
2424-ADD . /app
2525-RUN --mount=type=cache,target=/root/.cache/uv \
2626- uv sync --frozen --no-dev
4848+RUN apt update && apt upgrade -y && apt install -y openssl ca-certificates
27492828-# Place executables in the environment at the front of the path
2929-ENV PATH="/app/.venv/bin:$PATH"
5050+# Copy the executable from the "build" stage.
5151+COPY --from=build /bin/server /bin/
5252+COPY --from=build /bin/quotes /quotes
30533131-# Make port 8080 available to the world outside this container
5454+# Expose the port that the application listens on.
3255EXPOSE 8080
33563434-# Reset the entrypoint, don't invoke `uv`
3535-ENTRYPOINT []
3636-CMD ["uv", "run", "schedule_script.py", "--no-simulation-mode"]
5757+# What the container should run when it is started.
5858+CMD ["/bin/server"]
+36
Dockerfile-python
···11+# The following Dockerfile code has been taken from the uv documentation
22+# and adapted to suit my program: https://docs.astral.sh/uv/guides/integration/docker/
33+44+# Use a Python image with uv pre-installed
55+FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
66+77+# Install the project into `/app`
88+WORKDIR /app
99+1010+# Enable bytecode compilation
1111+ENV UV_COMPILE_BYTECODE=1
1212+1313+# Copy from the cache instead of linking since it's a mounted volume
1414+ENV UV_LINK_MODE=copy
1515+1616+# Install the project's dependencies using the lockfile and settings
1717+RUN --mount=type=cache,target=/root/.cache/uv \
1818+ --mount=type=bind,source=uv.lock,target=uv.lock \
1919+ --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
2020+ uv sync --frozen --no-install-project --no-dev
2121+2222+# Then, add the rest of the project source code and install it
2323+# Installing separately from its dependencies allows optimal layer caching
2424+ADD . /app
2525+RUN --mount=type=cache,target=/root/.cache/uv \
2626+ uv sync --frozen --no-dev
2727+2828+# Place executables in the environment at the front of the path
2929+ENV PATH="/app/.venv/bin:$PATH"
3030+3131+# Make port 8080 available to the world outside this container
3232+EXPOSE 8080
3333+3434+# Reset the entrypoint, don't invoke `uv`
3535+ENTRYPOINT []
3636+CMD ["uv", "run", "schedule_script.py", "--no-simulation-mode"]