Coder Social home page Coder Social logo

faisal-w / pngr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from karlkeefer/pngr

0.0 1.0 0.0 744 KB

dockerized (postgres + nginx + golang + react)

License: MIT License

Go 44.57% HTML 1.05% JavaScript 48.82% CSS 0.48% Dockerfile 1.92% Shell 2.56% TSQL 0.60%

pngr's Introduction

PNGR Stack

Dockerized (postgres + nginx + golang + react) starter kit

Only implements basic user signup, session management, and a toy post type to demonstrate basic CRUD. PNGR is not a 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
  • Uses alpine images for small footprint
  • Feature development is up to you!

Requirements

  • Install docker && docker-compose

Quick Start

  1. sudo docker-compose up
  2. Visit https://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.
  • N Look at nginx/nginx.prod.conf for ideas on what a production configuration might look like.
  • G Use golang/Dockerfile.prod
  • R Use react/Dockerfile.prod
    • e.g. From project root you can run sudo docker build -t react-prod -f react/Dockerfile.prod react
    • Test it out with sudo docker run --net=host react-prod then hit http://localhost in 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_name will create a template for the next migration.
  • sudo postgres/run-migrations.sh will execute any new migrations

You can do more advanced migrate commands

Opening a psql client

sudo docker-compose exec postgres psql -U postgres Remember to use \q to 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-gp for JSON Web Tokens
  • sqlx for better postgres interface

React

The basic building blocks of the front-end are:

pngr's People

Contributors

karlkeefer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.