practical-ansible.nginx_docker

Nginx-Docker for Ansible

Integration Quality Downloads Role

Use Ansible to set up Docker projects with Nginx, supporting both regular and HTTPS connections. This tool works regardless of the programming language used to create your application and is designed for continuous integration and deployment.

Features

  • Can build new Docker images or use existing ones.
  • No need for a Docker registry.
  • Sets up HTTPS using the nginx_project.
  • Automatically updates old versions of your project.

Prerequisites

  • User must have permissions to configure Nginx.
  • User must have permissions to run Docker.

Installation

ansible-galaxy install practical-ansible.nginx_docker

Example Playbook

Here’s a typical playbook setup:

---
- name: Deploy to a 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'

More examples can be found in the tests directory.

Example CI

You can find additional configuration examples.

Reference Manual

Use this to help prevent burnout when deploying your Docker application to Nginx.

Table of Contents


Default Variables

client_max_body_size

The maximum size for file uploads to Nginx. This is specified in the Nginx documentation.

Default Value

client_max_body_size: 1M

env

A list of environment variables that will be sent to the Docker container.

Default Value

env:
  nginx_docker: yes

Example Usage

env:
  PORT: 80
  SECRET_TOKEN: xa2z3ik6

image_local

The path to the Docker image file. If this is empty, it will try to build the image on the local machine before transferring it. The Dockerfile needs to be in the same folder as the playbook.

Default Value

image_local: ''

Example Usage

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

image_name

The name of the image to be pulled from the Docker repository.

Default Value

image_name: ''

Example Usage

image: 'requarks/wiki'

network_name

The name of the Docker network for this container. It will create the network if it doesn't exist.

Default Value

network_name: practical-ansible

Example Usage

network_name: 'totally-separated-network'

project_port

The internal port number for the container. This port will be linked from Docker to the Nginx proxy.

Default Value

project_port: 80

Example Usage

project_port: 3000

Dependencies

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

License

MIT

Author

Pavel Žák

Informazioni sul progetto

Deploy your Docker project to Nginx with minimal config

Installa
ansible-galaxy install practical-ansible.nginx_docker
Licenza
mit
Download
660
Proprietario
Tiny Ansible roles and playbooks that help you with web hosting in a world of VPS