Skip to content

Commit 8b60619

Browse files
committed
added production suppport
1 parent 210a388 commit 8b60619

32 files changed

+561
-256
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ stage_dir
66
.terraform.lock.hcl
77
terraform.tfstate
88
terraform.tfstate.backup
9+
backend.tf
10+
*.cfg
11+
*.tfvars.json
12+
blazegraph.jnl
13+
config-instance.yaml
14+
config-stack.yaml

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# Noctua Application Deployment
1+
# Noctua Testing Deployment
22

33
This repository enables the deployment of the noctua editor (which includes
4-
minerva, barista, golr and noctua) locally, using self-generated GO-CAM models (in the form of .ttl files).
4+
minerva, barista, golr and noctua) locally, using self-generated GO-CAM models (in the form of .ttl files).
5+
6+
Note: For production deployment see [this readme file](./production/README.md)
57

68
## Deploy a version of the Noctua editor (including minerva, barista, golr and noctua locally via docker):
79
- important files:

aws/main.tf

+36-31
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
1-
resource "aws_instance" "noctua_app_stack_server" {
2-
ami = "ami-07dd19a7900a1f049"
3-
instance_type = var.instance_type
4-
vpc_security_group_ids = [aws_security_group.noctua_app_stack_sg.id]
5-
subnet_id = aws_subnet.noctua_app_stack_public_subnet.id
6-
key_name = var.key_name
7-
tags = var.tags
1+
variable "tags" {
2+
type = map
3+
default = { Name = "testing-noctua-app-stack" }
4+
}
5+
6+
variable "instance_type" {
7+
default = "t2.large"
8+
}
89

9-
ebs_block_device {
10-
device_name = "/dev/sda1"
11-
delete_on_termination = true
12-
tags = var.tags
13-
volume_size = 100
14-
}
10+
variable "disk_size" {
11+
default = 100
12+
}
13+
14+
variable "public_key_path" {
15+
default = "~/.ssh/id_rsa.pub"
16+
}
1517

16-
provisioner "remote-exec" {
17-
inline = [
18-
"curl -fsSL https://get.docker.com -o /tmp/get-docker.sh",
19-
"sudo sh /tmp/get-docker.sh",
20-
"sudo usermod -aG docker ubuntu",
21-
"sudo apt-get install -y docker-compose",
22-
"curl https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py",
23-
"sudo python3 /tmp/get-pip.py",
24-
"sudo pip3 install docker==4.3.1",
25-
]
18+
variable "open_ports" {
19+
type = list
20+
default = [22, 8090, 8080, 8983]
21+
}
22+
23+
provider "aws" {
24+
region = "us-east-1"
25+
shared_credentials_files = [ "~/.aws/credentials" ]
26+
profile = "default"
27+
}
28+
29+
module "base" {
30+
source = "git::https://github.com/geneontology/devops-aws-go-instance.git?ref=V2.0"
31+
instance_type = var.instance_type
32+
public_key_path = var.public_key_path
33+
tags = var.tags
34+
open_ports = var.open_ports
35+
disk_size = var.disk_size
36+
}
2637

27-
connection {
28-
host = aws_instance.noctua_app_stack_server.public_ip
29-
type = "ssh"
30-
user = "ubuntu"
31-
agent = false
32-
private_key = file(var.private_key_path)
33-
}
34-
}
38+
output "public_ip" {
39+
value = module.base.public_ip
3540
}

aws/outputs.tf

-20
This file was deleted.

aws/provider.tf

-4
This file was deleted.

aws/securit_groups.tf

-40
This file was deleted.

aws/ssh_key.tf

-5
This file was deleted.

aws/vars.tf

-44
This file was deleted.

aws/vpc.tf

-34
This file was deleted.

docker-vars.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ repo_map:
99

1010
tag: latest
1111
docker_hub_user: "{{ lookup('env', 'USER')|lower }}"
12+
apache_proxy_image: geneontology/apache-proxy:v2

docker/Dockerfile.minerva

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ COPY ./minerva-converter/pom.xml ./minerva-converter/pom.xml
99
COPY ./minerva-lookup/pom.xml ./minerva-lookup/pom.xml
1010
COPY ./minerva-server/pom.xml ./minerva-server/pom.xml
1111
COPY ./minerva-cli/pom.xml ./minerva-cli/pom.xml
12+
COPY ./.git ./.git
1213
RUN mvn dependency:go-offline package -B -am -pl minerva-server -DskipTests -Dmaven.javadoc.skip=true -Dsource.skip=true
1314

14-
COPY ./.git ./.git
1515
RUN mvn dependency:go-offline package -B -am -pl minerva-cli -DskipTests -Dmaven.javadoc.skip=true -Dsource.skip=true
1616

1717
COPY ./ ./

files/robots.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-agent: *
2+
Disallow: /

production/README.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Noctua Production Deployment
2+
3+
This repository enables the deployment of the noctua stack to AWS. It includes
4+
minerva, barista, and noctua and it points to an external amigo instance.
5+
6+
## Deploy a version of the Noctua editor (including minerva, barista, noctua):
7+
- Important ansible files:
8+
- vars.yaml
9+
- docker-vars.yaml
10+
- s3-vars.yaml
11+
- stage.yaml
12+
- start_services.yaml
13+
14+
## Artifacts Deployed To Staging directory On AWS:
15+
- blazegraph.jnl
16+
- Cloned repositories:
17+
- noctua-form, noctua-landing-page, noctua-models, go-site and noctua-visual-pathway-editor.
18+
- s3 credentials used to push apache logs to s3 buckets
19+
- github OAUTH client id and secret
20+
- docker-production-compose and various configuration files from template directory
21+
22+
## Install Python deployment Script
23+
Note the script has a <b>-dry-run</b> option.
24+
25+
```
26+
>pip install go-deploy==0.3.0 # requires python >=3.8.5
27+
>go-deploy -h
28+
```
29+
30+
## S3 Terraform Backend
31+
32+
We use S3 terraform backend to store terraform's state. See production/backend.tf.sample
33+
34+
## Github OAUTH
35+
Noctua uses OAUTH for authentication. See templates/github.yaml
36+
37+
## Prepare Blazegraph journal locally
38+
39+
if you do not have a journal see production/gen_journal.sh.sample to generate one
40+
41+
## DNS
42+
43+
Use DNS records for noctua and barista. Once the stack is ready you would need to point these to elastic ip address of the stack,
44+
45+
## Golr/Amigo
46+
Use the dns name of the external golr instance running alongside amigo
47+
48+
## Provision to AWS
49+
50+
Copy sample files and modify as needed. For the terraform worksapce we append the date.
51+
As an example we use production-yy-mm-dd
52+
53+
```
54+
cp ./production/backend.tf.sample aws/backend.tf
55+
cp ./production/config-instance.yaml.sample config-instance.yaml
56+
go-deploy -init -c config-instance.yaml -w production-yy-mm-dd -d aws -verbose
57+
cp ./production/config-stack.yaml.sample config-stack.yaml
58+
go-deploy -c config-stack.yaml -w production-yy-mm-dd -d aws -verbose
59+
```
60+
61+
## Access noctua from a browser
62+
The elastic public ip address shows up in the logs when deploying but it can also be found in production-yy-mm-dd.cfg
63+
Point the noctua and barista DNS entries mentioned above to this ip address
64+
65+
- Use `http://{public_ip}`
66+
67+
## Destroy Instance And Stack
68+
69+
```sh
70+
# Make sure you pointing to the correct workspace
71+
terraform -chdir=aws workspace show
72+
terraform -chdir=aws destroy
73+
```

production/backend.tf.sample

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
backend "s3" {
3+
bucket = "REPLACE_ME"
4+
profile = "default"
5+
key = "noctua_app_stack/terraform.tfstate"
6+
region = "us-east-1"
7+
encrypt = true
8+
}
9+
}
10+
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ssh_keys:
2+
public: /Users/REPLACE/SSH/go-ssh.pub
3+
private: /Users/REPLACE_ME/SSH/go-ssh
4+
5+
instance:
6+
tags:
7+
Name: noctua_stack
8+
instance_type: t2.large
9+
open_ports:
10+
- 80
11+
- 22
12+
disk_size: 100

0 commit comments

Comments
 (0)