This commit is contained in:
@@ -17,14 +17,6 @@ jobs:
|
|||||||
mkdir -p assets/resources
|
mkdir -p assets/resources
|
||||||
printf "%s" "${{ secrets.ENV_FILE }}" > assets/resources/.env
|
printf "%s" "${{ secrets.ENV_FILE }}" > assets/resources/.env
|
||||||
|
|
||||||
- name: Stop and remove old containers
|
|
||||||
run: |
|
|
||||||
docker compose down || true
|
|
||||||
|
|
||||||
- name: Remove unused Docker resources
|
|
||||||
run: |
|
|
||||||
docker system prune -a --volumes -f
|
|
||||||
|
|
||||||
- name: Deploy to Container
|
- name: Deploy to Container
|
||||||
run: |
|
run: |
|
||||||
docker compose --env-file ./assets/resources/.env up -d --build --remove-orphans
|
docker compose --env-file ./assets/resources/.env up -d --build --remove-orphans
|
||||||
@@ -28,20 +28,23 @@ services:
|
|||||||
- history-api-project
|
- history-api-project
|
||||||
|
|
||||||
migrate:
|
migrate:
|
||||||
image: migrate/migrate
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile_inline: |
|
||||||
|
FROM migrate/migrate
|
||||||
|
COPY db/migrations /migrations
|
||||||
container_name: history_migrate
|
container_name: history_migrate
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
env_file:
|
env_file:
|
||||||
- ./assets/resources/.env
|
- ./assets/resources/.env
|
||||||
volumes:
|
|
||||||
- ${PWD}/db/migrations:/migrations:ro
|
|
||||||
entrypoint:
|
entrypoint:
|
||||||
- sh
|
- sh
|
||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
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 để kiểm tra chắc chắn lúc chạy
|
||||||
ls /migrations
|
ls /migrations
|
||||||
/migrate -path /migrations -database "$$DB_URL" up || \
|
/migrate -path /migrations -database "$$DB_URL" up || \
|
||||||
(/migrate -path /migrations -database "$$DB_URL" force 8 && \
|
(/migrate -path /migrations -database "$$DB_URL" force 8 && \
|
||||||
|
|||||||
Reference in New Issue
Block a user