mirror of https://github.com/doccano/doccano.git
Hironsan
4 years ago
1 changed files with 153 additions and 0 deletions
Split View
Diff Options
@ -0,0 +1,153 @@ |
|||
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.small |
|||
AllowedValues: |
|||
- t2.micro |
|||
- t2.small |
|||
- t2.medium |
|||
- t2.large |
|||
ConstraintDescription: must be a valid EC2 instance type. |
|||
|
|||
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: ami-0873b46c45c11058d |
|||
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 |
|||
sed -i s/"admin"/${Username}/g docker-compose.prod.yml |
|||
sed -i s/"password"/${Password}/g docker-compose.prod.yml |
|||
docker-compose -f docker-compose.prod.yml up -d |
|||
Tags: |
|||
- Key: Name |
|||
Value: doccano |
|||
Outputs: |
|||
PublicDNS: |
|||
Description: EC2 public DNS |
|||
Value: !GetAtt EC2Instance.PublicDnsName |
Write
Preview
Loading…
Cancel
Save