:earth_americas: a 4MB alpine based nginx docker image, but carried with a
configurable cache among other features
Built to be part of your project
Why did you built a nginx/alpine image?
Say WHAATT?? I search a lot, I really do, but unfortunatelly I like to customize
things, get my hands dirty on and make things work. Unfortunatelly most of the
images I've seen have something missing or don't have what I need for now.
As so, I've developed an image which can grant you TOTAL ACCESS to the
(Well, part of that its true, whenever you need something this doesn't have,
create an Issue)
- Cache control
- CORS headers as options
- Enhanced for static content
How to use it?
I've provided an hello world example so you can easily understand how you can
couple it with your project.
Create a Dockerfile based on the latest tag
FROM cusspvz/nginx:latest MAINTAINER God <firstname.lastname@example.org>
Tell me where your public stuff is
Computer isn't smart, yet, and I didn't developed an html/css/js auto-finder,
so you must tell your image where you save the precious juice.
Imagine that you have it under
public/ on the root of your project.
Just set up your Dockerfile like this:
FROM cusspvz/nginx:latest MAINTAINER God <email@example.com> ADD public/ /pub
And you're ready to set!
Building up the image
docker build -t dockerusername/yolo .
docker run -ti -p 80:80 dockerusername/yolo
Seems easy, but do you have a
onbuild tag, how does it work?
Hell yeah it is.
You can use the
onbuild tag ONLY if you have your public goods on
That is the only thing the
onbuild does, adding a folder as
FROM cusspvz/nginx:onbuild MAINTAINER God <firstname.lastname@example.org>
Here's the good part!!! :D
Allows you to change the target root directory inside the container.
NOTE: If you change this, you will need to change your public content
statements as well.
Sets the path of the generated nginx config gile.
Change this if you need to serve more connections
Sets the listening http port.
NOTE: If you change this you will also to have sure you set the right port
whenever you run a new container based on your image.
NOTE: Change if this isn't the charset you're using.
We already compress assets, if you have more assets you need to compress, please
change this line. If you think I've missed some of them here, please PR the
changes or open a new Issue! :)
I like to maintain compression somewhere in the middle, so we can average the
network vs cpu usage.
We're ignoring cache for HTMLs because they are usually who target other assets.
Feel free to set this empty in case you need to cache them.
All html assets should be cached, so you can have a fast website and a great SEO.
By default, I believe all your static assets should live, at least, for a year
on your visitors computer. If you disagree, feel free to change.
GET, POST, OPTIONS
Now you can: sayy WHHAAAATTT??
Feel free to create Issues or Pull Requests.