Initial docker sync setup and documentation of the new supported dev env methods

This commit is contained in:
Adam Lavin 2021-03-31 01:04:17 +01:00
parent d1cb2e69cf
commit 6b2ae80414
No known key found for this signature in database
GPG key ID: 9C4C68AFA9CA6461
4 changed files with 71 additions and 3 deletions

51
DOCKER-README.md Normal file
View file

@ -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.

View file

@ -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:

12
docker-sync.yml Normal file
View file

@ -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

View file

@ -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