This repository provides everything you need to run SQLPage locally, including a Docker configuration for PostgreSQL and pgAdmin, environment-based configuration for sensitive data, and automatic database migrations.
Create a file named .env in the project root (next to docker-compose.yml and with your own credentials) with the following content:
POSTGRES_USER=kirkgibson
POSTGRES_PASSWORD=dodgers
PGADMIN_DEFAULT_EMAIL=vinscully@greatest.com
PGADMIN_DEFAULT_PASSWORD=homerun
DATABASE_URL=postgres://kirkgibson:dodgers@localhost:5432/postgresImportant: Add
.envto your.gitignoreso that these sensitive credentials are not committed.
Before running Docker, load the environment variables into your shell by running:
set -o allexport; source .env; set +o allexportThe repository includes a docker-compose.yml configuration file.
From the project root (where your docker-compose.yml is located), run:
docker-compose up -dVerify the containers are running with:
docker-compose psOpen your browser and go to http://localhost:5050. Log in using the credentials from your .env file:
- Email:
vinscully@greatest.com - Password:
homerun
SQLPage uses a configuration file (sqlpage.json) to connect to your database.
Make sure sqlpage.json is in the repository root with the following content:
{
"database_url": "postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/postgres"
}
*** We are using our .env variable to overide the config file here - SQL Page is giving me some difficulties creating a sqlite db by default.Ensure the SQLPage binary is executable:
chmod +x sqlpage.binThen start SQLPage by running:
./sqlpage.binSQLPage will load environment variables from your .env file, read the configuration from sqlpage.json, and automatically scan the sqlpage/migrations directory for migration files. Any new migrations will be applied at startup.
Once SQLPage starts, it will print a message with the URL (by default, http://localhost:8080) where you can view your site.
By following these steps, you'll have a complete local development environment for SQLPage with PostgreSQL and pgAdmin managed via Docker, secure configuration through a .env file, and automatic migration management.