<file_sep>#!/usr/bin/env sh

if [ "true" != "${XDEBUG_ENABLED}" ]; then
    rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
fi

COMMAND="composer install --prefer-dist --no-progress --no-suggest --no-interaction"

if [[ "prod" = "${APP_ENV}" ]]; then
    COMMAND="${COMMAND} --no-dev  --optimize-autoloader --classmap-authoritative"
fi

su \
    -c "${COMMAND}" \
    -s /bin/sh \
    -m \
    www-data

chown -R www-data: var/

php-fpm<file_sep>version: '3.2'

services:
    php:
        build:
            context: .
            dockerfile: docker/php/Dockerfile.dev
            args:
                - HOST_UID=${HOST_UID}
                - HOST_GUID=${HOST_GUID}
        volumes:
            - .:/var/www/html
            - ${HOST_COMPOSER_HOME}:/var/www/html/var/.composer
        environment:
            - COMPOSER_HOME=/var/www/html/var/.composer
            - XDEBUG_ENABLED
            - XDEBUG_CONFIG
            - PHP_IDE_CONFIG
    db:
        image: postgres:12-alpine
        volumes:
            - db:/var/lib/postgresql/data
        environment:
            - POSTGRES_DB
            - POSTGRES_USER
            - POSTGRES_PASSWORD
            - POSTGRES_PORT
        ports:
            - "${EXTERNAL_POSTGRES_PORT}:${POSTGRES_PORT}"
    nginx:
        build:
            context: .
            dockerfile: docker/nginx/Dockerfile.dev
            args:
                - HOST_UID=${HOST_UID}
                - HOST_GUID=${HOST_GUID}
        depends_on:
            - php
        ports:
            - ${EXTERNAL_HTTP_PORT}:80
        volumes:
            - .:/var/www/html
            - ./var/log:/var/log/nginx
        environment:
            - UPSTREAM=php:9000

volumes:
    db:<file_sep># TODO List API Server

## Dev Requirements

- Docker
- Docker Compose >= 1.26

## Setup

1. Create `.env` file with the contents of the `.env.dist` file
2. Modify variables for your needs
3. Run `docker-compose up -d`
4. Open http://localhost:<${EXTERNAL_HTTP_PORT}> (by default just http://localhost)