2025-12-10 23:13:33 +00:00
|
|
|
# syntax=docker/dockerfile:1.7
|
|
|
|
|
|
|
|
|
|
# --- Build stage ------------------------------------------------------------
|
2025-12-11 00:34:46 +00:00
|
|
|
# Note: This Dockerfile should be built from the parent directory:
|
|
|
|
|
# docker build -f mnemo_cards_backend/Dockerfile -t mnemo_cards_backend .
|
|
|
|
|
|
2025-12-10 23:13:33 +00:00
|
|
|
FROM dart:stable-sdk AS build
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2025-12-11 00:34:46 +00:00
|
|
|
# Copy all sources at once (simpler and more efficient)
|
|
|
|
|
COPY mnemo_cards_common /app/mnemo_cards_common
|
|
|
|
|
COPY mnemo_cards_common_backend /app/mnemo_cards_common_backend
|
|
|
|
|
COPY mnemo_cards_backend /app/mnemo_cards_backend
|
|
|
|
|
|
|
|
|
|
# Get dependencies (path dependencies will resolve correctly)
|
|
|
|
|
WORKDIR /app/mnemo_cards_common
|
|
|
|
|
RUN dart pub get
|
|
|
|
|
|
|
|
|
|
WORKDIR /app/mnemo_cards_common_backend
|
2025-12-10 23:13:33 +00:00
|
|
|
RUN dart pub get
|
|
|
|
|
|
2025-12-11 00:34:46 +00:00
|
|
|
WORKDIR /app/mnemo_cards_backend
|
|
|
|
|
RUN dart pub get
|
2025-12-10 23:13:33 +00:00
|
|
|
|
|
|
|
|
# Compile to native executable
|
|
|
|
|
RUN dart compile exe lib/main.dart -o /app/server
|
|
|
|
|
|
|
|
|
|
# --- Runtime stage ----------------------------------------------------------
|
|
|
|
|
FROM debian:bookworm-slim AS runtime
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
RUN apt-get update \
|
|
|
|
|
&& apt-get install -y --no-install-recommends ca-certificates openssl curl \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
# App binary
|
|
|
|
|
COPY --from=build /app/server /app/server
|
|
|
|
|
|
2025-12-11 00:34:46 +00:00
|
|
|
# Static/assets needed at runtime
|
|
|
|
|
COPY --from=build /app/mnemo_cards_backend/public /app/public
|
|
|
|
|
COPY --from=build /app/mnemo_cards_backend/data /app/data
|
2025-12-10 23:13:33 +00:00
|
|
|
|
|
|
|
|
# Writable dirs for isar/backups by default
|
2025-12-11 00:34:46 +00:00
|
|
|
RUN mkdir -p /app/isar /app/backups && \
|
|
|
|
|
chmod -R 755 /app/isar /app/backups
|
2025-12-10 23:13:33 +00:00
|
|
|
|
|
|
|
|
ENV PORT=8081 \
|
|
|
|
|
ADDRESS=0.0.0.0 \
|
|
|
|
|
ISAR_DIR=/app/isar \
|
|
|
|
|
BACKUP_DIR=/app/backups \
|
2025-12-11 00:34:46 +00:00
|
|
|
APP_WORKDIR=/app
|
2025-12-11 00:23:59 +00:00
|
|
|
|
2025-12-10 23:13:33 +00:00
|
|
|
EXPOSE 8081
|
|
|
|
|
|
2025-12-11 00:34:46 +00:00
|
|
|
# Healthcheck - use existing public endpoint
|
2025-12-10 23:13:33 +00:00
|
|
|
HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=5 \
|
2025-12-11 00:34:46 +00:00
|
|
|
CMD curl -sf http://127.0.0.1:8081/api/v2/subscriptions/plans || exit 1
|
2025-12-10 23:13:33 +00:00
|
|
|
|
2025-12-11 00:34:46 +00:00
|
|
|
# Use environment variables with fallbacks
|
2025-12-10 23:13:33 +00:00
|
|
|
CMD ["/app/server", "-a", "0.0.0.0", "-p", "8081", "--isar", "/app/isar", "--backup", "/app/backups", "--workdir", "/app"]
|