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

Commit

Permalink
chore: change root directory
Browse files Browse the repository at this point in the history
Root directory is changed from /stackhead to /etc/stackhead
as this is a better location for applications.
  • Loading branch information
saitho committed May 27, 2023
1 parent c04c510 commit d6309c6
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Documentation/introduction/cli-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ See example below for setting the setting _server_names_hash_bucket_size_ for th

{% hint style="warning" %}
The `modules` and `modules_config` settings may be overwritten via server configuration.
The server configuration is located in `/stackhead/config.yml` (if it exists).
The server configuration is located in `/etc/stackhead/config.yml` (if it exists).
{% endhint %}

## Full annotated configuration
Expand Down
15 changes: 5 additions & 10 deletions Documentation/introduction/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ and the non-root StackHead user that is used for deploying projects.

This command needs to be executed before projects can be deployed onto the target server.

{% hint style="info" %}
Right now it is not possible for StackHead to deal with SSH fingerprints. Please connect to the server yourself via SSH
and accept the fingerprint hashes. Otherwise StackHead CLI is stuck in the connecting phase and can not proceed.
{% endhint %}

### Syntax

```shell
Expand All @@ -33,7 +28,7 @@ stackhead-cli setup [IPv4 or IPv6 address]

### Example

```bash
```shell
# IPv4
stackhead-cli setup 123.45.67.8

Expand Down Expand Up @@ -64,7 +59,7 @@ stackhead-cli project deploy [path to project definition] [ipv4 address] [--auto

### Example

```bash
```shell
./bin/stackhead-cli project deploy my_file.stackhead.yml 123.45.67.8
```

Expand All @@ -81,7 +76,7 @@ stackhead-cli project destroy [path to project definition] [ipv4 address]

### Example

```bash
```shell
./bin/stackhead-cli project destroy my_file.stackhead.yml 123.45.67.8
```

Expand All @@ -91,7 +86,7 @@ There are two commands you can use in order to validate StackHead configuration

### Syntax

```
```shell
# Validate Project definition file
./bin/stackhead-cli project validate [path to project definition]

Expand All @@ -101,7 +96,7 @@ There are two commands you can use in order to validate StackHead configuration

### Example

```bash
```shell
# Validate Project definition file
./bin/stackhead-cli project validate my_file.stackhead.yml

Expand Down
6 changes: 6 additions & 0 deletions Documentation/introduction/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,9 @@ stackhead-cli destroy ./stackhead/example_app.stackhead.yml 123.456.789.10
stackhead-cli destroy ./stackhead/example_app.stackhead.yml 1234:4567:90ab:cdef::1
```

## Troubleshotting

### Setup fails: `Unable to prepare setup. (ssh: handshake failed: knownhosts: key mismatch)`

Looks like the SSH signature from the target server changed and does not match the value saved in `~/.ssh/stackhead_known_hosts` anymore.
Remove the entry for the server IP address there and try again.
20 changes: 10 additions & 10 deletions Documentation/introduction/project-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ Note that you should not use or call any files in the file that are not already

StackHead saves mounted data in the project directory at project or service level. You can also define a custom location on the server.

| Configuration | Description | Allowed values |
| :--- | :--- | :--- |
| `type` \(required\) | Determines the data storage location | "global", "local" or "custom" |
| | **global**: Data storage location is located at `/stackhead/projects/[project_name]/container_data/global/` | |
| | **local**: Data storage location is located at `/stackhead/projects/[project_name]/container_data/services/[service_name]/` | |
| | **custom**: No data storage location. You have to set it yourself using the _src_ setting below \(absolute path!\). | |
| Configuration | Description | Allowed values |
| :--- |:-------------------------------------------------------------------------------------------------------------------------------| :--- |
| `type` \(required\) | Determines the data storage location | "global", "local" or "custom" |
| | **global**: Data storage location is located at `/etc/stackhead/projects/[project_name]/container_data/global/` | |
| | **local**: Data storage location is located at `/etc/stackhead/projects/[project_name]/container_data/services/[service_name]/` | |
| | **custom**: No data storage location. You have to set it yourself using the _src_ setting below \(absolute path!\). | |
| `src` \(required for type=custom\) | Relative path inside data storage location that should be mounted. Note: When type=custom this is has to be an absolute path! | any string |
| `dest` | Absolute path inside the Docker container where the mount should be applied | any string |
| `mode` | Defines if the volume should be read-write \(rw\) or readonly \(ro\) | "rw" \(default\) or "ro" |
| `dest` | Absolute path inside the Docker container where the mount should be applied | any string |
| `mode` | Defines if the volume should be read-write \(rw\) or readonly \(ro\) | "rw" \(default\) or "ro" |

Below you can see a comparison of the project definition \(left\) and the equivalent docker-compose definition:

Expand Down Expand Up @@ -232,8 +232,8 @@ services:
nginx:
# ...
volumes:
- /stackhead/projects/example_project/container_data/global/assets:/var/www/public/assets:rw
- /stackhead/projects/example_project/container_data/services/nginx/log:/var/www/public/log:rw
- /etc/stackhead/projects/example_project/container_data/global/assets:/var/www/public/assets:rw
- /etc/stackhead/projects/example_project/container_data/services/nginx/log:/var/www/public/log:rw
- /etc/secrets.txt:/var/www/secrets.txt:ro
```
{% endcode %}
Expand Down
4 changes: 2 additions & 2 deletions Documentation/technical-documentation/ssl-certificates.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ The figure above shows the organisation of SSL certificates and how they are use

The **snakeoil certificate** is created during server setup. It is a selfsigned certificate that technically expires after 100 years after creation, i.e. never. \(If it really expires simply run the server setup again.\)

The certificate and corresponding private key is stored inside the `/stackhead/certificates` directory.
The certificate and corresponding private key is stored inside the `/etc/stackhead/certificates` directory.

Freshly generated Nginx configurations will have a certificate paths that are symlinked to these snakeoil files, enabling Nginx to start.

## Project certificates

Project certificates are generated after the Nginx server configuration is written and active. They are stored inside the `certificates` folder of the project directory \(i.e. `/stackhead/projects/<project_name>/certificates`\).
Project certificates are generated after the Nginx server configuration is written and active. They are stored inside the `certificates` folder of the project directory \(i.e. `/etc/stackhead/projects/<project_name>/certificates`\).

After creation, the symlinked path to the certificate used by Nginx is switched to the generated certificate \(and private key\) and the Nginx configuration is reloaded.

4 changes: 4 additions & 0 deletions Documentation/technical-documentation/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ We recommend setting up the projects from scratch. However it should be possible

## Breaking Changes

### Change root directory

The root directory was changed from `/stackhead` to `/etc/stackhead`.

### Removed Terraform

Terraform is nice and great, but it is a software that requires updates. The main software and plugins as well.
Expand Down
6 changes: 3 additions & 3 deletions commands/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func userSetup() error {

// Add stackhead user if it does not exist
if _, _, err := system.RemoteRun("id", system.RemoteRunOpts{Args: []string{"stackhead"}}); err != nil {
if _, _, err := system.RemoteRun("adduser", system.RemoteRunOpts{Args: []string{"--system --shell /bin/sh --uid 1412 --no-create-home --home=/stackhead --gid 1412 stackhead"}}); err != nil {
if _, _, err := system.RemoteRun("adduser", system.RemoteRunOpts{Args: []string{"--system --shell /bin/sh --uid 1412 --no-create-home --home=" + config.RootDirectory + " --gid 1412 stackhead"}}); err != nil {
return fmt.Errorf("unable to add stackhead user")
}
}
Expand Down Expand Up @@ -157,11 +157,11 @@ func userSetup() error {
logger.Debugln(err)
return fmt.Errorf("unable to read local stackhead public SSH key")
}
if err := xfs.CreateFolder("ssh:///stackhead/.ssh"); err != nil {
if err := xfs.CreateFolder("ssh://" + config.RootDirectory + "/.ssh"); err != nil {
return err
}
if err := xfs.WriteFile(
"ssh:///stackhead/.ssh/authorized_keys",
"ssh://"+config.RootDirectory+"/.ssh/authorized_keys",
string(publicKeyBytes),
); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion config/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/shibukawa/configdir"
)

var RootDirectory = "/stackhead"
var RootDirectory = "/etc/stackhead"
var ProjectsRootDirectory = RootDirectory + "/projects"

func GetServerConfigFilePath() string {
Expand Down

0 comments on commit d6309c6

Please sign in to comment.