This commit is contained in:
@@ -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
|
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user