Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
docs: update instructions for StackHead CLI usage
Browse files Browse the repository at this point in the history
  • Loading branch information
saitho committed Sep 9, 2020
1 parent 16377eb commit b779ea1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 55 deletions.
13 changes: 0 additions & 13 deletions .stackhead/inventory.yml

This file was deleted.

83 changes: 41 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,79 +8,78 @@ It provides examples for deploying a single and multi container applications.

In order to try out this sample project, you'll need the following:

* [StackHead CLI binary file](https://docs.stackhead.io/v/next/introduction/installation)
* [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html)
* a web server with root SSH access (we recommend renting a [pay-per-use VPS at Hetzner. Get 20€ cloud balance for free](https://hetzner.cloud/?ref=n7H3qhWcZ2QS))
* a top level (sub) domain with A record pointing to your server IP

Also make sure to install StackHead via Ansible:
```shell script
ansible-galaxy collection install git+https://github.com/getstackhead/stackhead.git
```
Initialize StackHead by running the command below.
This will install all dependencies required.

and the required Ansible files via Ansible Galaxy:
```shell script
ansible-galaxy install -r ~/.ansible/collections/ansible_collections/getstackhead/stackhead/requirements/requirements.yml
stackhead-cli init
```

## How to use

### Configuration
### Server provisioning

```bash
stackhead-cli setup [IP_ADDRESS]
```

After provisioning completed, you should see the Nginx default page when opening your domain in your browser.

### Application deployment

The following sections describe how to configure the samples for your server and domain.
The provisioning and deployment part is the same regardless of the example you want to use.
There are two differently sized projects, consisting of one single container and multiple containers.

#### Single container application

1. Adjust your inventory configuration in `.stackhead/inventory.yml`
1. Change the IP address in `ansible_host` to your own servers IP in `.stackhead/inventory.yml`
2. Uncomment the line "- example_container_single" in `applications` section

2. Adjust the project settings in `.stackhead/project/example_container_single.yml`
1. Adjust the project settings in `.stackhead/project/example_container_single.yml`
1. Set your own domain in `domain`

3. Does not work currently ~~Validate your project file using the `project-validator` binary:~~
```shell script
./vendor/getstackhead/stackhead/validation/bin/project-validator .stackhead/project/example_container_single.yml
2. Validate your project file using the `validate` command:
```bash
stackhead-cli validate .stackhead/project/example_container_single.yml
```

#### Multi container application
3. Deploy the application. Make sure to replace `[IP_ADDRESS]` with your servers IP address.
```bash
stackhead-cli deploy ./.stackhead/example_container_single.yml [IP_ADDRESS]
```

1. Adjust your inventory configuration in `.stackhead/inventory.yml`
1. Change the IP address in `ansible_host` to your own servers IP in `.stackhead/inventory.yml`
2. Uncomment the line "- example_container_multi" in `applications` section
4. After deployment, open the domain in your web browser. You should see a page that prints "Hello world!" alongside the PHP version and successful database connection.

2. Adjust the project settings in `.stackhead/project/example_container_multi.yml`
1. Set your own domain in `domain`

3. Does not work currently ~~Validate your project file using the `project-validator` binary:~~
```shell script
./vendor/getstackhead/stackhead/validation/bin/project-validator .stackhead/project/example_container_multi.yml
```

### Server provisioning
5. Remove the application:

```shell script
ansible-playbook ~/.ansible/collections/ansible_collections/getstackhead/stackhead/playbooks/server-provision.yml
stackhead-cli destroy example_container_single
```

After provisioning completed, you should see the Nginx default page when opening your domain in your browser.
#### Multi container application

### Application deployment
1. Adjust the project settings in `.stackhead/project/example_container_multi.yml`
1. Set your own domain in `domain`

```shell script
ansible-playbook ~/.ansible/collections/ansible_collections/getstackhead/stackhead/playbooks/application-deploy.yml
```
3. Validate your project file using the `validate` command:
```bash
stackhead-cli validate .stackhead/project/example_container_multi.yml
```

After deployment, open the domain in your web browser.
3. Deploy the application. Make sure to replace `[IP_ADDRESS]` with your servers IP address.
```bash
stackhead-cli deploy ./.stackhead/project/example_container_multi.yml [IP_ADDRESS]
```

If you deployed a container-typed project, you should see a page that prints "Hello world!" alongside the PHP version and successful database connection.
If you deployed the `example_container_multi` project you can access PhpMyAdmin on port 81 (no HTTPS).
4. After deployment, open the domain in your web browser.
You should see a page that prints "Hello world!" alongside the PHP version and successful database connection.

### Remove application
You can access PhpMyAdmin on port 81 (no HTTPS).

If you want to remove your application, run the following playbook.
Make sure to replace `PROJECTNAME` with the name of the project you set up (i.e. example_container_multi or example_container_single).
5. Remove the application:

```shell script
ansible-playbook ~/.ansible/collections/ansible_collections/getstackhead/stackhead/playbooks/application-destroy.yml --extra-vars "project_name=PROJECTNAME"
stackhead-cli destroy example_container_multi
```

0 comments on commit b779ea1

Please sign in to comment.