AWS ECS
batch
NOVASTO
•
• NOVASTO join
•
API
aws
aws
•
•
•
1.
2. batch
1.
2. batch
1. Batch
2. Docker
3. Ecs
Batch
Batch
batch - 1 1 1
-Docker-
-Docker-
-
Docker p
OS
-Docker-
-
image
image DockerHub
-Docker-
-
(http://www.itmedia.co.jp/enterprise/articles/1701/23/news036.html)
Ecs(Elastic Container Service)
Docker AWS
Ecs(Elastic Container Service)
Ecs(Elastic Container Service)
(https://thinkit.co.jp/article/9701)
Ecs(Elastic Container Service)
——
1.
2.
3.
4. …
aws aws
1.
2. batch
Docker Engine Docker Engine Docker Engine Docker Engine
batch
Batch
(https://stackoverflow.com/questions/23735149/what-is-the-difference-between-a-docker-image-and-a-container)
Docker-Compose.yml
Batchfile(~~.rb)
DockerFile
image
Task
image
Ecs
Docker
Docker-file
FROM ruby:2.5.1
RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR
COPY src/Gemfile $APP_DIR
RUN gem install bundler & bundle install
RUN git clone git@github.com:novasto/~~~
WORKDIR /usr/share/batch/
RUN git checkout $branch
Dockerfile
Batchfile
Docker-file
FROM ruby:2.5.1
RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR
COPY src/Gemfile $APP_DIR
RUN gem install bundler & bundle install
RUN git clone git@github.com:novasto/~~~
WORKDIR /usr/share/batch/
RUN git checkout $branch Git clone
batch
DockerHub
VERSION=1.0
MINOR_VERSION=1
#
docker build -t novasto/leaves.batch:$VERSION.$MINOR_VERSION
# VERSION latest
docker tag novasto/leaves.batch:$VERSION.$MINOR_VERSION novasto/
leaves.batch:latest
# DockerHub push VERSION
docker push novasto/leaves.batch:$VERSION.$MINOR_VERSION
Docker-compose.yml
Docker-compose.yml
version: '3'
services:
ruby:
image: novasto/batch
container_name: scraping_batch
tty: true
command: ruby /usr/share/batch/app/batch/run.rb
env_file:
- ./ruby/app.env
DockerHub
ECS
batch
# ecs-cli compose --file docker-compose.yml --ecs-params ecs-params.yml
--project-name ruby create --launch-type EC2
# ecs-cli compose --file docker-compose.yml --ecs-params ecs-params.yml --project-name
ruby create --launch-type version: 1
task_definition:
ecs_network_mode: awsvpc
task_execution_role: secretsTaskExecutionRole3
task_size:
cpu_limit: 256
mem_limit: 512
services:
fluentd:
essential: true
- sg-0d7a8b34dd3cfee84
ecs-params
ecs-cli compose --file ./$VERSION/docker-compose.yml --task-role-arn
secretsTaskExecutionRole3 --ecs-params ./$VERSION/ecs-params.yml --project-name ruby
start --launch-type EC2 -c leaves-batch
ecs-params
OK!!!
ecs-params
Cloud Watch
ecs-params
Cloud Watch
ecs-params
1 11 16 24
2 12 1 24
ecs-params
ECS
•
•
•
ecs-params
ECS AWS
• Subnet
• VPC
• SecurityGroup
• I AM Role
ecs-params
•
•
• Web
•
AWS ECSを用いてbatchを動かそう

AWS ECSを用いてbatchを動かそう