Closed masonlr closed 6 years ago
Briefly tested this approach (https://docs.microsoft.com/en-us/azure/virtual-machines/linux/docker-compose-quickstart). Some notes are:
docker-compose
must be updated (from within VM)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
run.sh
should run in detached mode, i.e. 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
option, for example--public simulate.uksouth.cloudapp.azure.com:80
Opening ports 80, 5000, 5001, 5050 following this approach: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/nsg-quickstart-portal
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
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:
Invalid Host header
error in chrome. Likely related to (incorrect) use of dev server where we should be serving the built project (see https://github.com/angular/angular-cli/issues/6349)Implications:
docker-compose.json
and docker-compose.override.json
We can check
docker-compose.override-example.json
into version control, and have a deployment instruction:
cp docker-compose.override-example.json docker-compose.override.json
The override compose file will activate the production nginx docker container.
:tada: Working with nginx on Azure.
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;
}
}
Description
We need to deploy the application to Azure.
Acceptance criteria
Out of scope
Implementation notes