Add deploy script
This commit is contained in:
parent
eaff1a9239
commit
5035a5e90d
|
@ -0,0 +1,93 @@
|
|||
---
|
||||
- name: Deploy sepiatones_xyz project
|
||||
hosts: all
|
||||
become: yes
|
||||
vars:
|
||||
app_user: "sepiatones_xyz"
|
||||
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 }}/data"
|
||||
state: directory
|
||||
owner: "{{ app_user }}"
|
||||
group: "{{ app_user }}"
|
||||
|
||||
- name: Create templates directory
|
||||
file:
|
||||
path: "{{ app_home }}/templates"
|
||||
state: directory
|
||||
owner: "{{ app_user }}"
|
||||
group: "{{ app_user }}"
|
||||
|
||||
- name: Copy binary to target location
|
||||
copy:
|
||||
src: /mnt/big/code/sepiatones_xyz/target/sepiatones_xyz
|
||||
dest: "{{ app_home }}/sepiatones_xyz"
|
||||
owner: "{{ app_user }}"
|
||||
group: "{{ app_user }}"
|
||||
mode: "0755"
|
||||
|
||||
- name: Copy data directory
|
||||
synchronize:
|
||||
src: /mnt/big/code/sepiatones_xyz/data/
|
||||
dest: "{{ app_home }}/data/"
|
||||
recursive: yes
|
||||
owner: no
|
||||
group: no
|
||||
archive: yes
|
||||
delete: yes
|
||||
|
||||
- name: Copy templates directory
|
||||
synchronize:
|
||||
src: /mnt/big/code/sepiatones_xyz/templates/
|
||||
dest: "{{ app_home }}/templates/"
|
||||
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: /mnt/big/code/sepiatones_xyz/ansible/sepiatones_xyz.caddy
|
||||
dest: /etc/caddy/sites/sepiatones_xyz.caddy
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
|
||||
- name: Ensure Supervisor directory exists
|
||||
file:
|
||||
path: /etc/supervisor/conf.d
|
||||
state: directory
|
||||
|
||||
- name: Copy Supervisor configuration
|
||||
copy:
|
||||
src: /mnt/big/code/sepiatones_xyz/ansible/sepiatones_xyz.supervisor
|
||||
dest: /etc/supervisor/conf.d/sepiatones_xyz.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
|
||||
- name: Reload Supervisor
|
||||
supervisorctl:
|
||||
name: sepiatones_xyz
|
||||
state: present
|
||||
|
||||
- name: Restart the service
|
||||
supervisorctl:
|
||||
name: sepiatones_xyz
|
||||
state: restarted
|
|
@ -0,0 +1,3 @@
|
|||
# It is expected that you have sepiatonesxyz defined in your .ssh/config
|
||||
[production]
|
||||
sepiatonesxyz ansible_host=sepiatonesxyz
|
|
@ -0,0 +1,3 @@
|
|||
sepiatones.xyz {
|
||||
reverse_proxy localhost:3001
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
[program:sepiatones_xyz]
|
||||
command=/home/sepiatones_xyz/sepiatones_xyz
|
||||
directory=/home/sepiatones_xyz
|
||||
user=sepiatones_xyz
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startretries=3
|
||||
stderr_logfile=/var/log/supervisor/sepiatones_xyz.err.log
|
||||
stdout_logfile=/var/log/supervisor/sepiatones_xyz.out.log
|
||||
environment=PORT=3001
|
3
justfile
3
justfile
|
@ -8,8 +8,7 @@ build:
|
|||
bun build --compile --minify --target bun --outfile ./target/sepiatones_xyz ./src/index.tsx
|
||||
|
||||
deploy: build
|
||||
rsync -avz target/sepiatones_xyz sepiatonesxyz:~/sepiatones_xyz/sepiatones_xyz
|
||||
rsync -avz --delete public/ sepiatonesxyz:~/sepiatones_xyz/public
|
||||
ansible-playbook -i ansible/hosts.ini ansible/deploy.yml --ask-become-pass
|
||||
|
||||
test:
|
||||
bun test
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
[Unit]
|
||||
Description=Blog of Sepia
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/home/sepiatones_xyz
|
||||
ExecStart=/home/sepiatones_xyz/sepiatones_xyz
|
||||
Restart=always
|
||||
User=sepiatones_xyz
|
||||
Group=sepiatones_xyz
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in New Issue