Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,34 @@ The script will display a usage message and you can then bootstrap your server:

Once you're done head over to the [Piku documentation](https://github.com/piku/piku/#using-piku) to see how to deploy your first app.

### Multi-Environment Setup

You can run multiple piku environments on the same server (e.g., production, staging, dev). Use the `PIKU_USER` environment variable to specify the username for each environment:

```shell
# Install default piku environment
./piku-bootstrap install

# Install staging environment
PIKU_USER=piku-staging ./piku-bootstrap install

# Install dev environment
PIKU_USER=piku-dev ./piku-bootstrap install
```

Each environment runs its own uWSGI emperor and nginx path watcher. Apps in different environments can have the same name without conflict.

**Deploying to different environments:**

```shell
# From your development machine
git remote add production piku@yourserver:myapp
git remote add staging piku-staging@yourserver:myapp

git push staging feature-branch
git push production main
```

### Installing other dependencies

`piku-bootstrap` uses Ansible internally and it comes with some extra built-in playbooks which you can use to bootstrap common components onto your `piku` server.
Expand Down
16 changes: 8 additions & 8 deletions playbooks/piku.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@

- name: Install uwsgi-piku systemd script
get_url:
url: https://raw.githubusercontent.com/piku/piku/master/uwsgi-piku.service
dest: /etc/systemd/system/uwsgi-piku.service
url: https://raw.githubusercontent.com/piku/piku/master/uwsgi-piku@.service
dest: /etc/systemd/system/uwsgi-piku@.service
mode: 0600

- name: Create piku ansible tmp dir
Expand Down Expand Up @@ -168,7 +168,7 @@

- name: Enable uwsgi-piku service
systemd:
name: uwsgi-piku
name: uwsgi-piku@{{ user }}
enabled: yes
state: started
masked: no
Expand All @@ -178,7 +178,7 @@
# https://github.com/ansible/ansible/issues/72451
- name: Actually enable uwsgi-piku service (bug workaround)
shell:
cmd: "systemctl enable uwsgi-piku.service"
cmd: "systemctl enable uwsgi-piku@{{ user }}.service"
when: '"systemctl" in systemctl.stdout and uwsgi_systemd.status.UnitFileState == "enabled-runtime"'

- name: Start uwsgi init script
Expand All @@ -201,9 +201,9 @@
state: restarted
when: nginx_config_installed is changed

- name: Get systemd.path piku-nginx.path
- name: Get systemd.path piku-nginx@.path
get_url:
url: https://raw.githubusercontent.com/piku/piku/master/piku-nginx.path
url: https://raw.githubusercontent.com/piku/piku/master/piku-nginx@.path
dest: /etc/systemd/system/
register: piku_nginx_path_installed

Expand All @@ -213,9 +213,9 @@
dest: /etc/systemd/system/
register: piku_nginx_service_installed

- name: Start piku-nginx.path
- name: Start piku-nginx@.path
systemd:
name: piku-nginx.path
name: piku-nginx@{{ user }}.path
state: started
enabled: yes
when: ( piku_nginx_service_installed is changed ) and ( "systemctl" in systemctl.stdout )