Files
tg-bot-template/apps/bot/Dockerfile
Yuu Ottosoka 71365836d3 feat: add bot and api services with config, logger and database packages
- Add bot service with telegram integration and webhook/polling modes
- Add api service with hono, swagger and zod-openapi
- Create config package for environment variable management
- Create logger package for colored console logging
- Create database package with prisma integration
- Remove next.js web and docs apps
- Update turbo.json for new services
- Add dockerfiles and gitea workflows for deployment
2025-07-08 19:46:08 +03:00

59 lines
1.4 KiB
Docker

FROM node:lts-alpine AS base
# Install system dependencies needed for canvas and other native modules
RUN apk add --no-cache \
python3 \
make \
g++ \
cairo-dev \
jpeg-dev \
pango-dev \
musl-dev \
giflib-dev \
pixman-dev \
pangomm-dev \
libjpeg-turbo-dev \
freetype-dev
# Install turbo globally
RUN npm install -g turbo
FROM base AS pruner
WORKDIR /app
COPY . .
RUN turbo prune bot --docker
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
WORKDIR /app
# First install the dependencies (this is done before copying the source code to better leverage Docker layer caching)
COPY .gitignore .gitignore
COPY --from=pruner /app/out/json/ .
COPY --from=pruner /app/out/package-lock.json ./package-lock.json
RUN npm ci
# Build the project
COPY --from=pruner /app/out/full/ .
RUN turbo run build --filter=bot...
FROM base AS runner
WORKDIR /app
# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 bot
USER bot
COPY --from=installer --chown=bot:nodejs /app/apps/bot/dist ./dist
COPY --from=installer --chown=bot:nodejs /app/apps/bot/package.json ./package.json
# Copy node_modules from installer stage
COPY --from=installer --chown=bot:nodejs /app/node_modules ./node_modules
COPY --from=installer --chown=bot:nodejs /app/apps/bot/node_modules ./apps/bot/node_modules
# Expose port
EXPOSE 3000
CMD ["npm", "start"]