-
Notifications
You must be signed in to change notification settings - Fork 39
Update Nginx, add makefile #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Makefile for shipping and testing the container image. | ||
|
|
||
| MAKEFLAGS += --warn-undefined-variables | ||
| .DEFAULT_GOAL := build | ||
| .PHONY: * | ||
|
|
||
| # we get these from CI environment if available, otherwise from git | ||
| GIT_COMMIT ?= $(shell git rev-parse --short HEAD) | ||
| GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) | ||
| WORKSPACE ?= $(shell pwd) | ||
|
|
||
| namespace ?= autopilotpattern | ||
| tag := branch-$(shell basename $(GIT_BRANCH)) | ||
| imageWordpress := $(namespace)/wordpress | ||
| imageNginx := $(namespace)/wordpress-nginx | ||
|
|
||
| #dockerLocal := DOCKER_HOST= DOCKER_TLS_VERIFY= DOCKER_CERT_PATH= docker | ||
| dockerLocal := docker | ||
| #composeLocal := DOCKER_HOST= DOCKER_TLS_VERIFY= DOCKER_CERT_PATH= docker-compose | ||
| composeLocal := docker-compose | ||
|
|
||
| ## Display this help message | ||
| help: | ||
| @awk '/^##.*$$/,/[a-zA-Z_-]+:/' $(MAKEFILE_LIST) | awk '!(NR%2){print $$0p}{p=$$0}' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' | sort | ||
|
|
||
|
|
||
| # ------------------------------------------------ | ||
| # Container builds | ||
|
|
||
| ## Builds the application container image locally | ||
| build: | ||
| $(dockerLocal) build -t=$(imageWordpress):$(tag) . | ||
| cd nginx && $(dockerLocal) build -t=$(imageNginx):$(tag) . | ||
|
|
||
| ## Push the current application container images to the Docker Hub | ||
| push: | ||
| $(dockerLocal) push $(imageWordpress):$(tag) | ||
| $(dockerLocal) push $(imageNginx):$(tag) | ||
|
|
||
| ## Tag the current images as 'latest' | ||
| tag: | ||
| $(dockerLocal) tag $(imageWordpress):$(tag) $(imageWordpress):latest | ||
| $(dockerLocal) tag $(imageNginx):$(tag) $(imageNginx):latest | ||
|
|
||
| ## Push latest tag(s) to the Docker Hub | ||
| ship: tag | ||
| $(dockerLocal) push $(imageWordpress):$(tag) | ||
| $(dockerLocal) push $(imageWordpress):latest | ||
| $(dockerLocal) push $(imageNginx):$(tag) | ||
| $(dockerLocal) push $(imageNginx):latest | ||
|
|
||
|
|
||
| # ------------------------------------------------ | ||
| # Test running | ||
|
|
||
| ## Pull the container images from the Docker Hub | ||
| pull: | ||
| $(dockerLocal) pull $(imageWordpress):$(tag) | ||
| $(dockerLocal) pull $(imageNginx):$(tag) | ||
|
|
||
| ## Print environment for build debugging | ||
| debug: | ||
| @echo WORKSPACE=$(WORKSPACE) | ||
| @echo GIT_COMMIT=$(GIT_COMMIT) | ||
| @echo GIT_BRANCH=$(GIT_BRANCH) | ||
| @echo namespace=$(namespace) | ||
| @echo tag=$(tag) | ||
| @echo imageWordpress=$(imageWordpress) | ||
| @echo imageNginx=$(imageNginx) | ||
|
|
||
| # ------------------------------------------------------- | ||
| # helper functions for testing if variables are defined | ||
| # | ||
| check_var = $(foreach 1,$1,$(__check_var)) | ||
| __check_var = $(if $(value $1),,\ | ||
| $(error Missing $1 $(if $(value 2),$(strip $2)))) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .DS_Store | ||
| **/.DS_Store | ||
| _env* |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| # a minimal Nginx container including containerbuddy and a simple virtulhost config | ||
| FROM autopilotpattern/nginx:1-r6.1.0 | ||
| FROM autopilotpattern/nginx:1.13-r7.0.1 | ||
|
|
||
| # Add our configuration files | ||
| COPY etc /etc |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "consul": "{{ if .CONSUL_AGENT }}localhost{{ else }}{{ .CONSUL }}{{ end }}:8500", | ||
| "preStart": "/usr/local/bin/reload.sh preStart", | ||
| "preStart": "generate-config", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changed after |
||
| "logging": {"level": "DEBUG"}, | ||
| "services": [ | ||
| { | ||
|
|
@@ -32,7 +32,7 @@ | |
| { | ||
| "name": "wordpress", | ||
| "poll": 7, | ||
| "onChange": "/usr/local/bin/reload.sh" | ||
| "onChange": "reload" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changed after |
||
| } | ||
| ], | ||
| "coprocesses": [{{ if .CONSUL_AGENT }} | ||
|
|
@@ -62,14 +62,14 @@ | |
| "help": "Number of accepted connnections that were not handled", | ||
| "type": "gauge", | ||
| "poll": 5, | ||
| "check": ["/usr/local/bin/sensor.sh", "unhandled"] | ||
| "check": ["sensor", "unhandled"] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changed after |
||
| }, | ||
| { | ||
| "name": "nginx_connections_load", | ||
| "help": "Ratio of active connections (less waiting) to the maximum worker connections", | ||
| "type": "gauge", | ||
| "poll": 5, | ||
| "check": ["/usr/local/bin/sensor.sh", "connections_load"] | ||
| "check": ["sensor", "connections_load"] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changed after |
||
| } | ||
| ] | ||
| }, | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| {{ $acme_domain := env "ACME_DOMAIN" }} | ||
| {{ $ssl_ready := env "SSL_READY" }} | ||
|
|
||
| # If we're listening on https, define an http listener that redirects everything to https | ||
| {{ if eq $ssl_ready "true" }} | ||
| server { | ||
| server_name _; | ||
| listen 80; | ||
|
|
||
| include /etc/nginx/health.conf; | ||
|
|
||
| location / { | ||
| return 301 https://$host$request_uri; | ||
| } | ||
| } | ||
| {{ end }} | ||
|
|
||
| # The main server block | ||
| server { | ||
| server_name _; | ||
| # Listen on port 80 unless we have certificates installed, then listen on 443 | ||
| listen {{ if ne $ssl_ready "true" }}80{{ else }}443 ssl{{ end }}; | ||
|
|
||
| include /etc/nginx/health.conf; | ||
|
|
||
| location /.well-known/acme-challenge { | ||
| alias /var/www/acme/challenge; | ||
| } | ||
|
|
||
| {{ if service "wordpress" }} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block inside |
||
| rewrite ^/wp-admin/?(.*) /wordpress/wp-admin/$1; | ||
|
|
||
| location ^~ / { | ||
| proxy_pass http://wordpress; | ||
| proxy_redirect off; | ||
| proxy_set_header Host $http_host; | ||
| proxy_set_header X-Forwarded-Proto $scheme; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| }{{ else }} | ||
| # return 503 errors if we don't have our expected back-end | ||
| location / { | ||
| return 503; | ||
| }{{ end }} | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # This is an example Nginx configuration template file. | ||
| # Adjust the values below as required for your application. | ||
|
|
||
| user nginx; | ||
| worker_processes 1; | ||
|
|
||
| error_log /var/log/nginx/error.log warn; | ||
| pid /var/run/nginx.pid; | ||
|
|
||
| events { | ||
| worker_connections 1024; | ||
| } | ||
|
|
||
| http { | ||
| include /etc/nginx/mime.types; | ||
| default_type application/octet-stream; | ||
|
|
||
| map $status $isNot2xx { | ||
| ~^2 0; | ||
| default 1; | ||
| } | ||
|
|
||
| log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
| '$status $body_bytes_sent "$http_referer" ' | ||
| '"$http_user_agent" "$http_x_forwarded_for" ' | ||
| '$upstream_addr'; | ||
|
|
||
| access_log /var/log/nginx/access.log main; | ||
|
|
||
| sendfile on; | ||
| keepalive_timeout 65; | ||
|
|
||
| {{ $ssl_ready := env "SSL_READY" }} | ||
|
|
||
| {{ if eq $ssl_ready "true" }} | ||
| include ssl.conf; | ||
| {{ end }} | ||
|
|
||
| {{ if service "wordpress" }} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block inside |
||
| upstream wordpress { | ||
| # write the address:port pairs for each healthy wordpress node | ||
| {{range service "wordpress"}} | ||
| server {{.Address}}:{{.Port}}; | ||
| {{end}} | ||
| }{{ end }} | ||
|
|
||
| include conf.d/*.conf; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is waiting on autopilotpattern/prometheus#18