Dockerized (postgres + nginx + golang + react) starter kit
Only implements users, sessions, password_resets, and a toy post type to demonstrate basic CRUD. PNGR is not a CMS.
- Hot-reload, front and back, including a test-runner for golang changes
- golang-migrate already configured for easy migrations
- sqlc for auto-generated sql bindings and gomock for auto-generated mocks (also rigged with hot-reload!)
- jwt-go cookies with automatic refresh: ready for horizontal scaling
- Simple default middleware for CORS, CSRF, cookie parsing, etc.
- A golang worker container stubbed out for async (non-API) tasks
- "Server-side rendering" with a prerender sidecar container
- Unejected Create React App as the basis for the front-end
- React Router for front-end routing
- httprouter for simple back-end routing
- Uses React Context for global user state
- Functional-style components throughout, including some helpful custom hooks to simplify building forms
- Semantic UI React for component library - allows changing theme variables with hot-reload
- Feature development is up to you!
Install docker && docker-compose
# clone the repo
git clone https://github.com/karlkeefer/pngr.git my_project_name
# copy the .env template for your local version
cp .env.example .env
# build and start the containers
docker-compose up- Visit
https://localhost(note https) - Approve the self-signed cert
- Make changes to go, sql, or react code, and enjoy hot-reload goodness!
Migrations are created and run using simple wrappers around go-migrate.
# create files for a new migration
postgres/new my_migration_name
# execute any new migrations (this is also run automatically the container is created)
postgres/migrate up
# go down 1 migration
postgres/migrate down 1
# goto a migration by index
postgres/migrate goto 3# remember to use \q to exit
postgres/psqlMaybe your postgres went sideways from a wonky migration and it's easier to restart from scratch.
docker-compose down -v && docker-compose up --build --force-recreateWarning: Run in production at your own risk!
docker-compose.prod.yml is designed for a setup where postgresql is not dockerized. Pulling images from a registry and/or using CI/CD is up to you.
Don't forget to copy .env.example -> .env and setup your secrets/passwords for the new environment!
At minimum you'll need to change ENV, APP_ROOT, and TOKEN_SECRET!
# build production images, and run them in a detached state
docker-compose -f docker-compose.prod.yml up --build -d