From 52e65dff05058b47d753dfbe62370fbb6b560338 Mon Sep 17 00:00:00 2001 From: Artem Tsyrulnikov Date: Tue, 6 Jan 2026 12:38:49 +0300 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=D1=8B=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BF=D1=83=D1=81=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 3 +-- docker-compose.yml.example | 51 ++++++++++++++++++++++++++++---------- telegram_bot/Dockerfile | 17 +++++++++++++ telegram_bot/main.go | 2 +- 4 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 telegram_bot/Dockerfile diff --git a/Dockerfile b/Dockerfile index 436c191..e604bcc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,8 +8,7 @@ RUN uv sync --frozen COPY src ./src COPY shared ./shared -COPY alembic.ini ./ -COPY migration ./migration +COPY migrations ./migrations ENV PYTHONPATH=/shared:/src ARG GIT_COMMIT=unknown diff --git a/docker-compose.yml.example b/docker-compose.yml.example index d5c7c9a..4dd32c9 100644 --- a/docker-compose.yml.example +++ b/docker-compose.yml.example @@ -1,21 +1,46 @@ services: - # backend: - # build: - # context: . - # args: - # GIT_COMMIT: ${GIT_COMMIT:-unknown} - # env_file: - # - .env - # ports: - # - "8000:8000" - # depends_on: - # - postgres - postgres: - image: postgres + image: postgres:15 environment: POSTGRES_USER: "user" POSTGRES_PASSWORD: "password" POSTGRES_DB: "tgex" ports: - "5432:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U user -d tgex"] + interval: 10s + timeout: 5s + retries: 5 + + backend: + build: + context: . + ports: + - "8000:8000" + environment: + - DB__HOST=postgres + - DB__PORT=5432 + - DB__USER=user + - DB__PASSWORD=password + - DB__DATABASE=tgex + depends_on: + postgres: + condition: service_healthy + env_file: + - .env + restart: unless-stopped + + tg_bot: + build: + context: telegram_bot + depends_on: + - backend + env_file: + - .env + restart: unless-stopped + +volumes: + postgres_data: diff --git a/telegram_bot/Dockerfile b/telegram_bot/Dockerfile new file mode 100644 index 0000000..59624d8 --- /dev/null +++ b/telegram_bot/Dockerfile @@ -0,0 +1,17 @@ +FROM golang:1.25-alpine AS build + +WORKDIR /app + +# Modules layer +COPY go.mod go.sum ./ +RUN go mod download + +# Build layer +COPY . . +RUN CGO_ENABLED=0 GOOS=linux go build -o /tg_bot . + +FROM alpine:latest AS run + +COPY --from=build /tg_bot /tg_bot + +CMD ["/tg_bot"] \ No newline at end of file diff --git a/telegram_bot/main.go b/telegram_bot/main.go index 6f7e533..f67dedf 100644 --- a/telegram_bot/main.go +++ b/telegram_bot/main.go @@ -26,7 +26,7 @@ func main() { // Инициализация backend client backendClient := backend.New(backend.Config{ - BaseURL: "http://localhost:8000", + BaseURL: "http://backend:8000", LoginURL: "https://unstabilising-lora-unframable.ngrok-free.dev/api/v1/auth/complete?token=", })