Skip to content

Commit

Permalink
using custom image. using temp amigo.yaml file as it is modified when…
Browse files Browse the repository at this point in the history
… the amigo service is started
  • Loading branch information
abessiari committed Jan 5, 2022
1 parent 2fc8051 commit fa7bdfb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 37 deletions.
3 changes: 2 additions & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if [ $AMIGO -ne 0 ]; then
md5sum -c amigo-hash
GULP_INSTALL=$?
echo "GULP_INSTALL=$GULP_INSTALL"
cp ./conf/amigo.yaml.orig ./conf/amigo.yaml
if [ $GULP_INSTALL -ne 0 ]; then
npm install
./node_modules/.bin/gulp install
Expand All @@ -23,7 +24,7 @@ if [ $AMIGO -ne 0 ]; then
sed -i s,config.pl,/srv/amigo/perl/bin/config.pl,g /srv/amigo/perl/lib/AmiGO.pm
fi

md5sum ./conf/amigo.yaml > amigo-hash
md5sum ./conf/amigo.yaml.orig > amigo-hash
fi

echo "Starting the apache2 server with amigo installed"
Expand Down
38 changes: 5 additions & 33 deletions provision/aws/main.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
data "aws_ami" "ubuntu" {
most_recent = true

filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}

owners = ["099720109477"]
}

// Search for eip by allocation_id
// If found data.aws_eip.amigo_eip.public_ip will be the public ip.
data "aws_eip" "amigo_eip" {
Expand All @@ -26,8 +10,7 @@ resource "aws_eip_association" "eip_assoc" {
}

resource "aws_instance" "amigo_server" {
// This ami works for use-east-1 "ami-0dd76f917833aac4b"
ami = data.aws_ami.ubuntu.id
ami = var.ami
instance_type = var.instance_type
vpc_security_group_ids = [aws_security_group.amigo_sg.id]
subnet_id = aws_subnet.amigo_app_stack_public_subnet.id
Expand All @@ -41,21 +24,10 @@ resource "aws_instance" "amigo_server" {
volume_size = var.disk_size
}

provisioner "remote-exec" {
inline = [
"curl -fsSL https://get.docker.com -o /tmp/get-docker.sh",
"sudo sh /tmp/get-docker.sh",
"sudo usermod -aG docker ubuntu",
"sudo apt-get install -y docker-compose",
"sudo ln -s /usr/bin/python3 /usr/bin/python",
lifecycle {
ignore_changes = [
ebs_block_device,
tags,
]

connection {
host = aws_instance.amigo_server.public_ip
type = "ssh"
user = "ubuntu"
agent = false
private_key = file(var.private_key_path)
}
}
}
5 changes: 5 additions & 0 deletions provision/aws/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ variable "instance_type" {
default = "t2.large"
}

// custom ubuntu ami with docker, docker-compose, and python3 installed
variable "ami" {
default = "ami-01e51d86b60c02297"
}

variable "disk_size" {
default = 200
description = "size of disk in Gigabytes"
Expand Down
4 changes: 2 additions & 2 deletions provision/stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@
- { file: 'java-golr-monit', dir: '/golr-configs' }
- { file: 'console-capture-golr.xml', dir: '/golr-configs' }

- name: s3cfg is unused delete it
- name: s3cfg is unused. delete it
file:
path: "{{ stage_dir }}/proxy-configs/s3cfg"
state: absent
when: not USE_S3 | bool

- name: copy s3cfg is unused delete it
- name: copy s3cfg
copy:
src: "{{ S3_CRED_FILE }}"
dest: "{{ stage_dir }}/proxy-configs/s3cfg"
Expand Down
2 changes: 1 addition & 1 deletion provision/templates/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
- {{ stage_dir }}/amigo_working_path:/tmp
- {{ stage_dir }}/golr_timestamp.log:/tmp/golr_timestamp.log
- {{ stage_dir }}/release-archive-doi.json:/tmp/release-archive-doi.json
- {{ stage_dir }}/amigo-configs/amigo.yaml:/srv/amigo/conf/amigo.yaml
- {{ stage_dir }}/amigo-configs/amigo.yaml:/srv/amigo/conf/amigo.yaml.orig
- {{ stage_dir }}/amigo-configs/001-inline-amigo.conf:/etc/apache2/sites-available/001-inline-amigo.conf
- {{ stage_dir }}/amigo-configs/apache2.ports.conf:/etc/apache2/ports.conf
- {{ stage_dir }}/apache_amigo_logs:/var/log/apache2
Expand Down

0 comments on commit fa7bdfb

Please sign in to comment.