############################################################################### # The test suite, against Postgres. # # Worth having as its own file because of one specific risk: this application # stores translations, slugs and image variants in JSON columns and queries # them by path — `where("slug->es", …)` — in about forty places, and until this # stack existed all of it had only ever run on SQLite. The three databases # agree on the syntax and not always on the behaviour. # # docker compose -f docker-compose.test.yml run --rm test # # Everything is thrown away afterwards: no volume, no persistence, nothing # shared with the production stack. ############################################################################### services: test: build: context: . dockerfile: Dockerfile target: test environment: APP_ENV: testing APP_KEY: base64:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= APP_DEBUG: "true" DB_CONNECTION: pgsql DB_HOST: postgres-test DB_PORT: 5432 DB_DATABASE: testing DB_USERNAME: testing DB_PASSWORD: testing CACHE_STORE: array SESSION_DRIVER: array QUEUE_CONNECTION: sync MAIL_MAILER: array APP_LOCALE: es APP_FALLBACK_LOCALE: es # The identity server is faked in every test; these only have to exist. PIREON_SERVER: https://oauth.pireon.test PIREON_CLIENT_ID: test-client-id PIREON_CLIENT_SECRET: test-client-secret PIREON_REDIRECT_URI: http://localhost/auth/callback # Nothing here talks to the database until it is ready, and the # entrypoint's own wait is what makes `run` reliable. RUN_MIGRATIONS: "false" depends_on: postgres-test: condition: service_healthy command: - sh - -c - | php artisan config:clear --quiet php artisan test postgres-test: image: postgres:17-alpine environment: POSTGRES_DB: testing POSTGRES_USER: testing POSTGRES_PASSWORD: testing POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=C" # In memory: this database exists for the length of one test run. tmpfs: - /var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U testing -d testing"] interval: 5s timeout: 3s retries: 10