GitHub Repository
Postgres in webapp.io (with Docker)
Postgres & Docker Tutorial
This project will consist of three files in our repository:- init.sql (what we will initialize our database with)
- Dockerfile (the dockerfile for the postgres database)
- Layerfile (the Layerfile for webapp.io)
Initialize the Database
We’re going to be using theroot user for this postgres database. To do so, we’ll create a script to initialize a database called root.
init.sql
Create the Dockerfile
After creating the script to initialize the root database in postgres, we’ll use thepostgres:14-bullseye image from Docker. We’ll set the POSTGRES_USER as root, the POSTGRES_PASSWORD as postgres, and POSTGRES_DB as root.
Create the Layerfile
Once we’ve created the Dockerfile, we can create the Layerfile which will install Docker, build the Docker image, and run the docker image.Layerfile
Entering the Database
To enter the database, click the button “Connect to a debugging terminal” on the Layerfile Runner page, and type in the commandpsql -h localhost -p 5432 to enter the postgres shell.
If you’re prompted to enter a password, enter in postgres.