Use environment variables only (no .env file) and separate horizon

This commit is contained in:
Pierre Jaury 2018-06-17 10:20:21 +02:00
parent d327aeba2b
commit cce25eb771
4 changed files with 68 additions and 89 deletions

View file

@ -1,40 +1,56 @@
---
version: '3'
# In order to set configuration, please use a .env file in
# your compose project directory (the same directory as your
# docker-compose.yml), and set database options, application
# name, key, and other settings there.
# A list of available settings is available in .env.example
#
# The services should scale properly across a swarm cluster
# if the volumes are properly shared between cluster members.
services:
pixelfed:
build: .
app:
# Uncomment to build a local copy of the image
# build: .
image: pixelfed
# If you have a traefik running, uncomment this to expose Pixelfed
# labels:
# - traefik.enable=true
# - traefik.frontend.rule=Host:your.url
# - traefik.port=80
env_file:
- ./.env
volumes:
- "php-storage:/var/www/html"
- "app-storage:/var/www/storage"
networks:
- external
- internal
environment:
# The full list of available variables is documented in docker/env
- DB_HOST=mysql
- DB_DATABASE=pixelfed
- DB_USERNAME=${DB_USERNAME:-pixelfed}
- DB_PASSWORD=${DB_PASSWORD:-pixelfed}
- REDIS_HOST=redis
- APP_KEY=SetYourAppKeyHere
- APP_NAME=Pixelfed
- APP_URL=https://your.url
- MAIL_HOST=mail.host
- MAIL_FROM_ADDRESS=noreply@your.url
- MAIL_FROM_NAME=Pixelfed
mysql:
# Uncomment if you set HORIZON_EMBED to false and wish to run a local worker
# worker:
# image: pixelfed
# env_file:
# - ./.env
# volumes:
# - "app-storage:/var/www/storage"
# networks:
# - internal
# command: php artisan horizon
db:
image: mysql:5.7
networks:
- internal
environment:
- MYSQL_DATABASE=pixelfed
- MYSQL_USER=${DB_USERNAME:-pixelfed}
- MYSQL_PASSWORD=${DB_PASSWORD:-pixelfed}
- MYSQL_RANDOM_ROOT_PASSWORD="true"
- MYSQL_USER=${DB_USERNAME}
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_RANDOM_ROOT_PASSWORD=true
volumes:
- "mysql-data:/var/lib/mysql"
- "db-data:/var/lib/mysql"
redis:
image: redis:alpine
@ -43,10 +59,11 @@ services:
networks:
- internal
# Adjust your volume data in order to store data where you wish
volumes:
redis-data:
mysql-data:
php-storage:
db-data:
app-storage:
networks:
internal:

View file

@ -32,10 +32,27 @@ COPY . /var/www/
WORKDIR /var/www/
RUN cp -r storage storage.skel \
&& cp docker/env .env \
&& composer install --prefer-source --no-interaction \
&& rm -rf html && ln -s public html
VOLUME ["/var/www/storage"]
ENV APP_ENV=production \
APP_DEBUG=false \
LOG_CHANNEL=stderr \
DB_CONNECTION=mysql \
DB_PORT=3306 \
DB_HOST=db \
BROADCAST_DRIVER=log \
QUEUE_DRIVER=redis \
HORIZON_PREFIX=horizon-pixelfed \
REDIS_HOST=redis \
SESSION_SECURE_COOKIE=true \
API_BASE="/api/1/" \
API_SEARCH="/api/search" \
OPEN_REGISTRATION=true \
ENFORCE_EMAIL_VERIFICATION=true \
REMOTE_FOLLOW=false \
ACTIVITY_PUB=false
CMD /var/www/docker/start.sh

View file

@ -1,59 +0,0 @@
APP_NAME="${APP_NAME}"
APP_ENV=local
APP_KEY="${APP_KEY}"
APP_DEBUG=false
APP_URL=${APP_URL}
LOG_CHANNEL=stderr
DB_CONNECTION=mysql
DB_HOST=${DB_HOST}
DB_PORT=3306
DB_DATABASE="${DB_DATABASE}"
DB_USERNAME="${DB_USERNAME}"
DB_PASSWORD="${DB_PASSWORD}"
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=redis
HORIZON_PREFIX=horizon-pixelfed
REDIS_HOST="${REDIS_HOST}"
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=${MAIL_HOST}
MAIL_PORT="${MAIL_PORT}"
MAIL_USERNAME="${MAIL_USERNAME}"
MAIL_PASSWORD="${MAIL_PASSWORD}"
MAIL_ENCRYPTION="${MAIL_ENCRYPTION}"
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
SESSION_DOMAIN="${SESSION_DOMAIN}"
SESSION_SECURE_COOKIE=true
API_BASE="/api/1/"
API_SEARCH="/api/search"
OPEN_REGISTRATION=${OPEN_REGISTRATION}
MAX_CAPTION_LENGTH=${MAX_CAPTION_LENGTH}
MAX_PHOTO_SIZE=${MAX_PHOTO_SIZE}
ENFORCE_EMAIL_VERIFICATION=${ENFORCE_EMAIL_VERIFICATION}
REMOTE_FOLLOW=${REMOTE_FOLLOW}
ACTIVITY_PUB=${ACTIVITY_PUB}
RECAPTCHA_ENABLED=${RECAPTCHA_ENABLED}
RECAPTCHA_PUBLIC_KEY=${RECAPTCHA_PUBLIC_KEY}
RECAPTCHA_PRIVATE_KEY=${RECAPTCHA_PRIVATE_KEY}
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MIX_APP_URL="${APP_URL}"
MIX_API_BASE="${API_BASE}"
MIX_API_SEARCH="${API_SEARCH}"

View file

@ -1,13 +1,17 @@
#!/bin/bash
set -o allexport
source .env
set +o allexport
# Create the storage tree if needed and fix permissions
cp -r storage.skel/* storage/
chown -R www-data:www-data storage/
php artisan migrate --force
php artisan storage:link
php artisan horizon &
# Migrate database if the app was upgraded
php artisan migrate --force
# Run a worker if it is set as embedded
if [ HORIZON_EMBED = true ]; then
php artisan horizon &
fi
# Finally run Apache
exec apache2-foreground