# Flutter web build, served as static files by nginx.
#
# Dokploy builds this repo with its Dockerfile provider, so the image does the
# whole job: pull the Flutter SDK, compile the web bundle, hand the output to a
# web server. Nothing from the build stage survives into the final image but
# build/web.

FROM ghcr.io/cirruslabs/flutter:stable AS build

WORKDIR /app

# Dependencies resolve from the pubspec alone, so copying it first keeps the
# `pub get` layer cached across source-only changes.
COPY pubspec.yaml pubspec.lock ./
RUN flutter pub get

COPY . .
RUN flutter build web --release

FROM nginx:alpine

COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/build/web /usr/share/nginx/html

EXPOSE 80
