
Show HN: PNGR – Docker-compose for a Postgres-Nginx-Golang-React stack - karlkeefer
https://github.com/karlkeefer/pngr
======
karlkeefer
The purpose of this project was to get a docker-compose setup with good
developer ergonomics.

Basically you should just be able to `docker-compose up` and start hacking at
front-end or back-end code and have hot reloading of both _just work_.

I aimed to keep things pretty minimal. With some effort you can swap Redux for
Unstated, pick a different component library, swap my api router for gorilla
mux, whatever you want.

Happy to make changes based on feedback. I'm _sure_ this could be improved
with more eyes on it.

Enjoy :)

~~~
brian_herman
Is a requirement of this framework to only use PNG for graphics? On a more
serious note this is awesome! Good job PNGR would be great for a new project.

~~~
Operyl
I can't tell if it was a joke, but just in case someone else has problems:

Postres

Nginx

Golang

React

So .. nope! :)

~~~
thegeekpirate
It's in the title of this very submission =b

~~~
Operyl
Yup! Which in some cases would get truncated, i.e. in the HN interface itself:
"Show HN: PNGR – Docker-compose for a Postgres-Ngin...".

~~~
capableweb
Neither web or the mobile site seems to truncate the title so not sure what
"HN interface itself" you're referring to. Maybe you're using a third-part
client?

~~~
Operyl
Despite all my downvoters ... when you’re in single comment view the text most
definitely is truncated on both desktop and mobile :).

~~~
capableweb
That's absolutely true! Haven't noticed that before. I guess me and most
people don't look for the title while responding to a comment.

~~~
Operyl
Believe it or not, I generally find myself in these submissions based on
viewing comments from
[https://news.ycombinator.com/newcomments](https://news.ycombinator.com/newcomments)
. So yeah, just a bit jarring seeing so many people basically use the downvote
button to call me a liar.

------
mkesper
Uses alpine images for small footprint

That's really become a docker meme. Please be aware you're sacrificing
performance due to not using glibc.

~~~
kjeetgill
I hadn't heard this before, also sold by small image sizes. What is the big
performance weakness of mscl vs glibc?

Anything beyond binary size vs shared pages?

~~~
the8472
glibc has thread-local pools for malloc, afaik musl uses locks.

~~~
arcticfox
I'm very weak when it comes to stuff at this level but this sounds like it
might be something I really want to know. If I want to run Python or Ruby,
what is the practical downside to Alpine? Am I understanding correctly that
Python or Ruby interpreters built to run on Alpine use musl instead of glibc,
and that might have very noticeable performance impacts?

This thread is opening my eyes, I kind of assumed as long as I was running the
right version of those interpreters, I was getting more or less the same
thing. That feels like a very bad assumption now.

~~~
capableweb
As always when it comes to performance, you should measure the difference
yourself and see if it's a switch worth doing for your use case. "very
noticeable performance impacts" depends so much on the context that it's hard
to answer in a general way.

------
llimllib
I strongly recommend against using the Postgres alpine image, sorting is
irrevocably broken on it. Cf:
[https://stackoverflow.com/questions/58135353/postgres-
seems-...](https://stackoverflow.com/questions/58135353/postgres-seems-to-be-
ignoring-my-default-collation)

~~~
karlkeefer
Thanks - I haven't really put any of this "through the motions" so hadn't
encountered that yet.

Thankfully it's a one word change :)

------
qzw
An acronym that’s pronounceable is more likely to become popular, e.g. LAMP,
CRUD, etc. I guess you could say PNGR like “pinger”, but it’s a bit awkward.
So I suggest a slightly modified acronym: PRNGL, pronounced as “Pringle”. The
L of course stands for Linux. So now you can tell people “it’s running on the
PRNGL stack.” One downside is that PRNG is already a well-known acronym. But
so is PNG, so I don’t think it’s any worse than PNGR in that respect. On the
plus side, the PRNGL stack sounds pretty tasty.

~~~
jsjohnst
I’m not sure what you are on about there. PNGR is as pronounceable as PRNGL
is, in fact they even have the exact same dropped vowels (i followed by an e).
You even have to force in an unnecessary extra word which devalues your
acronym imho.

Personally, my issue with PRNGL is that it makes me think it has something to
do with random numbers (PRNG should make most think of pseudo random number
generator). The same argument could of course validly be made by someone about
PNG being a common acronym too, but for some reason PNGR doesn’t make me
immediately think it has to do with image formats, where as PRNGL does make me
think random numbers. My own mental biases are likely a factor there.

------
consultutah
Very cool. I’ve been thinking of doing the same for a .net core app and maybe
a couple other common frameworks. Might be PITA to keep up to date though.

~~~
karlkeefer
Thanks!

I actually made this over a year ago, and just this week updated all the deps
in order to make it public.

There were thankfully few breaking changes, though I did burn like an hour
debugging a weird dependency that wasn't compatible with golang 1.13 modules.
So it goes!

So I guess only a slight PITA so far haha

------
Zamicol
Nginx seems like one more layer of trouble. Why not just use Go?

~~~
dthul
I almost always use a reverse proxy for some or all of the following:

\- Serving static files

\- Not needing to care about binding your application to a privileged port
(below 1024)

\- SSL certificate handling

\- Hosting several applications on the same IP

For a minimal development setup you might not need it though, depends on what
you want to do I guess.

~~~
aphextron
> "I almost always use a reverse proxy for some or all of the following:

\- Serving static files

\- Not needing to care about binding your application to a privileged port
(below 1024)

\- SSL certificate handling

\- Hosting several applications on the same IP"

All of this should be handled at a higher level with load balancers doing your
SSL termination, and CDN for static files. There's no reason your application
server should care about any of that stuff.

~~~
dthul
I mostly work on small scale stuff. There is nothing to load balance if you
only have one machine :D

And for development you probably don't want to use a CDN.

Edit: it just occurred to me that a load balancer is nothing but a reverse
proxy anyway. Running on a different machine usually, but not really different
from nginx on the local machine from the point of view of the application
software.

------
haxterstockman
"write some tests, you animal", issue created a year ago

~~~
quickthrower2
9 hours ago this issue was update to capitalise the W. So there’s progress!

~~~
karlkeefer
Hear, hear! I'm 90% of the way there, now.

------
aloknnikhil
Docker with the TCP proxy absolutely destroys network performance (unless you
use the host network). Just beware. Hot-reloading is really neat! Good work.

~~~
karlkeefer
I looped back and setup a docker-compose.prod file that utilizes host
networking (and addresses some of the other issues raised in these comments).
Thanks for the heads up :)

------
cdbattags
I've been meaning to benchmark but NGINX in a container like this kinda wrecks
performance in most cases.

The situations you stand up a container infrastructure these days you usually
always already have a cloud load balancer like an ALB in AWS in front of it.

~~~
karlkeefer
I have some sketch notes in the readme outlining production strategy that
doesn't depend on using containerized nginx (or postgres), but I should make
that more clear.

------
dead_mall
The other day, I just made my first, something a lot similar:
postgres+nginx+python+php, but yours is much more proper than mine. Yours is
the example I really needed, thank you

~~~
karlkeefer
Glad it's helpful for you!

------
disposedtrolley
Dammit, I spent the other weekend cobbling together something similar for my
side project!

I'm definitely going to have a close look and migrate most of the components
over. Thanks!

~~~
karlkeefer
If you find anything silly please open an issue or pull request! This thing
does _not_ have all the kinks worked out.

------
veeralpatel979
Thanks for sharing! Having a tool like this makes me a lot more willing to
start new projects.

Created a couple GitHub issues for you with ideas to make this project even
better :)

~~~
karlkeefer
Appreciate that! Will try to implement some of the improvements that popped
out in this thread, as well.

------
Beltiras
I don't get it. Maybe I'm just the fish asking what water is but this doesn't
look like anything special. What is there to fawn over and swoon? Maybe I
don't see it because I use Docker 4 Development daily?

~~~
karlkeefer
The whole repo is largely just a shortcut for folks that haven't set something
like this up before. Nothing _special_ \- just aiming for _useful_.

------
kissgyorgy
You might not need nginx if you are using Go. I would only add it if
neccessary.

~~~
y4mi
are you seriously telling people that they should run their application as
root?

you do know that ports <1000 (http: 80, https: 443) require root, right?

~~~
jsjohnst
These are containers, why on earth would you assume an app needs to run on a
privileged port? You just run the app in the container on say 8080 or 8443
inside the container and expose it outside the container as 80 or 443
respectively.

~~~
y4mi
Ha, i literally forgot about that. Despite using docker every other day.
Thanks for correcting me

------
roberson87
The language is called Go not golang [1].

[1]
[https://twitter.com/rob_pike/status/886054143235719169?lang=...](https://twitter.com/rob_pike/status/886054143235719169?lang=en)

~~~
ernst_klim
Good luck searching for "go" in the internet.

~~~
roberson87
I also use 'golang' exclusively when searching for go related stuff :) doesn't
take away my point.

