This compose example will provide:
- front-end: nginx server to
- serve frontend assets
- forward requests to the backend
- back-end: Postgrest backend
- database: PostgreSQL server
├── db
│ ├── data # Database data (need root rights to see files)
│ ├── init # Custom scripts to be run on the 1st DB startup
│ └── runtime # Custom migrations
├── docker-compose.yml # Structure the whole application
├── nginx
│ ├── certs # SSL certificates for localhost
│ └── nginx.conf
├── web # Web project root path
│ └── dist # Build path used by nginx to serve web assets
└── README.md
- http://localhost redirecting automatically to 443 port
- https://localhost with following routes:
/api
: postgrest API on /api path/
all assets available in web/dist directory
cd nginx/cert
mkcert localhost
mkcert install
POSTGRES_PASSWORD=AZERTY docker-compose up
Postgrest API are here: https://localhost/api
You can use the web framework of your choice.
The only thing you need is to put your built web assets into the web/dist
directory.
Here we show how to integrate a reactJS project using viteJs:
# Create the project
yarn create vite web --template react
# Build it
cd web
# Download dependencies
yarn
You can use the dev mode and have a server outside of the docker fullstack with:
yarn dev # exposes http://localhost:3000
Or you can build the web application to let nginx serve the assets:
yarn build # access your application through https://localhost
Don't forget to rerun yarn build
every time you want to update the assets for nginx.
You can connect a psql client to your db:
docker exec -it docker-fullstack_db_1 psql -h localhost postgres postgres
Put your sql script in db/init
directory
Place your myscript.sql
file in db/runtime
and run:
docker exec -it docker-fullstack_db_1 psql -h localhost postgres postgres -f /runtime-scripts/myscript.sql
sudo rm -rf db/data/pgdata