[DOCKER] Führen Sie nginx + express mit fargate 4 core aus

api

Stellen Sie die allgemeine Lautstärke auf Lautstärke ein

VOLUME /usr/src/tmp

Lassen Sie den Sockenpfad durch eine Umgebungsvariable angeben

main.js



const sock = process.env.SOCK_PATH;
app.listen(sock, () => {
  fs.chmodSync(sock, '666');
  console.log(`Server running on ${sock} with pid ` + process.pid);
});
  

nginx

api1.sock --upstream zu api4.sock

nginx.conf


upstream api {
    server unix:///usr/src/tmp/api_1.sock;
    server unix:///usr/src/tmp/api_2.sock;
    server unix:///usr/src/tmp/api_3.sock;
    server unix:///usr/src/tmp/api_4.sock;
}
server {
    listen       80 default;
    listen  [::]:80;

    location / {
        proxy_pass http://api;       
        break;
    }
}

Aufgabendefinition

Stellen Sie eine Verbindung mit der ECS-Aufgabendefinition her

task-define.json


{
"containerDefinitions": [
  {
    "name": "nginx",
    "portMappings": [
      { "hostPort": 80, "protocol": "tcp", "containerPort": 80 }
    ],
    "mountPoints": [
      {
        "readOnly": true,
        "containerPath": "/usr/src/tmp",
        "sourceVolume": "etc"
      }
    ]
  },
  {
    "name": "api1",
    "mountPoints": [
      { "containerPath": "/usr/src/tmp", "sourceVolume": "etc" }
    ],
    "environment": [
      { "name": "SOCK_PATH", "value": "/usr/src/tmp/api_1.sock" }
    ]
  },
  {
    "name": "api2",
    "mountPoints": [
      { "containerPath": "/usr/src/tmp", "sourceVolume": "etc" }
    ],
    "environment": [
      { "name": "SOCK_PATH", "value": "/usr/src/tmp/api_2.sock" }
    ]
  },
  {
    "name": "api3",
    "mountPoints": [
      { "containerPath": "/usr/src/tmp", "sourceVolume": "etc" }
    ],
    "environment": [
      { "name": "SOCK_PATH", "value": "/usr/src/tmp/api_3.sock" }
    ]
  },
  {
    "name": "api4",
    "mountPoints": [
      { "containerPath": "/usr/src/tmp", "sourceVolume": "etc" }
    ],
    "environment": [
      { "name": "SOCK_PATH", "value": "/usr/src/tmp/api_4.sock" }
    ]
  }
],
"volumes": [{ "name": "etc" }],
}

Recommended Posts

Führen Sie nginx + express mit fargate 4 core aus
Führen Sie TAO Core mit Docker aus
Führen Sie Payara mit Docker aus
Verstopft mit Express npm Installation
Führen Sie Batch mit Docker-Compose mit Java-Batch aus
[Rails] Polymorph mit graphql-rubin ausdrücken
Führen Sie Tensorflow mit THETA V aus
Führen Sie LIFF mit Spring Boot aus
Führen Sie Rails immer im Docker aus
Führen Sie Java VM mit Web Assembly aus