in

karlkeefer / pngr, Hacker News

karlkeefer / pngr, Hacker News


                    

        

Dockerized (postgres nginx golang react) starter kit

Only implements basic user signup, session management, and a toyposttype to demonstrate basic CRUD. PNGR isnota CMS.

Features

  • Hot-reload, front and back, including a test-runner for golang changes
  • JSON Web-Token cookies with automatic refresh: ready for horizontal scaling
  • Usesalpineimages for small footprint
  • Feature development is up to you!

Requirements

  • Install docker && docker-compose

Quick Start

  1. sudo docker-compose up
  2. Visithttps: // localhost( (note) https)
  3. Approve the self-signed cert
  4. Make changes to either golang or react code, and enjoy hot-reload goodness!

Preview of the app:

Screenshot of the app

Rebuilding your dev environment

Maybe your postgres went sideways from a wonky migration and you don’t want to muck with fixing it.

sudo docker-compose down -v && sudo docker-compose up --build --force-recreate

Deploying to Production

Warning: Run in production at your own risk – this code is not security hardened!

Everyone’s production deployment will look different, but some thoughts:

  • (P) Consider running an actual postgres instance. Running a production database in docker makes me sweat.
  • NLook atnginx / nginx.prod.conffor ideas on what a production configuration might look like.
  • GUsegolang / Dockerfile.prod
  • RUsereact / Dockerfile.prod
    • e.g. From project root you can runsudo docker build -t react-prod -f react / Dockerfile.prod react
    • Test it out withsudo docker run --net=host react-prodthen hithttp: // localhostin your browser

Postgres

Some tips for working with your postgres docker instance

Creating and running migrations

Migrations are run using (go-migrate) ****************

I put together little bash scripts to help you get stuff done.

  • sudo postgres / new-migration.sh my_migration_namewill create a template for the next migration.
  • sudo postgres / run-migrations.shwill execute any new Migrations

You can do more advanced migrate commands

Opening a psql client

sudo docker-compose exec postgres psql -U postgresRemember to use qto exit.


Nginx

Nginx is simply used to route requests to the front-end and back-end based on path. It also terminates SSL so that we don’t have to deal with certs in our app layer.


Golang

Almost-vanilla golang api:

  • Makes use of go modules for dependencies
  • jwt-gpfor JSON Web Tokens
  • (sqlx) for better postgres interface

React

The basic building blocks of the front-end are:

  

Brave Browser
(Read More)
Payeer

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *

GIPHY App Key not set. Please check settings

BOLLINGER B2 – BOLLINGER MOTORS, Hacker News

BOLLINGER B2 – BOLLINGER MOTORS, Hacker News

leandromoreira / digital_video_introduction, Hacker News

leandromoreira / digital_video_introduction, Hacker News