Skip to content

Commit f6418bb

Browse files
committed
finally deploy
1 parent 4e7e070 commit f6418bb

3 files changed

Lines changed: 28 additions & 101 deletions

File tree

.github/workflows/ci.yml

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,23 @@ jobs:
2525
- name: Create placeholder env files
2626
run: |
2727
touch .env
28-
mkdir -p backend telegram-bot
29-
touch backend/.env telegram-bot/.env
28+
mkdir -p backend
29+
touch backend/.env
3030
3131
- name: Validate local Docker Compose
3232
run: docker compose config
3333

3434
- name: Validate server Docker Compose
3535
env:
3636
BACKEND_IMAGE: ghcr.io/example/focus/backend:test
37-
TELEGRAM_BOT_IMAGE: ghcr.io/example/focus/telegram-bot:test
3837
DATABASE_URL: postgres://user:pass@db:5432/focus?sslmode=disable
3938
JWT_SECRET: test-secret
4039
TELEGRAM_BOT_AUTH_TOKEN: test-bot-auth
41-
TELEGRAM_BOT_TOKEN: test-bot-token
4240
run: docker compose -f deploy/docker-compose.server.yml config
4341

4442
build-and-push-images:
4543
needs: compose-validate
4644
runs-on: ubuntu-latest
47-
strategy:
48-
fail-fast: false
49-
matrix:
50-
include:
51-
- service: backend
52-
context: ./backend
53-
image_suffix: backend
54-
- service: telegram-bot
55-
context: ./telegram-bot
56-
image_suffix: telegram-bot
5745
steps:
5846
- uses: actions/checkout@v4
5947

@@ -67,14 +55,14 @@ jobs:
6755
username: ${{ github.actor }}
6856
password: ${{ secrets.GHCR_TOKEN }}
6957

70-
- name: Build and push ${{ matrix.service }}
58+
- name: Build and push backend
7159
uses: docker/build-push-action@v6
7260
with:
73-
context: ${{ matrix.context }}
61+
context: ./backend
7462
push: true
7563
tags: |
76-
ghcr.io/${{ github.repository }}/${{ matrix.image_suffix }}:${{ github.sha }}
77-
ghcr.io/${{ github.repository }}/${{ matrix.image_suffix }}:latest
64+
ghcr.io/${{ github.repository }}/backend:${{ github.sha }}
65+
ghcr.io/${{ github.repository }}/backend:latest
7866
cache-from: type=gha
7967
cache-to: type=gha,mode=max
8068

@@ -92,7 +80,6 @@ jobs:
9280
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
9381
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
9482
BACKEND_IMAGE: ghcr.io/${{ github.repository }}/backend:${{ github.sha }}
95-
TELEGRAM_BOT_IMAGE: ghcr.io/${{ github.repository }}/telegram-bot:${{ github.sha }}
9683
steps:
9784
- uses: actions/checkout@v4
9885

@@ -167,10 +154,8 @@ jobs:
167154
run: |
168155
cat > deploy.env <<EOF
169156
BACKEND_IMAGE=${BACKEND_IMAGE}
170-
TELEGRAM_BOT_IMAGE=${TELEGRAM_BOT_IMAGE}
171157
DOCKER_NETWORK=${{ secrets.DOCKER_NETWORK }}
172158
BACKEND_PORT=${{ secrets.BACKEND_PORT }}
173-
BOT_PORT=${{ secrets.BOT_PORT }}
174159
PORT=${{ secrets.PORT }}
175160
DATABASE_URL=${{ secrets.DATABASE_URL }}
176161
CORS_ORIGIN=${{ secrets.CORS_ORIGIN }}
@@ -191,11 +176,6 @@ jobs:
191176
EMAIL_VERIFY_FAIL_REDIRECT=${{ secrets.EMAIL_VERIFY_FAIL_REDIRECT }}
192177
EMAIL_VERIFICATION_TTL_MINUTES=${{ secrets.EMAIL_VERIFICATION_TTL_MINUTES }}
193178
EMAIL_RESET_PASSWORD_URL_BASE=${{ secrets.EMAIL_RESET_PASSWORD_URL_BASE }}
194-
TELEGRAM_BOT_TOKEN=${{ secrets.TELEGRAM_BOT_TOKEN }}
195-
BACKEND_URL=${{ secrets.BACKEND_URL }}
196-
APP_URL=${{ secrets.APP_URL }}
197-
TELEGRAM_POLL_TIMEOUT_SECONDS=${{ secrets.TELEGRAM_POLL_TIMEOUT_SECONDS }}
198-
BOT_INTERNAL_API_ADDR=${{ secrets.BOT_INTERNAL_API_ADDR }}
199179
EOF
200180
201181
- name: Upload env file
@@ -211,6 +191,19 @@ jobs:
211191
echo "$GHCR_TOKEN" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
212192
docker compose --env-file .env pull
213193
docker compose --env-file .env run --rm migrate
214-
docker compose --env-file .env up -d backend telegram-bot
194+
docker compose --env-file .env up -d backend
195+
sleep 10
196+
docker compose --env-file .env ps --all || true
197+
docker ps -a --filter "name=mathalama-focus-backend" || true
198+
199+
backend_status="$(docker inspect -f '{{.State.Status}}' mathalama-focus-backend 2>/dev/null || true)"
200+
201+
if [ "$backend_status" != "running" ]; then
202+
echo "Deployed backend container is not running" >&2
203+
echo "backend status: ${backend_status:-missing}" >&2
204+
docker logs mathalama-focus-backend || true
205+
exit 1
206+
fi
207+
215208
docker image prune -f
216209
EOF

deploy/docker-compose.server.yml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,6 @@ services:
4646
- default
4747
- proxy
4848

49-
telegram-bot:
50-
image: ${TELEGRAM_BOT_IMAGE}
51-
container_name: mathalama-focus-telegram-bot
52-
environment:
53-
TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN}
54-
TELEGRAM_BOT_AUTH_TOKEN: ${TELEGRAM_BOT_AUTH_TOKEN}
55-
BACKEND_URL: ${BACKEND_URL:-http://backend:8080}
56-
APP_URL: ${APP_URL:-http://localhost:5173}
57-
TELEGRAM_POLL_TIMEOUT_SECONDS: ${TELEGRAM_POLL_TIMEOUT_SECONDS:-30}
58-
BOT_INTERNAL_API_ADDR: ${BOT_INTERNAL_API_ADDR:-:8091}
59-
restart: unless-stopped
60-
ports:
61-
- ${BOT_PORT:-8091}:8091
62-
depends_on:
63-
backend:
64-
condition: service_healthy
65-
healthcheck:
66-
test: ["CMD-SHELL", "wget -qO- http://localhost:8091/health >/dev/null || exit 1"]
67-
interval: 10s
68-
timeout: 5s
69-
retries: 5
70-
networks:
71-
- default
72-
7349
networks:
7450
proxy:
7551
name: ${DOCKER_NETWORK:-global_proxy}

docker-compose.yml

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,12 @@
11
services:
2-
postgres:
3-
image: postgres:16-alpine
4-
container_name: mathalama-focus-postgres
5-
environment:
6-
POSTGRES_USER: mathalama
7-
POSTGRES_PASSWORD: mathalama
8-
POSTGRES_DB: mathalama
9-
ports:
10-
- "5433:5432"
11-
volumes:
12-
- focus_pg_data:/var/lib/postgresql/data
13-
healthcheck:
14-
test: ["CMD-SHELL", "pg_isready -U mathalama -d mathalama"]
15-
interval: 10s
16-
timeout: 5s
17-
retries: 5
18-
192
migrate:
203
build:
214
context: ./backend
225
dockerfile: Dockerfile
236
image: mathalama-focus-backend:local
247
container_name: mathalama-focus-migrate
25-
depends_on:
26-
postgres:
27-
condition: service_healthy
288
environment:
29-
DATABASE_URL: postgres://mathalama:mathalama@postgres:5432/mathalama?sslmode=disable
9+
DATABASE_URL: ${DATABASE_URL:-postgres://mathalama:mathalama@localhost:5432/mathalama?sslmode=disable}
3010
MIGRATIONS_DIR: /app/migrations
3111
entrypoint: ["/app/migrate"]
3212
restart: "no"
@@ -41,42 +21,20 @@ services:
4121
migrate:
4222
condition: service_completed_successfully
4323
environment:
44-
PORT: "8080"
45-
DATABASE_URL: postgres://mathalama:mathalama@postgres:5432/mathalama?sslmode=disable
46-
ENABLE_DEV_LOGIN: "false"
24+
PORT: ${PORT:-8080}
25+
DATABASE_URL: ${DATABASE_URL:-postgres://mathalama:mathalama@localhost:5432/mathalama?sslmode=disable}
26+
CORS_ORIGIN: ${CORS_ORIGIN:-http://localhost:5173}
27+
JWT_SECRET: ${JWT_SECRET:-dev-secret-change-me}
28+
ENABLE_DEV_LOGIN: ${ENABLE_DEV_LOGIN:-false}
29+
TELEGRAM_BOT_AUTH_TOKEN: ${TELEGRAM_BOT_AUTH_TOKEN:-dev-telegram-bot-auth-change-me}
4730
ports:
48-
- "8080:8080"
31+
- "${BACKEND_PORT:-8080}:8080"
4932
restart: unless-stopped
5033
healthcheck:
5134
test: ["CMD-SHELL", "wget -qO- http://localhost:8080/health >/dev/null || exit 1"]
5235
interval: 10s
5336
timeout: 5s
5437
retries: 5
5538

56-
telegram-bot:
57-
build:
58-
context: ./telegram-bot
59-
dockerfile: Dockerfile
60-
container_name: mathalama-focus-telegram-bot
61-
depends_on:
62-
backend:
63-
condition: service_healthy
64-
environment:
65-
BACKEND_URL: http://backend:8080
66-
APP_URL: http://localhost:5173
67-
BOT_INTERNAL_API_ADDR: ":8091"
68-
ports:
69-
- "8091:8091"
70-
restart: unless-stopped
71-
healthcheck:
72-
test: ["CMD-SHELL", "wget -qO- http://localhost:8091/health >/dev/null || exit 1"]
73-
interval: 10s
74-
timeout: 5s
75-
retries: 5
76-
7739
# Frontend intentionally runs outside Docker:
7840
# cd frontend && npm install && npm run dev
79-
80-
volumes:
81-
focus_pg_data:
82-

0 commit comments

Comments
 (0)