diff --git a/DOCKER-README.md b/DOCKER-README.md new file mode 100644 index 00000000..e91a00b6 --- /dev/null +++ b/DOCKER-README.md @@ -0,0 +1,51 @@ +# Pony.fm Docker README + +So, Pony.fm is being converted to run within a container on some new servers where it is hosted, thus it is now gaining +support for docker in the project. + +This guide is going to be an attempt to document how to run things in the new docker environment, until it's merged into +the main README expect things to be a WIP, and probably be partially documented or undocumented. + +## Environment Setups + +It is my aim to allow Pony.fm to be run in the following types of environments: + +- App is run on the host with dependencies running in docker. +- App is run in docker, alongside all dependencies. + +### App on host + +In this the general idea is that you'd need to do the following + +In your .env file you will refer to localhost for pretty much all services. + +``` +docker-compose up -d +``` +``` +cd public; php -c ../docker/php/php.ini -S localhost:8000 ../serve.php +``` + +TODO: Figure out if I can change the path that the local php server uses + +Notes: +- `php artisan serve` cannot be configured to change ini settings, so max file upload is a problem. +- You can change the `FFMPEG_PREFIX` env var to `docker run -v \"$(pwd):$(pwd)\" -w \"$(pwd)\" jrottenberg/ffmpeg:4.3-alpine312` and that'll work as expected. (TODO: Same thing, but for AtomicParsley) + +### App on docker + +You need to install https://docker-sync.readthedocs.io/en/latest/getting-started/installation.html + +** This method is primarily optimised for macOS ** + +In your .env file you will refer to the container names for all services. (I.E `DB_HOST=postgresd`, `ELASTICSEARCH_HOST=elasticsearch`) + +Bring everything up +``` +docker-sync start +docker-compose up -d +``` + +Notes: +- Initial sync is super slow, but watching is pretty fast +- You could skip docker-sync and change `appcode-sync` to `./` but expect request time to go from the `ms` to the many `s`'s. diff --git a/docker-compose.yml b/docker-compose.yml index e8cd2f00..5956849f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,7 @@ services: command: - web volumes: - - .:/app + - appcode-sync:/app:nocopy - ./docker/php/php.ini:/usr/local/etc/php/conf.d/php.ini:ro - ./docker/php/php.ini:/usr/local/etc/php-fpm.d/php.ini:ro @@ -42,7 +42,8 @@ services: volumes: - postgres-data:/var/lib/postgresql/data - volumes: + appcode-sync: + external: true postgres-data: elasticsearch-data: diff --git a/docker-sync.yml b/docker-sync.yml new file mode 100644 index 00000000..0f80329f --- /dev/null +++ b/docker-sync.yml @@ -0,0 +1,12 @@ +version: "2" + +options: + verbose: true + +syncs: + appcode-sync: + src: '.' + sync_strategy: native_osx + sync_excludes: ['.git', '.idea', 'node_modules'] + sync_userid: 82 + notify_terminal: true diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 2e130909..4f9dad36 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -2,7 +2,11 @@ set -e -sudo -Esu www-data php artisan optimize +# If we have an .env file then we're likely running on a dev machine +# in which case auto optimization on start up is not necessary. +if [ ! -f .env ]; then + sudo -Esu www-data php artisan optimize +fi MODE=$1