forked from Somnia/SomniaRooms
Improved deployment, logs and update docs.
This commit is contained in:
@@ -73,6 +73,7 @@ docker run -d -it -p 80:80 -p 443:443 --name somniarooms --env-file ./env.prod.l
|
||||
|
||||
When deploying to prod is recomended to mount some directories as a docker volume or hostpath. This makes sure data is preserved after deleting the container.
|
||||
- Image directory (`/app/public/images`)
|
||||
- Logs (`/somnia_logs`)
|
||||
|
||||
If you are deploying your DB as a container, check the database docs and make sure database data won't be lost when updating or deleting the container. This example configuration store postgress data on a unnamed docket volume.
|
||||
|
||||
|
||||
@@ -11,14 +11,16 @@ services:
|
||||
# If you develop on Mac or Windows you can remove the vendor/ directory
|
||||
# from the bind-mount for better performance by enabling the next line:
|
||||
- /app/vendor
|
||||
# On dev mount var to localfiles.
|
||||
#- ./var/log:/app/var/log
|
||||
# App logs can be bind-mount to host folder.
|
||||
- ./var/log:/somnia_logs
|
||||
environment:
|
||||
FRANKENPHP_WORKER_CONFIG: watch
|
||||
MERCURE_EXTRA_DIRECTIVES: demo
|
||||
# See https://xdebug.org/docs/all_settings#mode
|
||||
XDEBUG_MODE: "${XDEBUG_MODE:-off}"
|
||||
APP_ENV: "${APP_ENV:-dev}"
|
||||
# Change APP log path.
|
||||
# SOMNIA_LOGSDIR: "/somnia_logs"
|
||||
extra_hosts:
|
||||
# Ensure that host.docker.internal is correctly defined on Linux
|
||||
- host.docker.internal:host-gateway
|
||||
|
||||
+4
-2
@@ -21,6 +21,7 @@ services:
|
||||
volumes:
|
||||
- caddy_data:/data
|
||||
- caddy_config:/config
|
||||
- app_logs:/somnia_logs # <-- Volume for App logs.
|
||||
ports:
|
||||
# HTTP
|
||||
- target: 80
|
||||
@@ -54,7 +55,7 @@ services:
|
||||
retries: 5
|
||||
start_period: 60s
|
||||
volumes:
|
||||
- somniaRooms_database:/var/lib/postgresql/data:rw
|
||||
- app_database:/var/lib/postgresql/data:rw
|
||||
# You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
|
||||
# - ./docker/db/data:/var/lib/postgresql/data:rw
|
||||
###< doctrine/doctrine-bundle ###
|
||||
@@ -62,9 +63,10 @@ services:
|
||||
volumes:
|
||||
caddy_data:
|
||||
caddy_config:
|
||||
app_logs:
|
||||
###> symfony/mercure-bundle ###
|
||||
###< symfony/mercure-bundle ###
|
||||
|
||||
###> doctrine/doctrine-bundle ###
|
||||
somniaRooms_database:
|
||||
app_database:
|
||||
###< doctrine/doctrine-bundle ###
|
||||
|
||||
@@ -8,13 +8,13 @@ when@dev:
|
||||
main:
|
||||
type: rotating_file
|
||||
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
||||
level: debug
|
||||
level: info
|
||||
channels: ["!event", "!doctrine"]
|
||||
max_files: 0
|
||||
doctrine:
|
||||
type: rotating_file
|
||||
path: "%kernel.logs_dir%/db_%kernel.environment%.log"
|
||||
level: debug
|
||||
level: info
|
||||
channels: ["doctrine", "request"]
|
||||
max_files: 10
|
||||
# uncomment to get logging in your browser
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
# Put parameters here that don't need to change on each machine where the app is deployed
|
||||
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
|
||||
parameters:
|
||||
# Allow custom path for log files.
|
||||
env(SOMNIA_LOGSDIR): '/somnia_logs'
|
||||
kernel.logs_dir: '%env(SOMNIA_LOGSDIR)%'
|
||||
# Set default value for APP_SECRET.
|
||||
env(APP_SECRET): 'ChangeMySecret'
|
||||
|
||||
services:
|
||||
# default configuration for services in *this* file
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!-- omit in toc -->
|
||||
# SomniaRooms - How to deploy.
|
||||
|
||||
- [Environment Vars](#environment-vars)
|
||||
- [Docker compose examples.](#docker-compose-examples)
|
||||
- [Deploy back-end and front-end on different servers (different ip address).](#deploy-back-end-and-front-end-on-different-servers-different-ip-address)
|
||||
- [Deploy on the same server.](#deploy-on-the-same-server)
|
||||
@@ -14,12 +15,37 @@ Production images for Docker Containers are available from Gitea Registry.
|
||||
|
||||
Documentation on how to deploy them as containers can be found at [Readme](../README.md).
|
||||
|
||||
## Environment Vars
|
||||
|
||||
Hare is a list of some "important" or useful environment vars to consider when deploying SomniaRooms
|
||||
|
||||
| Var | Required | Default Value | Description |
|
||||
| :------------------------: | :----------------: | :--------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `SERVER_NAME` | :heavy_check_mark: | `-` | Your server hostname to be used by Caddy. Should include "http://". |
|
||||
| `DATABASE_URL` | :heavy_check_mark: | `-` | Connection string for database. See: https://symfony.com/doc/current/doctrine.html#configuring-the-database |
|
||||
| `APP_SECRET` | :heavy_check_mark: | `ChangeMySecret` | Symfony App secret. You really should change this. . You can use `openssl rand -base64 36` to generate random strings |
|
||||
| `TRUSTED_PROXIES` | :heavy_check_mark: | `-` | Allowed proxies address. The proxy IP should be used. Must be set when used behind some proxy/reverse-proxy: traefik (see example below), nginx, .... |
|
||||
| `TRUSTED_HOSTS` | :heavy_check_mark: | `-` | ¿? You may have to set this to your `SERVER_NAME`, but I don't remember how it worked. |
|
||||
| `APP_ENV` | :x: | `dev` | Set current app environment. Set to `prod` from production use. |
|
||||
| `FRANKENPHP_CONFIG` | :x: | `-` | Add extra config for FrankenPHP. See: https://frankenphp.dev/docs/config/ |
|
||||
| `FRANKENPHP_WORKER_CONFIG` | :x: | `-` | Add extra config for FrankenPHP Workers. See: https://frankenphp.dev/docs/config/ |
|
||||
| `FRANKENPHP_USEWORKER` | :x: | `-` | Enable/disable FrankenPHP Workers. Valid values: `none` (disabled) /`worker` (enabled) |
|
||||
| `MERCURE_...` | :x: | `-` | Just copy default values from `compose.yaml`. SomniaRooms don't use Mercure right now and may get removed. |
|
||||
| `SOMNIA_LOGSDIR` | :x: | `/somnia_logs` | Path for App logs. It's recomended to save them on a volume or host-path (even in production?) just in case, as not all errors may be print to the console. |
|
||||
|
||||
|
||||
For running SomniaRooms behind a proxy, see: https://symfony.com/doc/current/deployment/proxies.html
|
||||
|
||||
|
||||
## Docker compose examples.
|
||||
|
||||
Here are some deploy examples using docker compose:
|
||||
|
||||
SomniaRooms back-end and front-end can run on the same machine, but some config is needed to work.
|
||||
|
||||
> [!WARNING]
|
||||
> **NOTE (31/05/2025)**: Some examples may be out-of-date. Use only as reference! Check ["dev" `compose.yaml`](../compose.yaml) and [Readme](../README.md) and apply relevant diffs.
|
||||
|
||||
### Deploy back-end and front-end on different servers (different ip address).
|
||||
If your servers have different IP addresses everything is a little bit easier. You can set-up subdomains for each one.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user