content: # build container
  # https://kerkour.com/rust-small-docker-image
  
  
  # FROM rust
  FROM rust:1.78-slim-bookworm as builder
  
  # RUN apt update && apt install -y librust-openssl-dev libssl-dev
  RUN apt update && apt install -y  musl musl-tools musl-dev clang llvm perl build-essential gcc-x86-64-linux-gnu  libssl-dev
  
  RUN rustup target add x86_64-unknown-linux-musl
  
  RUN update-ca-certificates
  
  ENV CC_x86_64_unknown_linux_musl=clang
  ENV RUST_BACKTRACE=full
  
  # Create appuser
  ENV USER=crabby
  ENV UID=10001
  
  RUN adduser \
      --disabled-password \
      --gecos "" \
      --home "/nonexistent" \
      --shell "/sbin/nologin" \
      --no-create-home \
      --uid "${UID}" \
      "${USER}"
  
  RUN mkdir /app
  
  COPY . /app/
  
  # RUN cd /app/ && cargo build --release
  RUN   --mount=type=cache,target=/app/target \
        --mount=type=cache,target=/usr/local/cargo/registry \
        cd /app/ && cargo build --target x86_64-unknown-linux-musl --release \
         && cp /app/target/x86_64-unknown-linux-musl/release/ilmateenistus_rs /app/ilmateenistus_rs
  
  
  # target container
  # FROM rust:1.77-slim-bookworm
  FROM alpine:latest
  # FROM debian:bookworm-slim
  
  RUN apk update \
      && apk add --no-cache ca-certificates tzdata \
      && rm -rf /var/cache/apk/*
  
  ENV TZ=Etc/UTC
  
  # Import from builder.
  COPY --from=builder /etc/passwd /etc/passwd
  COPY --from=builder /etc/group /etc/group
  
  RUN mkdir /app
  
  # Copy our build
  # COPY --from=builder /app/target/release/rustless /app/rustless
  COPY --from=builder /app/ilmateenistus_rs /app/ilmateenistus_rs
  COPY app-settings.toml /app/app-settings.toml
  
  WORKDIR /app
  
  # Use an unprivileged user.
  USER crabby:crabby
  
  CMD ["./ilmateenistus_rs"]
  EXPOSE 3000
  
  ENV APP_PORT="3000"
  ENV APP_DEBUG = "true"
  ENV APP_ADDRESS = "0.0.0.0"
  # ENV APP_SECURITY_KEY = "xxx"
  # ENV APP_APIKEY = "xxx"
  # ENV APP_WEATHER_URL = "https://www.ilmateenistus.ee/ilma_andmed/xml/forecast.php?lang=eng"
  
  