fix build web with docker compose
Some checks failed
Build & Deploy Web & Bot / Build and Push to Docker Hub (push) Has been cancelled
Build & Deploy Web & Bot / Deploy to VPS (push) Has been cancelled

This commit is contained in:
vchikalkin 2025-07-02 13:15:00 +03:00
parent ad4abdcb28
commit ecc7b44d6d
15 changed files with 685 additions and 322 deletions

6
apps/bot/.dockerignore Normal file
View File

@ -0,0 +1,6 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.git

View File

@ -1,27 +1,36 @@
FROM node:20-alpine AS base # This Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
# Make sure you update both files!
FROM base AS builder FROM node:alpine AS builder
RUN apk update RUN corepack enable && corepack prepare pnpm@8.9.0 --activate
ENV PNPM_HOME=/usr/local/bin
RUN apk add --no-cache libc6-compat RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app WORKDIR /app
RUN corepack enable && corepack prepare yarn@4.2.2 --activate RUN pnpm add -g turbo@1.12.4 dotenv-cli
RUN yarn global add turbo
COPY . . COPY . .
RUN turbo prune bot --docker RUN turbo prune --scope=bot --docker
FROM base AS installer FROM node:alpine AS installer
RUN apk update RUN corepack enable && corepack prepare pnpm@latest --activate
ENV PNPM_HOME=/usr/local/bin
RUN apk add --no-cache libc6-compat RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app WORKDIR /app
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ . COPY --from=builder /app/out/json/ .
RUN yarn install --immutable COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
RUN pnpm install
COPY --from=builder /app/out/full/ . COPY --from=builder /app/out/full/ .
RUN yarn turbo build COPY turbo.json turbo.json
RUN pnpm dotenv -e .env turbo run build --filter=bot...
FROM base AS runner FROM node:alpine AS runner
WORKDIR /app WORKDIR /app
RUN addgroup --system --gid 1001 nodejs RUN addgroup --system --gid 1001 botuser
RUN adduser --system --uid 1001 botuser RUN adduser --system --uid 1001 botuser
USER botuser USER botuser
COPY --from=installer --chown=botuser:nodejs /app/apps/bot/dist ./apps/bot/dist COPY --from=installer /app .
CMD node apps/bot/dist/src/index.js CMD node apps/bot/dist/src/index.js

7
apps/web/.dockerignore Normal file
View File

@ -0,0 +1,7 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git

View File

@ -1,29 +1,44 @@
FROM node:20-alpine AS base FROM node:22-alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN apk add --no-cache libc6-compat && \
corepack enable && \
pnpm install turbo dotenv-cli --global
FROM base AS builder FROM base AS builder
RUN apk update RUN apk add --no-cache openssl
RUN apk add --no-cache libc6-compat
WORKDIR /app WORKDIR /app
RUN corepack enable && corepack prepare yarn@4.2.2 --activate
RUN yarn global add turbo
COPY . . COPY . .
RUN turbo prune web --docker RUN turbo prune --scope=web --docker
FROM base AS installer FROM base AS installer
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /app WORKDIR /app
COPY .gitignore .gitignore
# COPY reset.d.ts reset.d.ts # only if you're using ts-reset library
COPY --from=builder /app/out/json/ . COPY --from=builder /app/out/json/ .
RUN yarn install --immutable COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/out/full/ . COPY --from=builder /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
RUN yarn turbo build RUN pnpm install --prod --frozen-lockfile
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
COPY .env .env
RUN dotenv -e .env turbo run build --filter=web
FROM base AS runner FROM base AS runner
WORKDIR /app WORKDIR /app
RUN addgroup --system --gid 1001 nodejs RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs RUN adduser --system --uid 1001 nextjs
USER nextjs USER nextjs
COPY --from=installer /app/apps/web/next.config.js .
COPY --from=installer /app/apps/web/package.json .
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./ COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
CMD node apps/web/server.js
CMD node apps/web/server.js

View File

@ -2,7 +2,8 @@
import { z } from 'zod'; import { z } from 'zod';
export const envSchema = z.object({ export const envSchema = z.object({
__DEV_TELEGRAM_ID: z.string(), __DEV_TELEGRAM_ID: z.string().default(''),
BOT_TOKEN: z.string(), BOT_TOKEN: z.string(),
}); });
export const env = envSchema.parse(process.env); export const env = envSchema.parse(process.env);

View File

@ -6,6 +6,7 @@ const nextConfig = withNextIntl({
eslint: { eslint: {
ignoreDuringBuilds: true, ignoreDuringBuilds: true,
}, },
output: 'standalone',
reactStrictMode: true, reactStrictMode: true,
transpilePackages: ['@repo/ui'], transpilePackages: ['@repo/ui'],
}); });

View File

@ -14,44 +14,44 @@
"test:e2e": "playwright test" "test:e2e": "playwright test"
}, },
"dependencies": { "dependencies": {
"@playwright/test": "^1.49.1",
"@repo/graphql": "workspace:*", "@repo/graphql": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@repo/ui": "workspace:*", "@repo/ui": "workspace:*",
"@repo/utils": "workspace:", "@repo/utils": "workspace:",
"@tanstack/react-query": "^5.64.1", "@tanstack/react-query": "^5.64.1",
"@telegram-apps/sdk-react": "^2.0.19", "@telegram-apps/sdk-react": "^2.0.19",
"@testing-library/react": "^16.1.0",
"@types/node": "catalog:",
"@types/react-dom": "catalog:",
"@types/react": "catalog:",
"@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "catalog:",
"dayjs": "catalog:", "dayjs": "catalog:",
"eruda": "^3.4.1",
"graphql": "catalog:", "graphql": "catalog:",
"jsdom": "^25.0.1",
"lucide-react": "catalog:", "lucide-react": "catalog:",
"next": "15.3.0",
"next-auth": "^4.24.11", "next-auth": "^4.24.11",
"next-intl": "^3.26.0", "next-intl": "^3.26.0",
"next-themes": "^0.4.4", "next-themes": "^0.4.4",
"next": "15.3.0",
"postcss": "catalog:",
"radashi": "catalog:", "radashi": "catalog:",
"react": "catalog:",
"react-dom": "catalog:", "react-dom": "catalog:",
"react": "catalog:",
"tailwindcss": "catalog:",
"typescript": "catalog:",
"use-debounce": "^10.0.4", "use-debounce": "^10.0.4",
"vite-tsconfig-paths": "catalog:",
"vitest": "catalog:",
"zod": "catalog:", "zod": "catalog:",
"zustand": "^5.0.3" "zustand": "^5.0.3"
}, },
"devDependencies": { "devDependencies": {
"@playwright/test": "^1.49.1",
"@repo/eslint-config": "workspace:*", "@repo/eslint-config": "workspace:*",
"@repo/lint-staged-config": "workspace:*", "@repo/lint-staged-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@testing-library/react": "^16.1.0",
"@types/node": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "catalog:",
"dotenv-cli": "catalog:", "dotenv-cli": "catalog:",
"eruda": "^3.4.1", "lint-staged": "catalog:"
"jsdom": "^25.0.1",
"lint-staged": "catalog:",
"postcss": "catalog:",
"tailwindcss": "catalog:",
"typescript": "catalog:",
"vite-tsconfig-paths": "catalog:",
"vitest": "catalog:"
} }
} }

View File

@ -1,42 +1,19 @@
version: "3"
services: services:
web: web:
container_name: web container_name: web
env_file:
- .env
build: build:
context: . context: .
dockerfile: ./apps/web/Dockerfile dockerfile: ./apps/web/Dockerfile
restart: always restart: always
ports: ports:
- 3000:3000 - 3000:3000
environment:
BOT_TOKEN: ${BOT_TOKEN}
LOGIN_GRAPHQL: ${LOGIN_GRAPHQL}
PASSWORD_GRAPHQL: ${PASSWORD_GRAPHQL}
URL_GRAPHQL: ${URL_GRAPHQL}
__DEV_TELEGRAM_ID: ${__DEV_TELEGRAM_ID}
NODE_ENV: "production"
networks:
- app
- web
bot: bot:
container_name: bot container_name: bot
env_file:
- .env
build: build:
context: . context: .
dockerfile: ./apps/bot/Dockerfile dockerfile: ./apps/bot/Dockerfile
restart: always restart: always
environment:
BOT_TOKEN: ${BOT_TOKEN}
LOGIN_GRAPHQL: ${LOGIN_GRAPHQL}
PASSWORD_GRAPHQL: ${PASSWORD_GRAPHQL}
URL_GRAPHQL: ${URL_GRAPHQL}
NODE_ENV: "production"
networks:
- app
- web
networks:
app:
external: true
web:
external: true

View File

@ -12,13 +12,15 @@
"test:unit": "turbo test:unit", "test:unit": "turbo test:unit",
"test:e2e": "turbo test:e2e" "test:e2e": "turbo test:e2e"
}, },
"devDependencies": { "dependencies": {
"husky": "catalog:", "husky": "catalog:",
"prettier": "catalog:",
"turbo": "^2.3.2", "turbo": "^2.3.2",
"typescript": "catalog:" "typescript": "catalog:"
}, },
"packageManager": "pnpm@9.14.2+sha512.6e2baf77d06b9362294152c851c4f278ede37ab1eba3a55fda317a4a17b209f4dbb973fb250a77abc463a341fcb1f17f17cfa24091c4eb319cda0d9b84278387", "devDependencies": {
"prettier": "catalog:"
},
"packageManager": "pnpm@9.15.9",
"engines": { "engines": {
"node": ">=18" "node": ">=18"
} }

View File

@ -9,11 +9,16 @@
}, },
"dependencies": { "dependencies": {
"@apollo/client": "catalog:", "@apollo/client": "catalog:",
"@graphql-typed-document-node/core": "^3.2.0",
"@repo/typescript-config": "workspace:*",
"@repo/utils": "workspace:", "@repo/utils": "workspace:",
"@types/jsonwebtoken": "^9.0.7",
"dayjs": "catalog:", "dayjs": "catalog:",
"jsonwebtoken": "catalog:", "jsonwebtoken": "catalog:",
"radashi": "catalog:", "radashi": "catalog:",
"telegraf": "catalog:", "telegraf": "catalog:",
"vite-tsconfig-paths": "catalog:",
"vitest": "catalog:",
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
@ -21,12 +26,7 @@
"@graphql-codegen/typed-document-node": "^5.0.12", "@graphql-codegen/typed-document-node": "^5.0.12",
"@graphql-codegen/typescript": "^4.1.2", "@graphql-codegen/typescript": "^4.1.2",
"@graphql-codegen/typescript-operations": "^4.4.0", "@graphql-codegen/typescript-operations": "^4.4.0",
"@graphql-typed-document-node/core": "^3.2.0",
"@repo/eslint-config": "workspace:*", "@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*", "graphql": "catalog:"
"@types/jsonwebtoken": "^9.0.7",
"graphql": "catalog:",
"vite-tsconfig-paths": "catalog:",
"vitest": "catalog:"
} }
} }

View File

@ -1,4 +1,4 @@
import { env } from '@/config/env'; import { env as environment } from '../config/env';
import { Telegraf } from 'telegraf'; import { Telegraf } from 'telegraf';
export const bot = new Telegraf(env.BOT_TOKEN); export const bot = new Telegraf(environment.BOT_TOKEN);

View File

@ -26,22 +26,9 @@
"type-check": "tsc --noEmit" "type-check": "tsc --noEmit"
}, },
"devDependencies": { "devDependencies": {
"@radix-ui/react-slot": "^1.1.1",
"@repo/eslint-config": "workspace:*", "@repo/eslint-config": "workspace:*",
"@repo/lint-staged-config": "workspace:*", "@repo/lint-staged-config": "workspace:*",
"@repo/typescript-config": "workspace:*", "lint-staged": "catalog:"
"@types/react": "catalog:",
"autoprefixer": "catalog:",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"lint-staged": "catalog:",
"lucide-react": "catalog:",
"postcss": "catalog:",
"postcss-load-config": "catalog:",
"tailwind-merge": "^2.5.5",
"tailwindcss": "catalog:",
"tailwindcss-animate": "^1.0.7",
"typescript": "catalog:"
}, },
"dependencies": { "dependencies": {
"@radix-ui/react-avatar": "^1.1.2", "@radix-ui/react-avatar": "^1.1.2",
@ -50,11 +37,24 @@
"@radix-ui/react-label": "^2.1.1", "@radix-ui/react-label": "^2.1.1",
"@radix-ui/react-scroll-area": "^1.2.2", "@radix-ui/react-scroll-area": "^1.2.2",
"@radix-ui/react-select": "^2.1.4", "@radix-ui/react-select": "^2.1.4",
"@radix-ui/react-slot": "^1.1.1",
"@repo/typescript-config": "workspace:*",
"@types/react": "catalog:",
"autoprefixer": "catalog:",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"date-fns": "^4.1.0", "date-fns": "^4.1.0",
"lucide-react": "catalog:",
"next-themes": "^0.4.4", "next-themes": "^0.4.4",
"react": "catalog:", "postcss-load-config": "catalog:",
"postcss": "catalog:",
"react-day-picker": "8.10.1", "react-day-picker": "8.10.1",
"react-dom": "catalog:", "react-dom": "catalog:",
"sonner": "^1.7.4" "react": "catalog:",
"sonner": "^1.7.4",
"tailwind-merge": "^2.5.5",
"tailwindcss-animate": "^1.0.7",
"tailwindcss": "catalog:",
"typescript": "catalog:"
} }
} }

View File

@ -11,14 +11,14 @@
"./customer": "./src/customer.ts" "./customer": "./src/customer.ts"
}, },
"dependencies": { "dependencies": {
"@repo/typescript-config": "workspace:*",
"dayjs": "catalog:", "dayjs": "catalog:",
"radashi": "catalog:", "radashi": "catalog:",
"vite-tsconfig-paths": "catalog:",
"vitest": "catalog:",
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@repo/eslint-config": "workspace:*", "@repo/eslint-config": "workspace:*"
"@repo/typescript-config": "workspace:*",
"vite-tsconfig-paths": "catalog:",
"vitest": "catalog:"
} }
} }

776
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,8 @@
"build": { "build": {
"dependsOn": ["^build"], "dependsOn": ["^build"],
"inputs": ["$TURBO_DEFAULT$", ".env*"], "inputs": ["$TURBO_DEFAULT$", ".env*"],
"outputs": [".next/**", "!.next/cache/**"] "outputs": [".next/**", "!.next/cache/**"],
"env": ["URL_GRAPHQL", "PASSWORD_GRAPHQL", "LOGIN_GRAPHQL", "BOT_TOKEN", "NEXTAUTH_SECRET"]
}, },
"lint": { "lint": {
"dependsOn": ["^lint"] "dependsOn": ["^lint"]