# Build stage
FROM cirrusci/flutter:latest AS builder

WORKDIR /app
COPY pubspec.* ./
COPY lib ./lib
COPY web ./web
COPY assets ./assets

RUN flutter pub get
RUN flutter build web --release

# Serve stage
FROM nginx:alpine

COPY --from=builder /app/build/web /usr/share/nginx/html

COPY nginx.conf /etc/nginx/nginx.conf

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]