diff options
Diffstat (limited to 'docker/docker-compose.api.yml')
-rw-r--r-- | docker/docker-compose.api.yml | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/docker/docker-compose.api.yml b/docker/docker-compose.api.yml new file mode 100644 index 0000000..5c7f6d8 --- /dev/null +++ b/docker/docker-compose.api.yml @@ -0,0 +1,60 @@ +### CRIMSON --- A simple PHP framework. +### Copyright © 2024 Freya Murphy <contact@freyacat.org> +### +### This file is part of CRIMSON. +### +### CRIMSON is free software; you can redistribute it and/or modify it +### under the terms of the GNU General Public License as published by +### the Free Software Foundation; either version 3 of the License, or (at +### your option) any later version. +### +### CRIMSON is distributed in the hope that it will be useful, but +### WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with CRIMSON. If not, see <http://www.gnu.org/licenses/>. + +services: + # `docker-compose-api.yml` + # This compose file creates the `rest` container running postgrest. This is + # the program that crimson uses for the default API functionality. + # + # This service stack is only enabled when API_ENABLED=true. + # + # WARNING: The postgres container must also be enabled `POSTGRES_ENABLED=true` + # otherwise the docker stack will be invalid. + + rest: + # Postgrest uses postgres to store the api schema. To work properly, the + # database must be working (healthy) and all the api schema must be loaded. + # It is db-init's job to load the api schema, thus this container depends + # on both postgres and db-init. + build: ../build/postgrest + restart: unless-stopped + environment: + - API_SECRET + - API_ROLE + - API_SCHEMA + - POSTGRES_DB + - POSTGRES_USER + - POSTGRES_PASSWORD + healthcheck: + test: curl -I "http://localhost:3000/" + interval: 10s + timeout: 3s + retries: 10 + start_period: 3s + depends_on: + postgres: + condition: service_healthy + db-init: + condition: service_completed_successfully + + web: + # Nginx proxies requests to the API making it an added dependency. + depends_on: + rest: + condition: service_healthy + |