initial import from https://git.mau.ro/mauro/ansible-role-nginx-docker
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
459edd803a
commit
a60e889530
55
.drone.yml
Normal file
55
.drone.yml
Normal file
@ -0,0 +1,55 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
- name: build and publish image
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: eumau/nginx
|
||||
auto_tag: true
|
||||
username:
|
||||
from_secret: dockerhub_username
|
||||
password:
|
||||
from_secret: dockerhub_password
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: pull_request
|
||||
|
||||
steps:
|
||||
- name: build image only
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: eumau/nginx
|
||||
auto_tag: true
|
||||
dry_run: true
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- pull_request
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: tags
|
||||
|
||||
steps:
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: eumau/nginx
|
||||
username:
|
||||
from_secret: dockerhub_username
|
||||
password:
|
||||
from_secret: dockerhub_password
|
||||
tags:
|
||||
- ${DRONE_TAG}
|
||||
build_args:
|
||||
- NGINX_VERSION=${DRONE_TAG}
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,6 +1,3 @@
|
||||
*~
|
||||
\#*
|
||||
.#*
|
||||
*.pyc
|
||||
*.bak
|
||||
__pycache__
|
||||
|
@ -1,6 +1,6 @@
|
||||
# nginx container with self-signed SSL certificates
|
||||
FROM nginx
|
||||
MAINTAINER Mauro Torrez <in@mau.ro>
|
||||
ARG NGINX_VERSION=latest
|
||||
FROM nginx:${NGINX_VERSION}
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y -q ssl-cert \
|
@ -1,23 +0,0 @@
|
||||
---
|
||||
# nombre del container
|
||||
nginx_container_name: nginx
|
||||
|
||||
# nombre de la imagen
|
||||
nginx_image_name: my_nginx
|
||||
|
||||
# nombre del volumen de configuracion
|
||||
nginx_config_volume: nginx_config
|
||||
|
||||
# nombre del volumen ssl
|
||||
nginx_ssl_volume: nginx_ssl
|
||||
|
||||
# nombre del volumen web
|
||||
nginx_webroot_volume: nginx_webroot
|
||||
|
||||
# nombre del volumen location
|
||||
nginx_location_volume: nginx_location
|
||||
|
||||
# puertos a publicar
|
||||
nginx_publish_ports:
|
||||
- 80:80
|
||||
- 443:443
|
@ -1,6 +0,0 @@
|
||||
---
|
||||
- name: restart nginx container
|
||||
docker_container:
|
||||
name: nginx
|
||||
state: started
|
||||
restart: yes
|
@ -1,18 +0,0 @@
|
||||
---
|
||||
# template domain config
|
||||
# vars: ng_domain_secure (True)
|
||||
# ng_domain_flags (['http2'])
|
||||
# ng_domain_name (no default)
|
||||
# ng_domain_root ('/usr/share/nginx/html')
|
||||
# ng_domain_common_locations (True)
|
||||
|
||||
- name: domain locations directory
|
||||
file:
|
||||
path: "{{ nginx_location_mountpoint }}/{{ ng_domain_name }}"
|
||||
state: directory
|
||||
|
||||
- name: template domain config
|
||||
template:
|
||||
src: domain.conf.j2
|
||||
dest: "{{ nginx_config_mountpoint }}/{{ ng_domain_name }}.conf"
|
||||
notify: restart nginx container
|
@ -1,12 +0,0 @@
|
||||
---
|
||||
# template domain config
|
||||
# ng_domain_name (no default)
|
||||
# ng_location_name (no default)
|
||||
# ng_location_content (no default)
|
||||
|
||||
- name: template location config
|
||||
template:
|
||||
src: location.conf.j2
|
||||
dest: "{{ nginx_location_mountpoint }}/{{ ng_domain_name }}/{{
|
||||
ng_location_name|regex_replace('[^0-9a-zA-Z_.-]','_') }}.conf"
|
||||
notify: restart nginx container
|
@ -1,78 +0,0 @@
|
||||
---
|
||||
- name: Directorio de build nginx
|
||||
file:
|
||||
path: /root/.nginx-docker-image
|
||||
state: directory
|
||||
tags: skip_me
|
||||
|
||||
- name: Copiar archivos de build
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: /root/.nginx-docker-image
|
||||
loop:
|
||||
- Dockerfile
|
||||
- nginx.conf
|
||||
- dhparams.pem
|
||||
- default.conf
|
||||
tags: skip_me
|
||||
|
||||
- name: Crear imagen my_nginx
|
||||
docker_image:
|
||||
state: present
|
||||
name: "{{ nginx_image_name }}"
|
||||
path: /root/.nginx-docker-image
|
||||
tags: skip_me
|
||||
|
||||
- name: Activar container nginx
|
||||
docker_container:
|
||||
name: "{{ nginx_container_name }}"
|
||||
state: started
|
||||
restart_policy: unless-stopped
|
||||
image: "{{ nginx_image_name }}"
|
||||
volumes:
|
||||
- "{{ nginx_ssl_volume }}:/etc/nginx/ssl/"
|
||||
- "{{ nginx_config_volume }}:/etc/nginx/conf.d/"
|
||||
- "{{ nginx_location_volume }}:/etc/nginx/location/"
|
||||
- "{{ nginx_webroot_volume }}:/usr/share/nginx/html/"
|
||||
networks:
|
||||
- name: "{{ docker_network_name }}"
|
||||
ports: "{{ nginx_publish_ports }}"
|
||||
env:
|
||||
register: container
|
||||
|
||||
- name: Leer info de volumen {{ nginx_config_volume }}
|
||||
docker_volume_info:
|
||||
name: "{{ nginx_config_volume }}"
|
||||
register: res_cnf
|
||||
|
||||
- name: Leer info de volumen {{ nginx_ssl_volume }}
|
||||
docker_volume_info:
|
||||
name: "{{ nginx_ssl_volume }}"
|
||||
register: res_ssl
|
||||
|
||||
- name: Leer info de volumen {{ nginx_webroot_volume }}
|
||||
docker_volume_info:
|
||||
name: "{{ nginx_webroot_volume }}"
|
||||
register: res_web
|
||||
|
||||
- name: Leer info de volumen {{ nginx_location_volume }}
|
||||
docker_volume_info:
|
||||
name: "{{ nginx_location_volume }}"
|
||||
register: res_loc
|
||||
|
||||
- name: Exportar informacion de volumenes
|
||||
set_fact:
|
||||
nginx_container_name: "{{ lookup('vars','nginx_container_name') }}"
|
||||
nginx_config_volume: "{{ lookup('vars','nginx_config_volume') }}"
|
||||
nginx_config_mountpoint: "{{ res_cnf.volume.Mountpoint }}"
|
||||
nginx_location_volume: "{{ lookup('vars','nginx_location_volume') }}"
|
||||
nginx_location_mountpoint: "{{ res_loc.volume.Mountpoint }}"
|
||||
nginx_webroot_volume: "{{ lookup('vars','nginx_webroot_volume') }}"
|
||||
nginx_webroot_mountpoint: "{{ res_web.volume.Mountpoint }}"
|
||||
nginx_ssl_volume: "{{ lookup('vars','nginx_ssl_volume') }}"
|
||||
nginx_ssl_mountpoint: "{{ res_ssl.volume.Mountpoint }}"
|
||||
|
||||
- name: default location dir
|
||||
file:
|
||||
path: "{{ nginx_location_mountpoint }}/default"
|
||||
state: directory
|
@ -1,24 +0,0 @@
|
||||
{% if ng_domain_secure|default(True) %}
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
# redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
server {
|
||||
{% if not ng_domain_secure %}
|
||||
listen 80 {{ ng_domain_flags | default(['http2']) | join(' ') }};
|
||||
listen [::]:80 {{ ng_domain_flags | default(['http2']) | join(' ') }};
|
||||
{% endif %}
|
||||
listen 443 ssl {{ ng_domain_flags | default(['http2']) | join(' ') }};
|
||||
listen [::]:443 ssl {{ ng_domain_flags | default(['http2']) | join(' ') }};
|
||||
|
||||
server_name {{ ng_domain_name | regex_replace('^default$','_') }};
|
||||
root {{ ng_domain_root|default('/usr/share/nginx/html') }};
|
||||
include locations/{{ ng_domain_name }}/*.conf;
|
||||
{% if ng_domain_common_locations | default(True) %}
|
||||
include locations/common/*.conf;
|
||||
{% endif %}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
location {{ ng_location_name }} {
|
||||
{{ ng_location_content }}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user