mnemo_cards/mnemo_cards_web_v2/Dockerfile

56 lines
1.8 KiB
Docker
Raw Permalink Normal View History

2025-12-11 00:38:08 +00:00
# syntax=docker/dockerfile:1.7
# --- Build stage ------------------------------------------------------------
2025-12-11 00:51:18 +00:00
# Note: This Dockerfile should be built from the parent directory:
# docker build -f mnemo_cards_web_v2/Dockerfile -t mnemo_cards_web .
2025-12-11 00:54:32 +00:00
FROM ghcr.io/cirruslabs/flutter:3.35.5 AS build
2025-12-11 00:38:08 +00:00
WORKDIR /app
2025-12-11 00:51:18 +00:00
# Copy all local dependencies
COPY mnemo_cards_common /app/mnemo_cards_common
COPY mnemo_cards_frontend_common /app/mnemo_cards_frontend_common
COPY chat/mnemo_cards_chat /app/chat/mnemo_cards_chat
COPY games/packages/bridge_core /app/games/packages/bridge_core
COPY games/packages/payloads_shared /app/games/packages/payloads_shared
COPY games/packages/game_tests /app/games/packages/game_tests
# Copy web app sources
COPY mnemo_cards_web_v2 /app/mnemo_cards_web_v2
2025-12-11 00:38:08 +00:00
2025-12-11 00:51:18 +00:00
WORKDIR /app/mnemo_cards_web_v2
# Get dependencies
RUN flutter pub get
2025-12-11 00:38:08 +00:00
2025-12-11 00:51:18 +00:00
# Build arg for API URL
ARG API_BASE_URL=https://api.mnemo-cards.online
2025-12-11 00:38:08 +00:00
2025-12-11 00:51:18 +00:00
# Build web app
2026-01-08 20:13:56 +00:00
RUN flutter build web --release --no-source-maps \
2025-12-11 00:38:08 +00:00
--dart-define=API_BASE_URL=${API_BASE_URL}
2025-12-11 01:41:36 +00:00
# Verify build output
RUN ls -la build/web/ && test -f build/web/index.html || (echo "ERROR: index.html not found!" && exit 1)
2025-12-11 00:38:08 +00:00
# --- Runtime stage ----------------------------------------------------------
2025-12-11 01:10:32 +00:00
FROM nginx:1.27-alpine AS runtime
2025-12-11 01:41:36 +00:00
# Install wget for healthcheck
RUN apk add --no-cache wget
2025-12-11 00:51:18 +00:00
# Copy nginx config
2025-12-11 01:10:32 +00:00
COPY mnemo_cards_web_v2/nginx.conf /etc/nginx/conf.d/default.conf
2025-12-11 00:38:08 +00:00
2025-12-11 00:51:18 +00:00
# Copy built web app
2025-12-11 01:10:32 +00:00
COPY --from=build /app/mnemo_cards_web_v2/build/web/ /usr/share/nginx/html/
2025-12-11 00:38:08 +00:00
2025-12-11 01:41:36 +00:00
# Verify files were copied
RUN ls -la /usr/share/nginx/html/ && test -f /usr/share/nginx/html/index.html || (echo "ERROR: index.html not copied!" && exit 1)
2025-12-11 00:38:08 +00:00
EXPOSE 80
2025-12-11 01:41:36 +00:00
# Healthcheck
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1/ || exit 1