Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,9 @@ backend/filepond-temp-uploads
backend/media
backend/*.sqlite3*
frontend/assets/fonts

*.auto.tfvars
.terraform/
.terraformrc
*.tfstate
terraform.tfstate.backup
2 changes: 1 addition & 1 deletion docker/Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG NODE_VERSION="16_16_bullseye_slim"
FROM quay.io/pcdc/node:${NODE_VERSION} AS frontend-builder
FROM node:20.19-bullseye-slim AS frontend-builder
Comment thread
grugna marked this conversation as resolved.
Outdated

COPY frontend/ /app/
WORKDIR /app
Expand Down
6 changes: 3 additions & 3 deletions docker/nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ server {
}

location /v1/ {
proxy_pass http://backend:8000/v1/;
proxy_pass http://localhost:8000/v1/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_read_timeout 300;
}

location /admin/ {
proxy_pass http://backend:8000/admin/;
proxy_pass http://localhost:8000/admin/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
Expand All @@ -32,7 +32,7 @@ server {
}

location /swagger/ {
proxy_pass http://backend:8000/swagger/;
proxy_pass http://localhost:8000/swagger/;
Comment thread
grugna marked this conversation as resolved.
Outdated
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
Expand Down
2 changes: 1 addition & 1 deletion docker/nginx/nginx.conf.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
worker_processes ${WORKER_PROCESSES};
worker_processes auto;

error_log /var/log/nginx/error.log warn;

Expand Down
43 changes: 43 additions & 0 deletions terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions terraform/dev/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module "doccano_ecs" {
source = "../modules/ecs"
app_name = var.app_name
subnet_ids = var.private_subnet_ids
lb_security_group = [module.doccano_alb.lb_security_group]
load_balancer = {
container_port = 8080
}
vpc_id = var.vpc_id
target_group_arn = module.doccano_alb.doccano_target_group.arn
container_name = "nginx"
# container_count = 2
efs_volume = module.doccano_efs.aws_efs_file_system
aws_efs_access_point_static_files = module.doccano_efs.access_point_id_static_files
efs_access_point_id_media = module.doccano_efs.access_point_id_media
efs_access_point_id_tmp = module.doccano_efs.access_point_id_tmp
database_url = module.rds.database_url
}

module "doccano_efs" {
source = "../modules/efs"
efs_name = var.app_name
vpc_id = var.vpc_id
subnet_ids = var.private_subnet_ids
security_groups = [module.doccano_ecs.ecs_tasks_sg]
}

module "doccano_alb" {
source = "../modules/alb"
environment = var.environment
vpc_id = var.vpc_id
subnet_ids = var.private_subnet_ids
}

module "rds" {
source = "../modules/rds"
rds_security_groups = module.doccano_ecs.ecs_tasks_sg
vpc_id = var.vpc_id
}
9 changes: 9 additions & 0 deletions terraform/dev/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
provider "aws" {
region = var.aws_region
default_tags {
tags = {
Environment = var.environment
Name = var.app_name
}
}
}
27 changes: 27 additions & 0 deletions terraform/dev/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
variable "aws_region" {
default = "us-east-1"
}

variable "environment" {
default = "dev"
}

variable "app_name" {
default = "doccano"
}

variable "private_subnet_ids" {
default = ["subnet-013e8d4a439201a84", "subnet-0025d9b857876f8a5"]
}

variable "vpc_id" {
default = "vpc-0ab59a594548de1b9" #doccano dev vpc
}

variable "efs_sg_id" {
default = ""
}

# variable "alb_sg_id" {
# default = ""
# }
3 changes: 3 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module "dev" {
source = "./dev"
}
55 changes: 55 additions & 0 deletions terraform/modules/alb/alb.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
resource "aws_lb" "doccano_lb" {
name = "doccano-lb-${var.environment}"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.lb.id] #[aws_security_group.lb.id]
subnets = var.subnet_ids #["subnet-02daaea0d231975df", "subnet-0c7f4570d0c82bdc3"]
}

resource "aws_lb_listener" "http" {
load_balancer_arn = aws_lb.doccano_lb.arn
port = 80
protocol = "HTTP"

default_action {
type = "forward"
target_group_arn = aws_lb_target_group.doccano_target_group.arn
}
}

resource "aws_lb_target_group" "doccano_target_group" {
name = "doccano-${var.environment}-target-group"
port = 80
protocol = "HTTP"
target_type = "ip"
vpc_id = var.vpc_id

health_check {
path = "/"
interval = 30
timeout = 5
healthy_threshold = 2
unhealthy_threshold = 3
}
}

# ALB security Group: Edit to restrict access to the application
resource "aws_security_group" "lb" {
name = "doccano-lb-security-group"
description = "controls access to the ALB"
vpc_id = var.vpc_id

ingress {
protocol = "tcp"
from_port = 80
to_port = 80
cidr_blocks = ["0.0.0.0/0"]
}

egress {
protocol = "-1"
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
}
7 changes: 7 additions & 0 deletions terraform/modules/alb/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "doccano_target_group" {
value = aws_lb_target_group.doccano_target_group
}

output "lb_security_group" {
value = aws_security_group.lb.id
}
15 changes: 15 additions & 0 deletions terraform/modules/alb/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable "environment" {

}

variable "subnet_ids" {

}

# variable "security_group_id" {

# }

variable "vpc_id" {

}
24 changes: 24 additions & 0 deletions terraform/modules/ecs/cloudwatch.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
resource "aws_cloudwatch_log_group" "doccano" {
name = "/ecs/doccano-logs"
retention_in_days = 7
}

resource "aws_cloudwatch_log_group" "flower" {
name = "/ecs/flower-logs"
retention_in_days = 7
}

resource "aws_cloudwatch_log_group" "celery" {
name = "/ecs/celery-logs"
retention_in_days = 7
}

resource "aws_cloudwatch_log_group" "nginx" {
name = "/ecs/nginx-logs"
retention_in_days = 7
}

resource "aws_cloudwatch_log_group" "rabbitmq" {
name = "/ecs/rabbitmq-logs"
retention_in_days = 7
}
3 changes: 3 additions & 0 deletions terraform/modules/ecs/cluster.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "aws_ecs_cluster" "cluster" {
name = "${var.environment}-cluster"
}
Loading