mnemo_cards/mnemo_cards_telegram_bot/Dockerfile

68 lines
1.8 KiB
Docker
Raw Permalink Normal View History

2025-12-11 02:04:03 +00:00
# syntax=docker/dockerfile:1.7
# --- Build stage ------------------------------------------------------------
# Note: This Dockerfile should be built from the parent directory:
# docker build -f mnemo_cards_telegram_bot/Dockerfile -t mnemo_cards_telegram_bot .
FROM dart:stable-sdk AS build
WORKDIR /app
# Copy all local dependencies
COPY mnemo_cards_common /app/mnemo_cards_common
COPY mnemo_cards_common_backend /app/mnemo_cards_common_backend
COPY mnemo_cards_telegram_bot /app/mnemo_cards_telegram_bot
# Get dependencies (order matters due to path dependencies)
WORKDIR /app/mnemo_cards_common
RUN dart pub get
WORKDIR /app/mnemo_cards_common_backend
RUN dart pub get
WORKDIR /app/mnemo_cards_telegram_bot
RUN dart pub get
# Compile to native executable
RUN dart compile exe bin/main.dart -o /app/bot
# --- Runtime stage ----------------------------------------------------------
FROM debian:bookworm-slim AS runtime
WORKDIR /app
# Install runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
zip \
2025-12-11 17:59:30 +00:00
procps \
2025-12-11 02:04:03 +00:00
&& rm -rf /var/lib/apt/lists/*
# Copy bot binary
COPY --from=build /app/bot /app/bot
# Copy required files
COPY --from=build /app/mnemo_cards_telegram_bot/admins /app/admins
# Create required directories
RUN mkdir -p /app/backups /app/zips /app/apks && \
chmod -R 755 /app/backups /app/zips /app/apks
# Environment variables
ENV BACKEND_URL=https://api.mnemo-cards.online \
2025-12-11 17:49:15 +00:00
BOT_SHARE_DAILY_LIMIT=1 \
TELEGRAM_BOT_API_KEY= \
TELEGRAM_BOT_TOKEN=
2025-12-11 02:04:03 +00:00
# No EXPOSE needed - bot uses outbound connections only (polling)
2025-12-11 18:23:55 +00:00
# Signal for graceful shutdown
STOPSIGNAL SIGTERM
2025-12-11 02:04:03 +00:00
# Healthcheck - check if process is running
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \
CMD pgrep -f "/app/bot" > /dev/null || exit 1
# Start bot
CMD ["/app/bot"]