Course Overview
Locked video preview

Paid video

Please purchase the course to watch.

Deploying a binary

Deploying part one

Here is a summary of the video transcript:

  • Database Migrations Strategy
    The application must apply database migrations before running in production. Migrations can be executed via a deployment pipeline or automatically on application startup. They must be backward-compatible and applied incrementally to avoid breaking a running system.

  • Implementing Migrations with Goose
    A runMigrations function is created using the Goose library with PostgreSQL. Migration files are embedded using Go's embed package, and migrations are executed programmatically during application startup with proper error handling and logging.

  • Timestamp vs Sequential Migration IDs
    During development, timestamp-based migrations prevent conflicts between multiple developers. Before production, migrations are converted to sequential numbering to ensure deterministic ordering, simpler auditing, and eliminate merge conflicts.

  • Rebuilding and Resetting the Database
    After converting migration IDs, the database must be dropped and recreated to reapply migrations cleanly. This ensures consistency with the new sequential versioning scheme.

  • Building a Production Binary
    A build command compiles a static Linux binary using CGO_ENABLED=0 and cross-compilation. Linker flags strip debugging information to reduce binary size, and -mod=readonly ensures reproducible builds.

  • Initial Admin User Creation
    On first deployment, an admin user is manually inserted into the production database. This temporary step simplifies initial access and is removed after deployment.

  • Deploying the Application Binary
    The compiled binary is transferred to the server using scp with an SSH configuration. This prepares the application for execution on the production server.