# Use Flutter with Dart 3.8+ (Flutter 3.22+)
FROM ghcr.io/cirruslabs/flutter:3.32.5 AS build

WORKDIR /app

# Copy all files into the build context
COPY . .

# Install dependencies
RUN flutter pub get

# Build for the web
RUN flutter build web --release

# Use a minimal web server to serve the built app
FROM nginx:alpine

# Copy built web assets into nginx's web root
COPY --from=build /app/build/web /usr/share/nginx/html

# Optional: remove default nginx config if needed
# RUN rm /etc/nginx/conf.d/default.conf

# Expose port 80
EXPOSE 80

# Start NGINX
CMD ["nginx", "-g", "daemon off;"]
