From d6309c66abfb5a778e23f64570e9faa75be26608 Mon Sep 17 00:00:00 2001 From: Mario Lubenka Date: Sat, 27 May 2023 18:48:33 +0200 Subject: [PATCH] chore: change root directory Root directory is changed from /stackhead to /etc/stackhead as this is a better location for applications. --- .../introduction/cli-configuration.md | 2 +- Documentation/introduction/commands.md | 15 +++++--------- Documentation/introduction/getting-started.md | 6 ++++++ .../introduction/project-definition.md | 20 +++++++++---------- .../ssl-certificates.md | 4 ++-- .../technical-documentation/upgrading.md | 4 ++++ commands/setup.go | 6 +++--- config/paths.go | 2 +- 8 files changed, 32 insertions(+), 27 deletions(-) diff --git a/Documentation/introduction/cli-configuration.md b/Documentation/introduction/cli-configuration.md index 0c876081..64ae27ac 100644 --- a/Documentation/introduction/cli-configuration.md +++ b/Documentation/introduction/cli-configuration.md @@ -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 diff --git a/Documentation/introduction/commands.md b/Documentation/introduction/commands.md index 61005ca4..7dec2ff4 100644 --- a/Documentation/introduction/commands.md +++ b/Documentation/introduction/commands.md @@ -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 @@ -33,7 +28,7 @@ stackhead-cli setup [IPv4 or IPv6 address] ### Example -```bash +```shell # IPv4 stackhead-cli setup 123.45.67.8 @@ -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 ``` @@ -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 ``` @@ -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] @@ -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 diff --git a/Documentation/introduction/getting-started.md b/Documentation/introduction/getting-started.md index 63fabb80..37ef8080 100644 --- a/Documentation/introduction/getting-started.md +++ b/Documentation/introduction/getting-started.md @@ -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. diff --git a/Documentation/introduction/project-definition.md b/Documentation/introduction/project-definition.md index c5d8393c..f7010400 100644 --- a/Documentation/introduction/project-definition.md +++ b/Documentation/introduction/project-definition.md @@ -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: @@ -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 %} diff --git a/Documentation/technical-documentation/ssl-certificates.md b/Documentation/technical-documentation/ssl-certificates.md index 74760edc..9d461314 100644 --- a/Documentation/technical-documentation/ssl-certificates.md +++ b/Documentation/technical-documentation/ssl-certificates.md @@ -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//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//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. diff --git a/Documentation/technical-documentation/upgrading.md b/Documentation/technical-documentation/upgrading.md index fac1f28a..cb3095f9 100644 --- a/Documentation/technical-documentation/upgrading.md +++ b/Documentation/technical-documentation/upgrading.md @@ -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. diff --git a/commands/setup.go b/commands/setup.go index 69c09dda..20cb9bff 100644 --- a/commands/setup.go +++ b/commands/setup.go @@ -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") } } @@ -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 diff --git a/config/paths.go b/config/paths.go index be8285ed..4de2648f 100644 --- a/config/paths.go +++ b/config/paths.go @@ -7,7 +7,7 @@ import ( "github.com/shibukawa/configdir" ) -var RootDirectory = "/stackhead" +var RootDirectory = "/etc/stackhead" var ProjectsRootDirectory = RootDirectory + "/projects" func GetServerConfigFilePath() string {