a 4MB alpine based nginx docker image, but carried with a configurable cache among other features
GPL-3.0 License
🌎 a 4MB alpine based nginx docker image, but carried with a configurable cache among other features
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 nginx.conf file. (Well, part of that its true, whenever you need something this doesn't have, create an Issue)
I've provided an hello world example so you can easily understand how you can couple it with your project.
Dockerfile
FROM cusspvz/nginx:latest
MAINTAINER God <[email protected]>
Easy right?
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:
Dockerfile
FROM cusspvz/nginx:latest
MAINTAINER God <[email protected]>
ADD public/ /pub
And you're ready to set!
docker build -t dockerusername/yolo .
docker run -ti -p 80:80 dockerusername/yolo
onbuild
tag, how does it work?Hell yeah it is.
You can use the onbuild
tag ONLY if you have your public goods on public/
.
That is the only thing the onbuild
does, adding a folder as /pub
Dockerfile
FROM cusspvz/nginx:onbuild
MAINTAINER God <[email protected]>
Here's the good part!!! :D
/pub
Allows you to change the target root directory inside the container.
NOTE: If you change this, you will need to change your public content ADD
statements as well.
/etc/nginx/boot.conf
Sets the path of the generated nginx config gile.
1024
Change this if you need to serve more connections
80
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.
$uri $uri/ $uri/index.html index.html
Allows you to change the file lookup order. Useful for setting up a specific page for a 404.
utf-8
NOTE: Change if this isn't the charset you're using.
application/javascript application/x-javascript application/rss+xml text/javascript text/css image/svg+xml
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! :)
6
I like to maintain compression somewhere in the middle, so we can average the network vs cpu usage.
html
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.
ico|jpg|jpeg|png|gif|svg|js|jsx|css|less|swf|eot|ttf|otf|woff|woff2
All html assets should be cached, so you can have a fast website and a great SEO.
1y
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
DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type
Now you can: sayy WHHAAAATTT??
Feel free to create Issues or Pull Requests.