mirror of https://github.com/doccano/doccano.git
pythondatasetsactive-learningtext-annotationdatasetnatural-language-processingdata-labelingmachine-learningannotation-tool
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
155 lines
4.3 KiB
155 lines
4.3 KiB
AWSTemplateFormatVersion: 2010-09-09
|
|
Description: "Deploy doccano on AWS EC2"
|
|
|
|
Parameters:
|
|
Username:
|
|
Description: "The username of the superuser"
|
|
Type: String
|
|
Default: "admin"
|
|
Password:
|
|
Description: "The password of the superuser"
|
|
Type: String
|
|
Default: "password"
|
|
NoEcho: true
|
|
KeyName:
|
|
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
|
Type: AWS::EC2::KeyPair::KeyName
|
|
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
|
InstanceType:
|
|
Description: WebServer EC2 instance type
|
|
Type: String
|
|
Default: t2.medium
|
|
AllowedValues:
|
|
- t2.medium
|
|
- t2.large
|
|
ConstraintDescription: must be a valid EC2 instance type.
|
|
LatestAmiId:
|
|
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
|
|
Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2'
|
|
|
|
Metadata:
|
|
AWS::CloudFormation::Interface:
|
|
ParameterGroups:
|
|
- Label:
|
|
default: "doccano Configuration"
|
|
Parameters:
|
|
- Username
|
|
- Password
|
|
- Label:
|
|
default: "EC2 Configuration"
|
|
Parameters:
|
|
- KeyName
|
|
- InstanceType
|
|
|
|
Resources:
|
|
VPC:
|
|
Type: "AWS::EC2::VPC"
|
|
Properties:
|
|
CidrBlock: "10.0.0.0/16"
|
|
EnableDnsHostnames: true
|
|
EnableDnsSupport: true
|
|
InstanceTenancy: default
|
|
Tags:
|
|
- Key: Name
|
|
Value: doccanoVPC
|
|
InternetGateway:
|
|
Type: AWS::EC2::InternetGateway
|
|
Properties:
|
|
Tags:
|
|
- Key: Name
|
|
Value: doccano-igw
|
|
AttachGateway:
|
|
Type: AWS::EC2::VPCGatewayAttachment
|
|
Properties:
|
|
VpcId: !Ref VPC
|
|
InternetGatewayId: !Ref InternetGateway
|
|
PublicSubnet:
|
|
Type: "AWS::EC2::Subnet"
|
|
Properties:
|
|
AvailabilityZone:
|
|
Fn::Select:
|
|
- 0
|
|
- Fn::GetAZs: { Ref: "AWS::Region" }
|
|
CidrBlock: "10.0.1.0/24"
|
|
MapPublicIpOnLaunch: true
|
|
Tags:
|
|
- Key: Name
|
|
Value: doccano-public-subnet
|
|
VpcId: !Ref VPC
|
|
PublicRouteTable:
|
|
Type: AWS::EC2::RouteTable
|
|
Properties:
|
|
VpcId: !Ref VPC
|
|
Tags:
|
|
- Key: Name
|
|
Value: doccanoRouteTable
|
|
PublicRoute:
|
|
Type: AWS::EC2::Route
|
|
Properties:
|
|
RouteTableId: !Ref PublicRouteTable
|
|
DestinationCidrBlock: "0.0.0.0/0"
|
|
GatewayId: !Ref InternetGateway
|
|
PublicRouteTableAssociation:
|
|
Type: AWS::EC2::SubnetRouteTableAssociation
|
|
Properties:
|
|
SubnetId: !Ref PublicSubnet
|
|
RouteTableId: !Ref PublicRouteTable
|
|
EC2SecurityGroup:
|
|
Type: AWS::EC2::SecurityGroup
|
|
Properties:
|
|
GroupName: "doccano-ec2-sg"
|
|
GroupDescription: "Security Group for doccano"
|
|
VpcId: !Ref VPC
|
|
SecurityGroupIngress:
|
|
- IpProtocol: tcp
|
|
FromPort: "80"
|
|
ToPort: "80"
|
|
CidrIp: 0.0.0.0/0
|
|
- IpProtocol: tcp
|
|
FromPort: "22"
|
|
ToPort: "22"
|
|
CidrIp: 0.0.0.0/0
|
|
Tags:
|
|
- Key: Name
|
|
Value: doccano-ec2-sg
|
|
EC2Instance:
|
|
Type: AWS::EC2::Instance
|
|
Properties:
|
|
AvailabilityZone:
|
|
Fn::Select:
|
|
- 0
|
|
- Fn::GetAZs: { Ref: "AWS::Region" }
|
|
KeyName: !Ref KeyName
|
|
ImageId: !Ref LatestAmiId
|
|
InstanceType: !Ref InstanceType
|
|
Monitoring: true
|
|
SecurityGroupIds:
|
|
- !Ref EC2SecurityGroup
|
|
SubnetId: !Ref PublicSubnet
|
|
UserData:
|
|
Fn::Base64: !Sub |
|
|
#!/bin/bash -ex
|
|
yum update -y
|
|
# Install Docker
|
|
yum install -y docker
|
|
systemctl enable docker
|
|
service docker start
|
|
# Install docker compose
|
|
curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
|
chmod +x /usr/local/bin/docker-compose
|
|
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
|
|
# Install git
|
|
yum install -y git
|
|
git clone https://github.com/doccano/doccano.git
|
|
cd doccano
|
|
cp docker/.env.example .env
|
|
sed -i s/admin/${Username}/g .env
|
|
sed -i s/password/${Password}/g .env
|
|
docker-compose -f docker/docker-compose.prod.yml up -d
|
|
Tags:
|
|
- Key: Name
|
|
Value: doccano
|
|
Outputs:
|
|
PublicDNS:
|
|
Description: EC2 public DNS
|
|
Value: !GetAtt EC2Instance.PublicDnsName
|