Skip to content

Commit f8e38cb

Browse files
authored
Merge pull request #135 from AET-DevOps25/test-aws-deployment
Test aws deployment
2 parents 73b71f0 + 4330318 commit f8e38cb

File tree

11 files changed

+117
-35
lines changed

11 files changed

+117
-35
lines changed

.github/workflows/ansible-manual.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
type: string
1010

1111
env:
12-
SERVER_DN: ec2-18-212-178-250.compute-1.amazonaws.com # TODO: Change ip and Username according to aws vm
12+
SERVER_DN: ec2-44-201-251-81.compute-1.amazonaws.com
1313
DEBUG: true
1414
SERVER_USERNAME: ubuntu
1515

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# RecipAI
22

3-
RecipAI is available at [`https://recipai.student.k8s.aet.cit.tum.de`](https://recipai.student.k8s.aet.cit.tum.de)
3+
RecipAI is available at [`https://recipai.student.k8s.aet.cit.tum.de`](https://recipai.student.k8s.aet.cit.tum.de) (k8s) and deployable at [`https://recipai.duckdns.org`](https://recipai.duckdns.org) (aws)
44

55
For running it on docker please see [dockerized-deployment](#dockerized-deployment) and [.env.template](.env.template).
66

@@ -410,6 +410,17 @@ The project includes Helm charts for Kubernetes deployment in the `recipai-chart
410410
--set secrets.apiOpenWebUi="your open web ui api key"
411411
```
412412

413+
## AWS Deployment
414+
415+
## Deploy with Ansible
416+
417+
1. Change the host name of the server on [inventory.ini](./ansible/inventory.ini) and [ansible-manual](./.github/workflows/ansible-manual.yml) to the server or ip address of VM.
418+
2. Update `recipai.duckdns.org` DNS record on DuckDNS to point new VM IP address
419+
3. The application is now deployable through github actions with the following steps
420+
- Run Manual Ansible Playbook Execution action install_docker.yml as input
421+
- Run Manual Ansible Playbook Execution action with docker_compose_up.yml
422+
- Run Manual Ansible Playbook Execution action with install_caddy.yml
423+
413424
## CI/CD Pipeline
414425

415426
The project includes a GitHub Actions workflow `ci-cd.yml` for:

ansible/files/Caddyfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
recipai.duckdns.org {
2+
reverse_proxy localhost:5173
3+
tls esad.akcam@tum.de
4+
log
5+
}

ansible/files/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"redirectUri": "https://recipai.duckdns.org/",
3+
"clientId": "9c1befae9e56ca4e83629b18875b9b543692d19a2bb0e828ba4b5cbd3dc37627"
4+
}

ansible/inventory.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[server]
2-
ec2-18-212-178-250.compute-1.amazonaws.com ansible_user=ubuntu
2+
ec2-44-201-251-81.compute-1.amazonaws.com ansible_user=ubuntu
33

44
[all:vars]
55
ansible_python_interpreter=/usr/bin/python3

ansible/playbooks/docker_compose_up.yml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,32 @@
33
hosts: all
44
vars:
55
project_dir: "{{ ansible_env.HOME }}/recipai"
6-
folders_to_copy:
7-
- server
8-
- client
9-
- genai
106

117
tasks:
12-
- name: Copy project folders
13-
copy:
14-
src: "../../{{ item }}/"
15-
dest: "{{ project_dir }}/{{ item }}/"
16-
loop: "{{ folders_to_copy }}"
8+
- name: Ensure project directory exists
9+
ansible.builtin.file:
10+
path: "{{ project_dir }}"
11+
state: directory
12+
13+
- name: Ensure client directory exists
14+
ansible.builtin.file:
15+
path: "{{ project_dir }}/client"
16+
state: directory
1717

1818
- name: Copy docker-compose.yml
1919
copy:
2020
src: "../../docker-compose.yml"
2121
dest: "{{ project_dir }}/docker-compose.yml"
2222

23-
- name: Copy server secrets
24-
copy:
25-
src: ../secrets/server.env
26-
dest: "{{ project_dir }}/server/.env"
27-
28-
- name: Copy client secrets
23+
- name: Copy docker-compose.yml
2924
copy:
30-
src: ../secrets/client.env
31-
dest: "{{ project_dir }}/client/.env"
25+
src: "../files/config.json"
26+
dest: "{{ project_dir }}/client/config.json"
3227

33-
- name: Copy genai secrets
28+
- name: Copy secrets
3429
copy:
35-
src: ../secrets/genai.env
36-
dest: "{{ project_dir }}/genai/.env"
30+
src: ../secrets/secret.env
31+
dest: "{{ project_dir }}/.env"
3732

3833
- name: Stop any running containers
3934
command: docker compose down
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
- name: Install and configure Caddy reverse proxy
3+
hosts: all
4+
become: yes
5+
6+
vars:
7+
caddy_config_path: /etc/caddy/Caddyfile
8+
9+
tasks:
10+
- name: Install dependencies
11+
apt:
12+
name: [debian-keyring, debian-archive-keyring, apt-transport-https]
13+
state: present
14+
update_cache: yes
15+
16+
- name: Add Caddy GPG key
17+
apt_key:
18+
url: https://dl.cloudsmith.io/public/caddy/stable/gpg.key
19+
state: present
20+
21+
- name: Add Caddy repository
22+
apt_repository:
23+
repo: deb [trusted=yes] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main
24+
state: present
25+
26+
- name: Install Caddy
27+
apt:
28+
name: caddy
29+
state: present
30+
update_cache: yes
31+
32+
- name: Deploy Caddyfile
33+
copy:
34+
dest: "{{ caddy_config_path }}"
35+
src: "../files/Caddyfile"
36+
owner: root
37+
group: root
38+
mode: '0644'
39+
notify:
40+
- Reload Caddy
41+
42+
- name: Ensure Caddy is running and enabled
43+
systemd:
44+
name: caddy
45+
enabled: yes
46+
state: started
47+
48+
handlers:
49+
- name: Reload Caddy
50+
systemd:
51+
name: caddy
52+
state: restarted

ansible/secrets/client.env

Lines changed: 0 additions & 1 deletion
This file was deleted.

ansible/secrets/genai.env

Lines changed: 0 additions & 1 deletion
This file was deleted.

ansible/secrets/secret.env

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
$ANSIBLE_VAULT;1.1;AES256
2+
35626432643764626530666432623666633134366536323330346166396163643530393432646630
3+
3930653031393930396561633562353364613630656261370a386463386137353163656334643231
4+
39383563396431336561616433306536303633363437383737616131343535373539636135366531
5+
6135656130353065390a303734623062333361653766373635323634353566343336343034653934
6+
62313435316566383466376462653934656664306131646266353738616563643338663665326235
7+
34386335326361623837306633623330396137356639373763636231303238373031366265373231
8+
66623164373466326433303033643635373834396331343566343935323938326161343766323937
9+
65373431306631396631336335393835363964313965623131346662326161653165376566393236
10+
66346534383136326166623538303334633337306336353236613230303734386461333137616361
11+
61626336303533326430396238373863656531666531613161646235323565366361643965366362
12+
61356164623030616539356534643961643663626161333065333330653931343637643735333332
13+
39656639353263326463353163393665663534323963366265383063316132663966613565623834
14+
36646532353362663537326333323530383138643931626638653930366532663562313135313037
15+
66313434336462383833616333363165353834666432316537376664613337343465346338356362
16+
66613234346432373738633434393033376236656434613330336563666337353634313462616338
17+
63636430373732306132613436363539666630363334643531343435653335653737393634656339
18+
37363435353830313536326461376335643830383638633061636365316635363465323762323433
19+
30643433313932346138326237336266376330336265373331316235393032373465383665326532
20+
63366631623830386564383338626636623364646530343765623234633066393537373530373933
21+
62626462313433383062663331653931326364653666363936396431373130623862353135386432
22+
66316366346462373037663436393438323563626437303435626439383730383963316530313430
23+
65303963653763333864643534343632363637313733333536663438376138383362306663373138
24+
65303539353435346461653836656164636534663635623034303437666161623561336165383033
25+
62323039393037643834336232633832343766333037316336613163646536353965393130366166
26+
66313539396330663639633364656132373361646530663736353732663866353733613432666361
27+
3433626236366461333361333461616332633563303666646533

0 commit comments

Comments
 (0)