alan-turing-institute / simulate

A web framework for research simulations.
http://simulate.readthedocs.io
MIT License
4 stars 1 forks source link

Deploy docker containers on an Azure VM #86

Closed masonlr closed 6 years ago

masonlr commented 6 years ago

Description

We need to deploy the application to Azure.

Acceptance criteria

Out of scope

Implementation notes

masonlr commented 6 years ago

Briefly tested this approach (https://docs.microsoft.com/en-us/azure/virtual-machines/linux/docker-compose-quickstart). Some notes are:

sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose up -d
frontend:
    build:
      context: gateway-frontend
      dockerfile: Dockerfile
    ports:
    - "80:8080"
    depends_on:
    - job-manager
    - middleware
    - simulator
    networks:
    - db_nw
    volumes:
    - './gateway-frontend/src:/app/src'
    - '/app/node_modules'
--public simulate.uksouth.cloudapp.azure.com:80
masonlr commented 6 years ago

Opening ports 80, 5000, 5001, 5050 following this approach: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/nsg-quickstart-portal

screen shot 2018-09-11 at 5 23 41 pm

Check which ports are listening (run from VM):

turing@MyDockerVM:~/simulate$ sudo netstat -ntlp | grep LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1855/sshd
tcp6       0      0 :::10022                :::*                    LISTEN      18528/docker-proxy
tcp6       0      0 :::10023                :::*                    LISTEN      18882/docker-proxy
tcp6       0      0 :::5000                 :::*                    LISTEN      18635/docker-proxy
tcp6       0      0 :::5001                 :::*                    LISTEN      18900/docker-proxy
tcp6       0      0 :::22                   :::*                    LISTEN      1855/sshd
tcp6       0      0 :::5050                 :::*                    LISTEN      18720/docker-proxy
masonlr commented 6 years ago

Possible (more correct) way forward will be to ng build the frontend angular project and serve it using nginx from with the docker image.

An example of this is here: https://medium.com/@DenysVuika/your-angular-apps-as-docker-containers-471f570a7f2

Issue:

Implications:

cp docker-compose.override-example.json docker-compose.override.json

The override compose file will activate the production nginx docker container.

masonlr commented 6 years ago

:tada: Working with nginx on Azure.

image

masonlr commented 6 years ago

Much saner approach is to use a single nginx container as an API gateway for the entire system. This way we can have a unified micro-service config and reduce the number of containers. For example,

server {
    listen 80;
    server_name frontend;
    location / {
        proxy_pass http://frontend:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

server {
    listen 5000;
    server_name middleware;
    location / {
        proxy_pass http://middleware:5001;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

server {
    listen 5010;
    server_name manager;
    location / {
        proxy_pass http://manager:5011;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}