- Renamed Request/Response items as well.
SomniaRooms
A Hotel Room booking system.
Powered by:
- PHP Symfony.
- Easyadmin.
Commands:
Build containers:
docker compose build --no-cache
Start Containers:
docker compose up --pull always -d --wait
docker compose --env-file .\.env.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
Prod:
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:
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)
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
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.
Then, you the admin panel is at https://localhost/admin
You may login using default admin user:
user: admin
pass: admin