Create deploy script
This commit is contained in:
parent
042d83e2c1
commit
a0f6e47f57
|
@ -0,0 +1,84 @@
|
||||||
|
---
|
||||||
|
- name: Deploy gomoku project
|
||||||
|
hosts: all
|
||||||
|
become: yes
|
||||||
|
vars:
|
||||||
|
app_user: 'gomoku'
|
||||||
|
app_home: '/home/{{ app_user }}'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Ensure user exists
|
||||||
|
user:
|
||||||
|
name: '{{ app_user }}'
|
||||||
|
shell: /bin/bash
|
||||||
|
create_home: yes
|
||||||
|
home: '{{ app_home }}'
|
||||||
|
|
||||||
|
- name: Create data directory
|
||||||
|
file:
|
||||||
|
path: '{{ app_home }}/public'
|
||||||
|
state: directory
|
||||||
|
owner: '{{ app_user }}'
|
||||||
|
group: '{{ app_user }}'
|
||||||
|
|
||||||
|
- name: Copy binary to target location
|
||||||
|
copy:
|
||||||
|
src: ../target/gomoku
|
||||||
|
dest: '{{ app_home }}/gomoku'
|
||||||
|
owner: '{{ app_user }}'
|
||||||
|
group: '{{ app_user }}'
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Copy data directory
|
||||||
|
synchronize:
|
||||||
|
src: ../public/
|
||||||
|
dest: '{{ app_home }}/public/'
|
||||||
|
recursive: yes
|
||||||
|
owner: no
|
||||||
|
group: no
|
||||||
|
archive: yes
|
||||||
|
delete: yes
|
||||||
|
|
||||||
|
- name: Ensure Caddy directory exists
|
||||||
|
file:
|
||||||
|
path: /etc/caddy/sites
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Copy Caddy configuration
|
||||||
|
copy:
|
||||||
|
src: gomoku.caddy
|
||||||
|
dest: /etc/caddy/sites/gomoku.caddy
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: '0644'
|
||||||
|
register: caddy_config_copy
|
||||||
|
|
||||||
|
- name: Restart Caddy service if config changed
|
||||||
|
systemd:
|
||||||
|
name: caddy
|
||||||
|
state: restarted
|
||||||
|
daemon_reload: yes
|
||||||
|
when: caddy_config_copy.changed
|
||||||
|
|
||||||
|
- name: Ensure Supervisor directory exists
|
||||||
|
file:
|
||||||
|
path: /etc/supervisor/conf.d
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Copy Supervisor configuration
|
||||||
|
copy:
|
||||||
|
src: gomoku.supervisor
|
||||||
|
dest: /etc/supervisor/conf.d/gomoku.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
|
- name: Reload Supervisor
|
||||||
|
supervisorctl:
|
||||||
|
name: gomoku
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Restart the service
|
||||||
|
supervisorctl:
|
||||||
|
name: gomoku
|
||||||
|
state: restarted
|
|
@ -0,0 +1,3 @@
|
||||||
|
gomoku.sepiatones.xyz {
|
||||||
|
reverse_proxy localhost:3002
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
[program:gomoku]
|
||||||
|
command=/home/gomoku/gomoku
|
||||||
|
directory=/home/gomoku
|
||||||
|
user=gomoku
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
startretries=3
|
||||||
|
stderr_logfile=/var/log/supervisor/gomoku.err.log
|
||||||
|
stdout_logfile=/var/log/supervisor/gomoku.out.log
|
||||||
|
environment=PORT=3002
|
|
@ -0,0 +1,3 @@
|
||||||
|
# It is expected that you have sepiatonesxyz defined in your .ssh/config
|
||||||
|
[production]
|
||||||
|
sepiatonesxyz ansible_host=sepiatonesxyz ansible_python_interpreter=/usr/bin/python3.11
|
3
justfile
3
justfile
|
@ -8,8 +8,7 @@ build:
|
||||||
bun build --compile --minify --target bun --outfile ./target/gomoku ./src/index.ts
|
bun build --compile --minify --target bun --outfile ./target/gomoku ./src/index.ts
|
||||||
|
|
||||||
deploy: build
|
deploy: build
|
||||||
rsync -avz target/gomoku sepiatonesxyz:~/gomoku/gomoku
|
ansible-playbook -i ansible/hosts.ini ansible/deploy.yml
|
||||||
rsync -avz --delete public/ sepiatonesxyz:~/gomoku/public
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
bun test
|
bun test
|
||||||
|
|
Loading…
Reference in New Issue