Skip to content

metakgp/metaploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Contributors Forks Stargazers Issues MIT License Wiki


image

MetaPloy

Taking over the world one deployment at a time.
Report Bug · Request Feature

Table of Contents

About

MetaPloy is just a containerized nginx reverse proxy that acts as the main web server (ingress server) for all metakgp projects. It exposes a Docker network named metaploy-network and a volume named metaploy-nginx-config-volume. The volume is mounted at /etc/nginx/sites-enabled/ and reads .metaploy.conf files that contain the nginx configurations for each of the individual projects.

Each project hosted on the server is containerized and connected to the metaploy-network, and its nginx configuration file is copied to the metaploy-nginx-config-volume volume. MetaPloy watches for changes in the volume and reloads the configuration if any changes are made (e.g., a new project is loaded or unloaded).

These config files are included inside the top-level http directive and should contain only the server directives. See the usage section for examples.

(back to top)

Getting Started

Prerequisites

Docker and docker compose are the only required dependencies. You can either install Docker Desktop or the Docker Engine. For minimal installations and server use cases, Docker Engine is recommended.

(back to top)

Installation

  1. Clone this repository.
  2. Copy the contents of the .env.template file into the .env file. Create the file if it doesn't exist.
  3. Set the SERVER_PORT variable to the desired port. This is the port at which the server will be accessible on the system.
  4. Run docker compose up to start MetaPloy.

(back to top)

Usage

MetaPloy uses docker networks and volumes for its core functionality. See docker-compose.yml for the definitions. There are two main networks and one volume:

  • The metaploy-network which is used for connecting projects to the ingress server. Anything on this network can be exposed to the external world via the ingress server.
  • The nginx-config-volume which contains the nginx configuration files for each project and is mounted at /etc/nginx/sites-enabled.
  • The metaploy-private-network which is not exposed to the ingress server. It is used for internal communication between different projects connected to metaploy. Eg: For a database to be accessed by multiple projects.

MetaPloy listens to changes in the config directory using watch_reload.sh. If any file is changed, a new one is added, or removed (such as during the starting or stopping of a project), the nginx configuration is reloaded using nginx -s reload. All configuration files inside the configuration directory are directly included under the http directive of the ingress server. See the last lines of nginx.conf.

To connect a project to a running MetaPloy instance, the following is required:

  1. Add the metaploy networks and volumes in the project's docker compose file (or connect to the network in any other way).
  2. Create a [project].metaploy.conf file that adds directives to connect to the server and sets the server directives including the server_name to set the domain. See example.
  3. Copy the config file to the config volume when the project starts. This can be done by running a postinstall script as the entrypoint of the container.

See the example. Also see existing projects using metaploy:

  1. IQPS Backend - Uses the standard template described here. Also uses the private network to connect to a database and file server.
  2. Metakgp Wiki - A non-standard legacy example with an nginx proxy of its own that uses fastcgi.
  3. Odin's Vault: A static file server that exposes a volume internally and a file server externally.
  4. Database of Babel: A Postgres database that only uses the private network and does not expose anything outside.

Debugging on server

Sometimes we have to debug things out in production environment. To make this process streamlined there is an auto reload script running as a background service which checks for any changes made to nginx configurations (/etc/nginx/nginx.conf and /etc/nginx/sites-enabled/*) and reloads nginx automatically. Check out the script here. In case you need to debug the script itself you can check-out the logs in the docker container located at /nginx_auto_reload_service.log.

Maintainer(s)

(back to top)

Contact

📫 Metakgp - Metakgp's slack invite Metakgp's email metakgp's Facebook metakgp's LinkedIn metakgp's Twitter metakgp's Instagram

(back to top)

Additional documentation

(back to top)

About

The metakgp nginx deployment architecture.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •