nginx_docker

Nginx-docker for ansible

Integration Quality Downloads Role

Use Ansible to deploy Docker projects to Nginx with or without https. This role does not really care what language you used to create your app. Created to be used with continuous integration and continuous deployment tools.

Features

  • Builds or uses prebuilt docker image
  • Does not require docker registry
  • Configures https via nginx_project
  • Automatically replaces old versions via project_name

Prerequisities

  • Target user with rights to config nginx
  • Target user with rights to run docker

Install

ansible-galaxy install practical-ansible.nginx_docker

Example playbook

This would be the most usual playbook

---
- name: Deploy to testing Docker container
  hosts: all
  roles:
    - role: practical-ansible.nginx_docker
      vars:
        admin_email: '[email protected]'
        image_local: 'test_app.tar'
        project_port: '3000'
        project_name: 'my-app'
        project_version: '0.1.0'
        server_names: 'localhost,www.localhost'
        use_ssl: true
        env:
          print_this: 'Testing deployment: X Æ A-12'

You can find more examples in the tests directory.

Example CI

There are some more examples of configuration.

Reference manual

Use this to avoid Burnout Syndrome when deploying your Docker wrapped application to nginx.

Table of content


Default Variables

client_max_body_size

Maximum file upload size for Nginx. Value as defined by nginx documentation

Default value

client_max_body_size: 1M

env

Dictionary of environment variables that will be passed to the docker container.

Default value

env:
  nginx_docker: yes

Example usage

env:
  PORT: 80
  SECRET_TOKEN: xa2z3ik6

image_local

Path to the extracted docker image. When empty, the role will attempt to build the image on local host before uploading the image to the remote. Expects the Dockerfile to be present in the same directory as the playbook.

Default value

image_local: ''

Example usage

image: './dist/my-app.tar'

image_name

Name of image that will be pulled from the docker repository.

Default value

image_name: ''

Example usage

image: 'requarks/wiki'

network_name

Name of docker network used by this container. The role will create it if necessary

Default value

network_name: practical-ansible

Example usage

network_name: 'totally-separated-network'

project_port

Inner port number of the container. The role will map this port from docker to nginx proxy|

Default value

project_port: 80

Example usage

project_port: 3000

Dependencies

  • {'role': 'practical-ansible.nginx_project'}

License

MIT

Author

Pavel Žák

About

Deploy your Docker project to Nginx with minimal config

Install
ansible-galaxy install practical-ansible/nginx-docker
GitHub repository
License
mit
Downloads
650
Owner
Tiny Ansible roles and playbooks that help you with web hosting in a world of VPS