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: |
docker system prune -a --volumes -f
- name: Build and restart containers
- name: Deploy to Container
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
docker compose --env-file ./assets/resources/.env up -d --build --remove-orphans

View File

@@ -28,30 +28,28 @@ services:
- history-api-project
migrate:
image: migrate/migrate
container_name: history_migrate
depends_on:
db:
condition: service_healthy
env_file:
- ./assets/resources/.env
volumes:
- ./db/migrations:/migrations
# Sử dụng sh -c để có thể chạy chuỗi lệnh
entrypoint:
- sh
- -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"
echo "Checking for dirty database..."
/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" up)
networks:
- history-api-project
image: migrate/migrate
container_name: history_migrate
depends_on:
db:
condition: service_healthy
env_file:
- ./assets/resources/.env
volumes:
# 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
- ./db/migrations:/migrations:ro
entrypoint:
- sh
- -c
- |
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
ls /migrations
/migrate -path /migrations -database "$$DB_URL" up || \
(/migrate -path /migrations -database "$$DB_URL" force 8 && \
/migrate -path /migrations -database "$$DB_URL" up)
networks:
- history-api-project
app:
build: .
container_name: history_app