From 4838432850232b9dfb7f62cea793ee149cad913b Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Mon, 16 Mar 2026 12:40:20 +0100 Subject: [PATCH] Add docker-compose bind mount preview test case (#67) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test case for coolify#7802 — reproduces the bug where bind mount volumes from repo content get an incorrect -pr-N suffix during Preview Deployments. Co-authored-by: Claude Opus 4.6 --- docker-compose-bind-mount-preview/README.md | 19 +++++++++ .../docker-compose.yml | 42 +++++++++++++++++++ .../scripts/bootstrap_db.sh | 20 +++++++++ 3 files changed, 81 insertions(+) create mode 100644 docker-compose-bind-mount-preview/README.md create mode 100644 docker-compose-bind-mount-preview/docker-compose.yml create mode 100644 docker-compose-bind-mount-preview/scripts/bootstrap_db.sh diff --git a/docker-compose-bind-mount-preview/README.md b/docker-compose-bind-mount-preview/README.md new file mode 100644 index 0000000..f68274b --- /dev/null +++ b/docker-compose-bind-mount-preview/README.md @@ -0,0 +1,19 @@ +# Docker Compose Bind Mount Preview Test + +Test case for [coolify#7802](https://github.com/coollabsio/coolify/issues/7802) — volume mappings from repo content in Preview Deployments. + +## Setup + +1. Add this repo as a Docker Compose resource in Coolify +2. Set the base directory to `/docker-compose-bind-mount-preview` +3. Deploy — should succeed (db_bootstrap runs the script from `./scripts`) +4. Enable **Preview Deployments** +5. Open a PR and deploy the preview + +## Expected + +The preview deployment should work the same as the main deployment — the `./scripts` bind mount should resolve to the repo's `scripts/` directory. + +## Actual (bug) + +The preview deployment fails because Coolify appends `-pr-N` to the bind mount path, looking for `scripts-pr-1` which doesn't exist. diff --git a/docker-compose-bind-mount-preview/docker-compose.yml b/docker-compose-bind-mount-preview/docker-compose.yml new file mode 100644 index 0000000..3764a33 --- /dev/null +++ b/docker-compose-bind-mount-preview/docker-compose.yml @@ -0,0 +1,42 @@ +services: + + postgres: + image: postgres:16.4 + container_name: postgres_test + restart: always + environment: + POSTGRES_USER: ${COMPOSE__POSTGRES_USER:-postgres} + POSTGRES_PASSWORD: ${COMPOSE__POSTGRES_PASSWORD:-postgres} + POSTGRES_DB: ${COMPOSE__POSTGRES_DB:-postgres} + expose: + - "5432" + healthcheck: + test: [ "CMD-SHELL", "pg_isready -U postgres" ] + interval: 10s + retries: 5 + start_period: 10s + + db_bootstrap: + image: postgres:16.4 + container_name: db_bootstrap_test + depends_on: + postgres: + condition: service_healthy + environment: + DB_HOST: ${COMPOSE__POSTGRES_HOST:-postgres} + DB_NAME: ${COMPOSE__POSTGRES_DB:-postgres} + DB_USER: ${COMPOSE__POSTGRES_USER:-postgres} + PGPASSWORD: ${COMPOSE__POSTGRES_PASSWORD:-postgres} + volumes: + - ./scripts:/scripts:ro + entrypoint: [ "bash", "/scripts/bootstrap_db.sh" ] + restart: "no" + + main_service: + image: nginx:latest + container_name: nginx_server + ports: + - '0:80' + depends_on: + db_bootstrap: + condition: service_completed_successfully diff --git a/docker-compose-bind-mount-preview/scripts/bootstrap_db.sh b/docker-compose-bind-mount-preview/scripts/bootstrap_db.sh new file mode 100644 index 0000000..5700864 --- /dev/null +++ b/docker-compose-bind-mount-preview/scripts/bootstrap_db.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +echo "Waiting for PostgreSQL to be ready..." +until psql -h "$DB_HOST" -U "$DB_USER" -d "$DB_NAME" -c '\q' 2>/dev/null; do + sleep 1 +done + +echo "Creating test table..." +psql -h "$DB_HOST" -U "$DB_USER" -d "$DB_NAME" <