arrange entrypoints and commands for docker

This commit is contained in:
Arthur de Moulins
2020-02-27 21:54:54 +01:00
parent 056feff7b7
commit 4cfc712674
13 changed files with 62 additions and 41 deletions

View File

@@ -6,6 +6,7 @@
/docker-compose.*
/Dockerfile
/.env
/.env.*
/*.md
/.travis.yml
/CONTRIBUTORS
@@ -13,3 +14,5 @@
/www/thumbnails
/www/assets
/www/custom
/config/configuration.yml
/config/configuration-compiled.php

2
.gitignore vendored
View File

@@ -71,3 +71,5 @@ playbook.retry
npm-debug.log
/Phrasea_datas
.env.*

View File

@@ -107,15 +107,16 @@ FROM phraseanet-system as phraseanet-fpm
COPY --from=builder --chown=app /var/alchemy/Phraseanet /var/alchemy/Phraseanet
ADD ./docker/phraseanet/ /
WORKDIR /var/alchemy/Phraseanet
ENTRYPOINT ["/phraseanet-entrypoint.sh"]
CMD ["/boot.sh"]
ENTRYPOINT ["/phraseanet/entrypoint.sh"]
CMD ["php-fpm", "-F"]
#########################################################################
# Phraseanet worker application image
#########################################################################
FROM phraseanet-fpm as phraseanet-worker
CMD ["/worker-boot.sh"]
ENTRYPOINT ["/phraseanet/worker/entrypoint.sh"]
CMD ["/phraseanet/worker/scheduler-run.sh"]
#########################################################################
# phraseanet-nginx
@@ -125,4 +126,7 @@ FROM nginx:1.17.8-alpine as phraseanet-nginx
RUN adduser --uid 1000 --disabled-password app
ADD ./docker/nginx/ /
COPY --from=builder /var/alchemy/Phraseanet/www /var/alchemy/Phraseanet/www
CMD ["/boot.sh"]
ENTRYPOINT ["/entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -52,6 +52,16 @@ export INSTALL_ACCOUNT_PASSWORD=$3cr3t!
export PHRASEANET_APP_PORT=8082
```
### Using a .env.local
It may be easier to deal with a local file to manage our env variables.
You can add your `.env.local` at the root of this project and define a command alias in your `~/.bashrc`:
```bash
alias dc="env $(cat .env.local | grep -v '#' | tr '\n' ' ') docker-compose"
```
### Running the application
If you are not interested in the development of Phraseanet, you can ignore everything in `.env` after the `DEV Purpose` part.
@@ -103,15 +113,6 @@ For PhpStorm, you can follow this example:
> Configure the `Absolute path on the server` to `/var/alchemy/Phraseanet` at the project root path (i.e. `~/projects/Phraseanet`).
### How to change volumes location
Before moving all the files, or to use a different location, you have to remove all containers and volume definitions with the following command :
docker-compose down --volumes
Then move the files and set the `VOLUMES_DIR` to the new location.
# With Vagrant (deprecated)
## Development :

View File

@@ -13,6 +13,7 @@ services:
- .:/var/alchemy/Phraseanet
- ./datas:/var/alchemy/Phraseanet/datas:rw
- ./www/thumbnails:/var/alchemy/Phraseanet/www/thumbnails:rw
- ./docker/nginx/entrypoint.sh:/entrypoint.sh
builder:
build:
@@ -33,6 +34,8 @@ services:
- ./logs:/var/alchemy/Phraseanet/logs:rw
- ./datas:/var/alchemy/Phraseanet/datas:rw
- ./www/thumbnails:/var/alchemy/Phraseanet/www/thumbnails:rw
- ./docker/phraseanet/phraseanet/entrypoint.sh:/phraseanet/entrypoint.sh
- ./docker/phraseanet/phraseanet/auto-install.sh:/phraseanet/auto-install.sh
worker:
volumes:
@@ -41,6 +44,9 @@ services:
- ./logs:/var/alchemy/Phraseanet/logs:rw
- ./datas:/var/alchemy/Phraseanet/datas:rw
- ./www/thumbnails:/var/alchemy/Phraseanet/www/thumbnails:rw
- ./docker/phraseanet/phraseanet/entrypoint.sh:/phraseanet/entrypoint.sh
- ./docker/phraseanet/phraseanet/worker/entrypoint.sh:/phraseanet/worker/entrypoint.sh
- ./docker/phraseanet/phraseanet/worker/scheduler-run.sh:/phraseanet/worker/scheduler-run.sh
rabbitmq:
ports:

View File

@@ -14,7 +14,6 @@ services:
- phraseanet
environment:
- MAX_BODY_SIZE
ports:
- ${PHRASEANET_APP_PORT}:80

View File

@@ -3,4 +3,5 @@
set -xe
cat nginx.conf.sample | sed "s/\$MAX_BODY_SIZE/$MAX_BODY_SIZE/g" > /etc/nginx/conf.d/default.conf
nginx -g "daemon off;"
exec "$@"

View File

@@ -1,17 +0,0 @@
#!/bin/bash
set -xe
chown -R app:app /var/alchemy/Phraseanet/config
chown -R app:app /var/alchemy/Phraseanet/datas
chown -R app:app /var/alchemy/Phraseanet/tmp
chown -R app:app /var/alchemy/Phraseanet/www/thumbnails
FILE=/var/alchemy/Phraseanet/config/configuration.yml
if [ -f "$FILE" ]; then
echo "$FILE exist, skip setup."
else
echo "$FILE doesn't exist, entering setup..."
runuser app -c '/auto-install.sh'
fi
php-fpm -F

View File

@@ -0,0 +1,25 @@
#!/bin/bash
set -e
envsubst < /php.ini.sample > /usr/local/etc/php/php.ini
envsubst < /php-fpm.conf.sample > /usr/local/etc/php-fpm.conf
chown -R app:app /var/alchemy/Phraseanet/config
chown -R app:app /var/alchemy/Phraseanet/datas
chown -R app:app /var/alchemy/Phraseanet/tmp
chown -R app:app /var/alchemy/Phraseanet/www/thumbnails
FILE=/var/alchemy/Phraseanet/config/configuration.yml
if [ -f "$FILE" ]; then
echo "$FILE exists, skip setup."
else
echo "$FILE doesn't exist, entering setup..."
runuser app -c '/phraseanet/auto-install.sh'
fi
if [ ${XDEBUG_ENABLED} == "1" ]; then
echo "XDEBUG is enabled. YOU MAY KEEP THIS FEATURE DISABLED IN PRODUCTION."
docker-php-ext-enable xdebug
fi
bash -e docker-php-entrypoint $@

View File

@@ -2,6 +2,9 @@
set -e
mkdir -p /var/alchemy/Phraseanet/tmp/locks \
&& chown -R app:app /var/alchemy/Phraseanet/tmp
envsubst < /php.ini.sample > /usr/local/etc/php/php.ini
envsubst < /php-fpm.conf.sample > /usr/local/etc/php-fpm.conf

View File

@@ -0,0 +1,3 @@
#!/bin/bash
runuser app -c 'php /var/alchemy/Phraseanet/bin/console task-manager:scheduler:run'

View File

@@ -1,9 +0,0 @@
#!/bin/bash
if [ ${XDEBUG_ENABLED} == "1" ]; then
echo "XDEBUG is enabled. YOU MAY KEEP THIS FEATURE DISABLED IN PRODUCTION."
docker-php-ext-enable xdebug
fi
mkdir /var/alchemy/Phraseanet/tmp/locks && chown -R app:app /var/alchemy/Phraseanet/tmp
runuser app -c 'php /var/alchemy/Phraseanet/bin/console task-manager:scheduler:run'