Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
69 lines
2.5 KiB
Docker
69 lines
2.5 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
|
|
# --- Build stage ------------------------------------------------------------
|
|
# Note: This Dockerfile should be built from the parent directory:
|
|
# docker build -f mnemo_cards_backend/Dockerfile -t mnemo_cards_backend .
|
|
|
|
FROM dart:stable-sdk AS build
|
|
WORKDIR /app
|
|
|
|
# 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
|
|
RUN dart pub get
|
|
|
|
WORKDIR /app/mnemo_cards_backend
|
|
RUN dart pub get
|
|
|
|
# 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 wget \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# App binary
|
|
COPY --from=build /app/server /app/server
|
|
|
|
# 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
|
|
|
|
# Writable dirs for isar/backups by default
|
|
RUN mkdir -p /app/isar /app/backups && \
|
|
chmod -R 755 /app/isar /app/backups
|
|
|
|
ENV PORT=3000 \
|
|
SERVER_ADDRESS=0.0.0.0 \
|
|
ISAR_DIR=/app/isar \
|
|
BACKUP_DIR=/app/backups \
|
|
WORK_DIR=/app \
|
|
DEBUG=false \
|
|
CERTS_PATH= \
|
|
DUAL_MODE=false \
|
|
ADMIN_IDS=
|
|
|
|
EXPOSE 3000
|
|
|
|
# Healthcheck - проверка доступности сервера
|
|
# Increased start-period to 90s to allow server initialization (Isar DB, cron jobs, etc.)
|
|
# Isar может долго инициализироваться при первом запуске или при большом объеме данных
|
|
# Используем 127.0.0.1 для healthcheck (внутри контейнера работает даже если сервер слушает на 0.0.0.0)
|
|
# Пробуем curl, если не работает - используем wget как fallback
|
|
HEALTHCHECK --interval=10s --timeout=10s --start-period=90s --retries=3 \
|
|
CMD curl -f -sS --max-time 8 --connect-timeout 3 http://127.0.0.1:${PORT:-3000}/health > /dev/null 2>&1 || \
|
|
wget --quiet --tries=1 --timeout=8 --spider http://127.0.0.1:${PORT:-3000}/health || exit 1
|
|
|
|
# Start server - все настройки читаются из environment variables
|
|
CMD ["/app/server"]
|