--Emballage de Nginx + Express dans Fargate
api
VOLUME /usr/src/tmp
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 - en amont de 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;
}
}
Connectez-vous avec la définition de tâche ECS
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