Skip to content

Commit

Permalink
Merge pull request #1 from Yahav/dev
Browse files Browse the repository at this point in the history
Development environment support
  • Loading branch information
Yahav authored Jul 24, 2024
2 parents 7b9c2e0 + d0e9237 commit 01bfc63
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 10 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,14 @@ git pull
chmod a+x update.sh
bash update.sh
```


## Development

Assuming that you are developing within your own fork/repo and so, set `azuracast_dev_repo` and `azuracast_dev_ver` in deploy.yml

eg.
```yml
azuracast_dev_repo: "username/AzuraCast"
azuracast_dev_ver: "dev-branch-name"
```
6 changes: 4 additions & 2 deletions ansible/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
update_mode: false
dev_azuracast_user_password: "azuracast"
dev_mysql_user_password: "azuracast"
azuracast_repo: "Yahav/AzuraCast" # @7243: after PR#7232 merged into main Azuracast repo, change to: Azuracast/Azuracast
azuracast_ref: "heads/"
azuracast_repo: "Yahav/AzuraCast" # @TODO: after PR#7243 merged into main Azuracast repo, change to: Azuracast/Azuracast
azuracast_ref: "heads/"
azuracast_ver: "main"
azuracast_dev_repo: "Yahav/AzuraCast" # Your repo name
azuracast_dev_ver: "dev" # Our repo development branch

roles:
- role: init
Expand Down
27 changes: 24 additions & 3 deletions ansible/roles/azuracast-build/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,42 @@
args:
chdir: "{{ www_base }}"

- name: Build AzuraCast Frontend Scripts

- name: Build AzuraCast Frontend Scripts (Production)
become: true
become_user: azuracast
command: >-
node ./node_modules/vite/bin/vite.js build
args:
chdir: "{{ www_base }}"
when:
- app_env == "production"

- name: Remove file (delete file)
ansible.builtin.file:
path: /etc/supervisord.d/vite.conf
state: absent
when:
- app_env == "production"
ignore_errors: true

- name: Install Vite Supervisor (Development)
template:
src: vite_supervisor.conf.j2
dest: /etc/supervisord.d/vite.conf
force: true
mode: 0644
when:
- app_env == "development"

- name: Set permissions of generated frontend content
command: >-
{{ azuracast_build_perm_command }}
loop:
- "chown -R azuracast:www-data {{ www_base }}"
- "find {{ www_base }} -type d -exec chmod 755 {} \\;"
- "find {{ www_base }} -type f -exec chmod 644 {} \\;"
- "find {{ www_base }} -type d -exec chmod 775 {} \\;"
- "find {{ www_base }} -type f -exec chmod 664 {} \\;"
- "find -L {{ www_base }}/node_modules/.bin -type f -exec chmod +x {} \\;"
loop_control:
loop_var: azuracast_build_perm_command
# Note: Don't add warn: false here, it's incompatible with the earlier Ansibles used in 16.04/18.04.
16 changes: 16 additions & 0 deletions ansible/roles/azuracast-build/templates/vite_supervisor.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[program:vite]
directory={{ www_base }}
command=node ./node_modules/vite/bin/vite.js
user=azuracast
priority=700
numprocs=1
autostart=true
autorestart=true

stopasgroup=true
killasgroup=true

stdout_logfile={{ tmp_base }}/service_vite.log
stdout_logfile_maxbytes=5MB
stdout_logfile_backups=5
redirect_stderr=true
2 changes: 2 additions & 0 deletions ansible/roles/azuracast-config/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
file:
path: "{{ www_base }}"
state: absent
when:
- app_env == "production"

- name: Create System Folders
file:
Expand Down
6 changes: 3 additions & 3 deletions ansible/roles/azuracast-radio/tasks/autocue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

- name: Download autocue
get_url:
url: https://github.com/Moonbase59/autocue/archive/refs/tags/v4.0.2.tar.gz
url: https://github.com/Moonbase59/autocue/archive/refs/tags/v4.0.5.tar.gz
dest: "/tmp/autocue.tar.gz"
force: true

Expand All @@ -17,7 +17,7 @@

- name: Copy autocue bin
ansible.builtin.copy:
src: /tmp/autocue-4.0.2/cue_file
src: /tmp/autocue-4.0.5/cue_file
dest: /usr/local/bin/cue_file
owner: azuracast
group: azuracast
Expand All @@ -32,7 +32,7 @@

- name: Copy autocue liq file
ansible.builtin.copy:
src: /tmp/autocue-4.0.2/autocue.cue_file.liq
src: /tmp/autocue-4.0.5/autocue.cue_file.liq
dest: "{{app_base}}/autocue/autocue.liq"
owner: azuracast
group: azuracast
19 changes: 19 additions & 0 deletions ansible/roles/composer/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@
url: "https://github.com/{{azuracast_repo}}/archive/refs/{{azuracast_ref}}/{{azuracast_ver}}.tar.gz"
dest: "/tmp/azuracast-{{azuracast_ver}}.tar.gz"
force: true
when:
- app_env == "production"


- name: Checking out the dev branch
become: true
become_user: azuracast
ansible.builtin.git:
repo: [email protected]:{{azuracast_dev_repo}}.git
dest: "{{ www_base }}/"
version: "{{ azuracast_dev_ver }}"
accept_hostkey: yes
when:
- app_env == "development"


- name: Extract Azuracast
unarchive:
Expand All @@ -18,9 +33,13 @@
remote_src: true
owner: azuracast
group: www-data
when:
- app_env == "production"

- name: Move Azuracast files to www
shell: "rsync -av /tmp/AzuraCast-{{azuracast_ver}}/ {{ www_base }}/ && rm -rf /tmp/AzuraCast-{{azuracast_ver}}"
when:
- app_env == "production"

- name: Install Deps (Development)
become: true
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/init/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
- ca-certificates
- rsync


- name: Update pip components
pip:
name: pip
Expand Down
21 changes: 21 additions & 0 deletions ansible/roles/nginx/templates/default.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ upstream php-fpm-www {
server unix:/run/php-fpm-www.sock;
}

{% if app_env == "development" %}
upstream vite {
server 127.0.0.1:5173;
}
{% endif %}



server {
listen 127.0.0.1:6010;

Expand Down Expand Up @@ -144,9 +152,22 @@ server {
expires 365d;
}


{% if app_env == "development" %}

location /static/vite_dist {
include proxy_params;
proxy_pass http://vite$request_uri;
}

{% else %}

location /static/vite_dist {
expires 365d;
}

{% endif %}


location /static/icons {
expires 365d;
Expand Down
3 changes: 1 addition & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,4 @@ fi

echo "Installing AzuraCast (Environment: $APP_ENV)"
ansible-galaxy collection install community.general
ansible-playbook ansible/deploy.yml --inventory=ansible/hosts --extra-vars "app_env=$APP_ENV"
#ansible-playbook ansible/deploy.yml --inventory=ansible/hosts --extra-vars "app_env=$APP_ENV" --tags "TAG"
ansible-playbook ansible/deploy.yml --inventory=ansible/hosts --extra-vars "app_env=$APP_ENV"
1 change: 1 addition & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if [[ $majorVersion -lt 8 ]]; then
exit 0
fi


sudo dnf update
sudo dnf install -y ansible python3-pip python3-mysqlclient

Expand Down

0 comments on commit 01bfc63

Please sign in to comment.