PNGR – Docker-compose for a Postgres-Nginx-Golang-React stack
source link: https://github.com/karlkeefer/pngr
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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
alpine
Requirements
- Install docker && docker-compose
Quick Start
-
sudo docker-compose up
- Visit
https://localhost
( note https ) - Approve the self-signed cert
- Make changes to either golang or react code, and enjoy hot-reload goodness!
Preview 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 hithttp://localhost
in your browser
- e.g. From project root you can run
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 sudo postgres/run-migrations.sh
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:
- Create React App (unejected!)
- React Router
- Unstated for state management
- Semantic UI React for component library
Recommend
-
8
在 GoLang 中使用 Docker Compose 运行 Go 应用程序 在 GoLang 中使用 Docker Compose 运行 Go 应用程序 今天,我们将继续有关如何使用 Docker 运行和...
-
11
In this article, we are going to use Docker Compose to run our Laravel application using Nginx, PHP, and MySQL. In the end, we will get three separate service containers.An app service containerA db
-
21
查看中文版本 Introduction LAMP is a suitable software bundle for building dynamic web sites and web applications. With Docker, we can quickly build web services using LAMP and d...
-
7
在上一篇文章《使用Docker-Compose部署单节点ELK》中讲述了如何使用Docker-Compose创建一个单节点的ELK服务;但是目前在整个ELK-Stack中还包括了Filebeat进行日志采集; 本文在上一篇文章的基础之上在服务中添加了Filebeat,形成了目前业界比较常用的完...
-
11
V2EX › Go 关于 docker-compose 搭建 golang 本地开发环境的问题 SimbaPeng · 2 天前 · 720 次...
-
5
Tutorial How To Set Up Laravel, Nginx, and MySQL With Docker Compose on Ubuntu 20.04 Nginx
-
8
-
5
Why you should split your env file with docker-compose and docker swarm stack an...
-
6
Spring Boot 3.0 (二十六):Docker Compose + Spring Boot + Nginx + Mysql 实践 2023/01/26...
-
6
Rotating nginx logs using Docker Compose and logrotatePublished on Saturday, December 30, 2023Photo by
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK