9 ms·
Show HN: PNGR – Docker-compose for a Postgres-Nginx-Golang-React stack
- karlkeefer 7y agoThe 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 7y agoIs 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 7y agoI can't tell if it was a joke, but just in case someone else has problems: Postres Nginx Golang React So .. nope! :)
- thegeekpirate 7y agoIt's in the title of this very submission =b
- Operyl 7y agoYup! Which in some cases would get truncated, i.e. in the HN interface itself: "Show HN: PNGR – Docker-compose for a Postgres-Ngin...".
- capableweb 7y agoNeither 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 7y agoDespite all my downvoters ... when you’re in single comment view the text most definitely is truncated on both desktop and mobile :).
- capableweb 7y agoThat'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 7y agoBelieve 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.
- codedokode 7y agoThis is bad ergonomics because to use it the developer has to install Docker which is a monster made by commercial company and run with root privileges. It's privileges are enough to gather "telemetry" including you browser cookies and history, install and uninstall software or delete all files on your hard drive. Why would anyone want to run such dangerous daemon I don't understand. Also on Windows and Mac Docker user virtual machines with worse performance. It is OK to install Docker on a throwaway VPS, or in office, but not on your own machine. Instead of this poor designed technology it is better to use portable programs (which can be downloaded in binary form to avoid compilation) and collection of bash scripts. Then you won't have to install the aforementioned proprietary daemon.
- consultutah 7y agoVery 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 7y agoThanks! 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
- clintonb 7y agoGo for it! I made my own cookiecutter template for Django: https://github.com/clintonb/cookiecutter-django https://github.com/clintonb/cookiecutter-django. My main goal was to get projects running faster. Updates every 6-12 months are fine. Alternatively, update when you are ready to start the next project, or shortly after you’ve made significant changes to the most recent project. For example, my latest project has a React frontend. I’ll incorporate that back into my cookiecutter after I’ve worked out various issues.
- haxterstockman 7y ago"write some tests, you animal", issue created a year ago
- quickthrower2 7y ago9 hours ago this issue was update to capitalise the W. So there’s progress!
- karlkeefer 7y agoHear, hear! I'm 90% of the way there, now.
- karlkeefer 7y agoGuilty as charged. In my defense the repo sat unchanged for almost the entire year haha
- disposedtrolley 7y agoDammit, 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 7y agoIf you find anything silly please open an issue or pull request! This thing does not have all the kinks worked out.
- veeralpatel979 7y agoThanks 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 7y agoAppreciate that! Will try to implement some of the improvements that popped out in this thread, as well.
- kissgyorgy 7y agoYou might not need nginx if you are using Go. I would only add it if neccessary.
- y4mi 7y agoare 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?
- zrail 7y agoYou only need root to open the port. Once you do that you can drop privileges.
- jsjohnst 7y agoThese 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 7y agoHa, i literally forgot about that. Despite using docker every other day. Thanks for correcting me
- vhodges 7y agosudo apt-get install libcap2-bin # Debian/Ubuntu/etc sudo setcap 'cap_net_bind_service=+ep' /path/to/program will allow program to bind low numbered ports by non-root user. Just learned this deploying a new rails app behind caddy2 (which is running as the deploy user I setup).
- kissgyorgy 7y agoI'm not and what does it have to do with what I said? :) Do you know that nginx must be running as root, right?
- karlkeefer 7y ago
- Zamicol 7y agoNginx seems like one more layer of trouble. Why not just use Go?
- zwarag 7y agoSsl certificate Reverse Proxy for possible load balancing?
- todotask 7y agoIf it was my case, I still undecided which reverse proxy can replace Nginx, however, there are no known performance benchmarks for Caddy 2 I could refer to. Nginx was designed to handle backend services easily and programmers from different background may not be well verse in Golang at the beginning.
- sneak 7y agoIt is generally repeated that the Go stdlib webserver is internet-facing-ok and production-ready (with appropriate timeouts being set on the http.Server), making a reverse proxy unnecessary. There are also dead-simple TLS libraries, some that will even get LE certs automatically.
- todotask 7y agoAgreed, I have recently built a web server entirely (with timeouts) in Go too and acme.sh for LE certs but I still haven't find a way to support Wordpress from Go to PHP-FPM, I'm not well verse to fix the only this part, if you have any suggestion is greatly appreciate.
- dthul 7y agoI 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.
- dead_mall 7y agoThe 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
- deleted 7y ago[deleted]
- karlkeefer 7y agoGlad it's helpful for you!
- qzw 7y agoAn 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.
- ryanhuff 7y agoHow about PLNGR (plunger)?
- deleted 7y ago[deleted]
- Tim0theus 7y agoI liked PNGR, sounds like Pee-eN-Gee-Er in my head.
- jsjohnst 7y agoI’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.
- mkesper 7y agoUses 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 7y agoI 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 7y agoglibc has thread-local pools for malloc, afaik musl uses locks.
- arcticfox 7y agoI'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 7y agoAs 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.
- jiux 7y ago> also sold by small image sizes. Out of curiosity, what sold you on this? Has caching of a docker image been considered in this conclusion as well?
- roberson87 7y agoThe language is called Go not golang [1]. [1] https://twitter.com/rob_pike/status/886054143235719169?lang=en https://twitter.com/rob_pike/status/886054143235719169?lang=...
- ernst_klim 7y agoGood luck searching for "go" in the internet.
- roberson87 7y agoI also use 'golang' exclusively when searching for go related stuff :) doesn't take away my point.
- cdbattags 7y agoI'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 7y agoI 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.
- llimllib 7y agoI strongly recommend against using the Postgres alpine image, sorting is irrevocably broken on it. Cf: https://stackoverflow.com/questions/58135353/postgres-seems-to-be-ignoring-my-default-collation https://stackoverflow.com/questions/58135353/postgres-seems-...
- karlkeefer 7y agoThanks - I haven't really put any of this "through the motions" so hadn't encountered that yet. Thankfully it's a one word change :)
- aloknnikhil 7y agoDocker with the TCP proxy absolutely destroys network performance (unless you use the host network). Just beware. Hot-reloading is really neat! Good work.
- karlkeefer 7y agoI 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 :)
- Beltiras 7y agoI 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 7y agoThe whole repo is largely just a shortcut for folks that haven't set something like this up before. Nothing special - just aiming for useful.