# Dockerfile - Problem 16.6: the Laundry Counter in a container, for hosts that run containers.
# Build from the Chapter16 folder:   docker build -f deploy/Dockerfile -t laundry-counter .
# Run:  docker run -p 8080:8080 -v laundry-data:/data -v laundry-keys:/keys laundry-counter
# (Not run on the machine where this book was written: it has no Docker. See VERIFIED.md.)
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY aspnet/LaundryCounter/ ./
RUN dotnet publish -c Release -o /app

FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
COPY --from=build /app ./
COPY data/csv /seed/csv
# First start: copy the sample CSV files into the volume; later starts keep the saved data.
ENV Laundry__DataDir=/data Laundry__KeysDir=/keys ASPNETCORE_URLS=http://+:8080
EXPOSE 8080
ENTRYPOINT ["sh", "-c", "mkdir -p /data && [ -d /data/csv ] || cp -r /seed/csv /data/; exec dotnet LaundryCounter.dll"]
