init
Some checks failed
Build and Release / release (push) Failing after 1m32s

This commit is contained in:
2026-03-25 22:47:09 +07:00
parent 9bc2200455
commit 21dd86c3ea
2 changed files with 24 additions and 27 deletions

View File

@@ -25,7 +25,6 @@ jobs:
run: | run: |
docker system prune -a --volumes -f docker system prune -a --volumes -f
- name: Build and restart containers - name: Deploy to Container
run: | run: |
# Đảm bảo file .env tồn tại trước khi chạy docker compose --env-file ./assets/resources/.env up -d --build --remove-orphans
docker compose --env-file ./assets/resources/.env up -d --build

View File

@@ -36,19 +36,17 @@ services:
env_file: env_file:
- ./assets/resources/.env - ./assets/resources/.env
volumes: volumes:
- ./db/migrations:/migrations # Sử dụng đường dẫn tuyệt đối biến docker tự hiểu hoặc đảm bảo folder tồn tại
# Sử dụng sh -c để có thể chạy chuỗi lệnh - ./db/migrations:/migrations:ro
entrypoint: entrypoint:
- sh - sh
- -c - -c
- | - |
# Lấy URL database từ biến môi trường
DB_URL="postgres://$${POSTGRES_USER}:$${POSTGRES_PASSWORD}@db:5432/$${POSTGRES_DB}?sslmode=disable" DB_URL="postgres://$${POSTGRES_USER}:$${POSTGRES_PASSWORD}@db:5432/$${POSTGRES_DB}?sslmode=disable"
# Thêm ls để debug xem có file không nếu vẫn lỗi
echo "Checking for dirty database..." ls /migrations
/migrate -path /migrations -database "$$DB_URL" up || \ /migrate -path /migrations -database "$$DB_URL" up || \
(echo "Database is dirty, forcing to version 8..." && \ (/migrate -path /migrations -database "$$DB_URL" force 8 && \
/migrate -path /migrations -database "$$DB_URL" force 8 && \
/migrate -path /migrations -database "$$DB_URL" up) /migrate -path /migrations -database "$$DB_URL" up)
networks: networks:
- history-api-project - history-api-project