- Added endpoint to get prices for all RoomCategories. - Improvements to Prices API.
SomniaRooms
A Hotel Room booking system.
Powered by:
- PHP Symfony.
- Easyadmin.
Get started:
Dev commands
Build containers:
docker compose build --no-cache
Start Containers:
# Run SomniaRooms
docker compose up --pull always -d --wait
docker compose --env-file .\.env.local up -d --wait
# Run SomniaRooms with debug.
docker compose --env-file .\.env.dev.local up -d --wait
Stop containers
docker compose down --remove-orphans
To use xdebug in VSCode you may need to configure some environment vars. A .env file (.env.local) can be used as:
XDEBUG_MODE=develop,debug
XDEBUG_DISCOVER_CLIENT_HOST=1
XDEBUG_IDEKEY=docker
XDEBUG_LOG=/dev/stdout
Production commands:
When deploying to a production environment a production build should be used. Then, deployment can be done as containers or using docker-compose.
Build Prod image
To build a production image:
docker build -t somniarooms:prod --target frankenphp_prod .
Deploy prod image
You may use a env file to configure the SomniaRoom container (.env.prod.local):
SERVER_NAME=localhost
DATABASE_URL=postgresql://app:!ChangeMe!@somniadb:5432/somniarooms?serverVersion=16&charset=utf8
APP_SECRET=MYSECRET
MERCURE_PUBLISHER_JWT_KEY=MYCADDY_MERCURE_JWT_SECRET
MERCURE_SUBSCRIBER_JWT_KEY=MYCADDY_MERCURE_JWT_SECRET
FRANKENPHP_CONFIG="" #-> Avoid using FrankenPHP workers, as don't play well with Easyadmin.
You need a database for using SomniaRooms. To run one on a container you can use this that match this example config:
docker run -d --name somniarooms-db --hostname somniadb -p 5432:5432 --env=POSTGRES_DB=somniarooms --env=POSTGRES_PASSWORD=!ChangeMe! --env=POSTGRES_USER=app --env=PGDATA=/var/lib/postgresql/data --volume=somniarooms_db:/var/lib/postgresql/data --network somniarooms-network postgres:16-alpine
Then SomniaRooms can be deployed on a container (change --env-file value to the created file):
docker run -d -it -p 80:80 -p 443:443 --name somniarooms --env-file ./env.prod.local somniarooms:prod
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.
docker run -d -it -p 80:80 -p 443:443 --name somniarooms --env-file ./.env.prod.local --volume=somniarooms_images:/app/public/images:rw --network somniarooms-network somniarooms:prod
If you want your app and DB to comunicate using it's hostname (like on this example) you should create a docker network.
docker network create somniarooms-network
Check deploy docs for complete examples on how to deploy SomniaRooms (backend+frontend) using Docker and Docker-compose.
Examples shown on deploy docs may be out-of-date. Make sure all readme recommendations are applied before use on production.Running the app!
Go to the app address (https://localhost) and it will show Symfony welcome page (or a error when running on prod).
Go to addres https://localhost/setup to inicialize app users and data.
During setup you must configure the admin account.
If you check "Add example data" you will be redirected to example data setup.
Example data can be added anytime at https://localhost/debug/exampleData. There is needed to use a Superadmin account.
Then, you the admin panel is at https://localhost/admin
Logs.
By default logs are saved to /app/var/log on an unamed container volume.
For development, /app/var/log directory is mounted to ./var/log on the local filesystem.
This config can be overriden setting a different mount for /app/var/log when creating the containers.