mirror of
https://github.com/koodiklinikka/koodiklinikka.fi.git
synced 2026-03-12 09:03:15 +00:00
add deployment stuff
This commit is contained in:
57
deploy/deploy.yml
Normal file
57
deploy/deploy.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
- name: Deploy koodiklinikka.fi
|
||||
hosts: all:!localhost
|
||||
gather_facts: no
|
||||
vars_files:
|
||||
- vars.yml
|
||||
tasks:
|
||||
- name: Deploy client from git
|
||||
remote_user: "{{ service_user }}"
|
||||
action: >
|
||||
git
|
||||
repo="{{ repository_url }}"
|
||||
dest="{{ projects_path }}"
|
||||
accept_hostkey=True
|
||||
|
||||
- name: Install NVM
|
||||
remote_user: "{{ service_user }}"
|
||||
action: >
|
||||
git
|
||||
repo="https://github.com/creationix/nvm"
|
||||
dest="{{ nvm_path }}"
|
||||
|
||||
- name: Make sure Node.js is installed and properly aliased
|
||||
command: >
|
||||
bash -c "source {{ nvm_script }} && nvm install {{ nodejs_version }} && nvm alias {{ project_name }} {{ nodejs_version }}"
|
||||
register: nvm_result
|
||||
changed_when: >
|
||||
"already installed" not in nvm_result.stdout
|
||||
remote_user: "{{ service_user }}"
|
||||
|
||||
- name: Install client NPM dependencies and build assets
|
||||
command: >
|
||||
bash -c "source {{ nvm_script }} && nvm use {{ project_name }} && cd {{ projects_path }} && npm install && NODE_ENV=production npm run build"
|
||||
remote_user: "{{ service_user }}"
|
||||
|
||||
- name: Setup nginx vhost
|
||||
sudo: yes
|
||||
template: >
|
||||
src=templates/nginx.j2
|
||||
dest="/etc/nginx/sites-available/{{ public_hostname }}"
|
||||
mode=664
|
||||
notify: restart nginx
|
||||
|
||||
- name: Enable nginx vhost
|
||||
sudo: yes
|
||||
file: >
|
||||
state=link
|
||||
src=/etc/nginx/sites-available/{{ public_hostname }}
|
||||
dest=/etc/nginx/sites-enabled/{{ public_hostname }}
|
||||
notify: restart nginx
|
||||
|
||||
handlers:
|
||||
- name: restart nginx
|
||||
sudo: true
|
||||
service: >
|
||||
name=nginx
|
||||
state=restarted
|
||||
Reference in New Issue
Block a user