Course Overview
Locked video preview

Paid video

Please purchase the course to watch.

Deploying a binary

Setting up postgres

Here is a summary of the video transcript:

  • Choosing a Self-Hosted Database
    The speaker opts for a self-hosted database on a VPS instead of a managed solution due to cost and learning benefits. Managed databases scale in price quickly, while a VPS setup is sufficient for a small personal project. Self-hosting also improves understanding of database internals and troubleshooting.

  • Installing PostgreSQL on the Server
    PostgreSQL is installed via apt after updating the system. The service is verified to be running using system status commands. This establishes the database infrastructure required before deploying the application.

  • Understanding PostgreSQL Authentication
    PostgreSQL uses roles rather than traditional users and relies on peer authentication by default on Debian/Ubuntu systems. The installation creates a postgres system user and role, which must be used to access the database initially. Access requires matching the Linux username to an existing PostgreSQL role.

  • Creating a Production Database and Role
    A dedicated database and role are created for the application. The role is granted privileges only on the specific database and schema. This prevents the use of a superuser in production, reducing risk if credentials are compromised.

  • Security and Access Configuration
    External database access is disabled by default and limited to localhost. While remote access can be configured, keeping it internal reduces security exposure. Only applications running on the server can access the database.

  • Handling Migrations in Production
    Migrations can be executed at application startup for small projects. In larger setups, CI/CD pipelines (e.g., via GitHub Actions) can manage migrations before deployment. Production migrations must avoid breaking changes and be applied incrementally to prevent downtime.

  • Next Deployment Steps
    The next phase involves deploying the application, running migrations, applying seed data, and configuring a systemd service. Once completed, the application will be ready to go live.