FROM nginx:alpine

# Setting the working directory inside the container
WORKDIR /usr/share/nginx/html

# Copying the zip file containing the Flutter web build into the container
COPY build.zip /tmp/build.zip

# Installing unzip, extracting the build files with overwrite, and cleaning up
RUN apk add --no-cache unzip && \
    unzip -o /tmp/build.zip -d /usr/share/nginx/html && \
    rm /tmp/build.zip && \
    chown -R nginx:nginx /usr/share/nginx/html

# Copying a custom Nginx configuration to serve the Flutter app
# It looks for 'nginx.conf' in the same directory (the build context)
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Exposing port 80 (inside the container)
EXPOSE 80

# Starting Nginx in the foreground
CMD ["nginx", "-g", "daemon off;"]