FROM rust:1.78.0-slim-bookworm AS base

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Add our helper tools
COPY --chmod=777 docker/tools /tools
ENV PATH="/tools:${PATH}"
ENV LANG="C.UTF-8"

# Install tools that are useful during development.
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
    && apt-get -y dist-upgrade \
    && apt-get install -y \
        git \
        less \
        libpq-dev \
        procps \
    && apt-cleanup.sh

# Create a user for our application.
RUN useradd --create-home --shell /bin/bash appuser
WORKDIR /workspace
USER appuser

RUN cargo install \
        cargo-watch \
    && rustup component add rustfmt

ENTRYPOINT ["cargo", "watch"]
