Browse Source

Merge pull request #940 from doccano/fix/cloudformation

Update CloudFormation template
pull/944/head
Hiroki Nakayama 4 years ago
committed by GitHub
parent
commit
2a94bf55e5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 154 additions and 1 deletions
  1. 2
      README.md
  2. 153
      template.aws.yaml

2
README.md

@ -132,7 +132,7 @@ If you want to add annotators/annotation approvers, see [Frequently Asked Questi
| Service | Button |
|---------|---|
| AWS[^1] | [![AWS CloudFormation Launch Stack SVG Button](https://cdn.rawgit.com/buildkite/cloudformation-launch-stack-button-svg/master/launch-stack.svg)](https://console.aws.amazon.com/cloudformation/home?#/stacks/create/review?stackName=doccano&templateURL=https://s3-external-1.amazonaws.com/cf-templates-10vry9l3mp71r-us-east-1/2019290i9t-AppSGl1poo4j8qpq) |
| AWS[^1] | [![AWS CloudFormation Launch Stack SVG Button](https://cdn.rawgit.com/buildkite/cloudformation-launch-stack-button-svg/master/launch-stack.svg)](https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=doccano&templateURL=https://doccano.s3.amazonaws.com/public/cloudformation/template.aws.yaml) |
| Azure | [![Deploy to Azure](https://azuredeploy.net/deploybutton.svg)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fdoccano%2Fdoccano%2Fmaster%2Fazuredeploy.json) |
| GCP[^2] | [![GCP Cloud Run PNG Button](https://storage.googleapis.com/gweb-cloudblog-publish/images/run_on_google_cloud.max-300x300.png)](https://console.cloud.google.com/cloudshell/editor?shellonly=true&cloudshell_image=gcr.io/cloudrun/doccano&cloudshell_git_repo=https://github.com/doccano/doccano.git) |
| Heroku | [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?template=https%3A%2F%2Fgithub.com%2Fdoccano%2Fdoccano) |

153
template.aws.yaml

@ -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
Loading…
Cancel
Save