webapp-deployment-status-api/README.md

94 lines
2.9 KiB
Markdown
Raw Permalink Normal View History

2024-08-30 16:52:39 +00:00
# webapp-deployment-status-api
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
This API provides status information about webapp deployment requests and a mechanism for upload encrypted configuration
files used by those requests.
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
## Build and Run
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
```
$ yarn
$ yarn build
$ yarn start
```
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
## Configuration
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
### Keys
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
Configuration files are encrypted prior to being uploaded using an RSA `publicKey` specified in the `WebappDeployer` record.
On upload, the configuration is temporarily decrypted for validation, but stored in its encrypted format.
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
To create and export a key in the necessary format use:
2024-01-19 02:17:30 +00:00
```
2024-08-30 16:52:39 +00:00
# Create a key
$ gpg --batch --passphrase "SECRET" --quick-generate-key webapp-deployer-api.my.domain.com default default never
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
# Export the public key
$ gpg --export webapp-deployer-api.my.domain.com > webapp-deployer-api.my.domain.com.pgp.pub
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
# Export the private key
$ gpg --export-secret-keys webapp-deployer-api.my.domain.com > webapp-deployer-api.my.domain.com.pgp.key
2024-01-19 02:17:30 +00:00
```
2024-08-30 16:52:39 +00:00
### Create the Deployer Record
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
Every webapp deployer should have `WebappDeployer` record in the registry which looks something like:
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
```
record:
type: WebappDeployer
version: 1.0.0
name: webapp-deployer-api.my.domain.com
apiUrl: https://webapp-deployer-api.my.domain.com
minimumPayment: 100alnt
paymentAddress: laconic1clpc8smrhx5k25zmk3vwna8kddxrsem7a1jlry
publicKey: mQGNBGbJUk0BDAC3j3CiaVtoEf1jrgtsjJnTA5u1a3BExP72mv0eE8y84TgY5rVcf ...
```
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
This record can most easily be created using `laconic-so publish-deployer-to-registry`.
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
```
$ laconic-so publish-deployer-to-registry \
--laconic-config ~/.laconic/registry.yml \
--api-url https://webapp-deployer-api.my.domain.com
--public-key-file webapp-deployer-api.my.domain.com.pgp.pub \
--lrn lrn://laconic/deployers/webapp-deployer-api.my.domain.com \
--min-required-payment 100
```
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
This will create the record in the proper format and assign its LRN.
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
### Request Deployment
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
Users can now request deployment using the LRN of the deployer. This will allow them to:
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
1. Discover the API URL for config uploads.
1. Obtain the public key for encrypting config.
1. See the minimum required payment.
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
The request can be made using `laconic-so request-webapp-deployment`. This will handle encrypting and uploading the
config automatically, as well as making a payment (if necessary).
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
```
$ laconic-so request-webapp-deployment \
--laconic-config ~/.laconic/registry.yml \
--deployer lrn://laconic/deployers/webapp-deployer-api.my.domain.com \
--app lrn://cerc-io/applications/webapp-hello-world@0.1.3 \
--env-file hello.env \
--make-payment auto
```
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
### Example Config
2024-01-19 02:17:30 +00:00
2024-08-30 16:52:39 +00:00
```
UPLOAD_DIRECTORY="/srv/uploads/config"
UPLOAD_MAX_SIZE="1MB"
DEPLOYER_STATE="/srv/deployments/autodeploy.state"
UNDEPLOYER_STATE="/srv/deployments/autoundeploy.state"
BUILD_LOGS="/srv/logs"
OPENPGP_PASSPHRASE="SECRET"
OPENPGP_PRIVATE_KEY_FILE="/etc/config/webapp-deployer-api.my.domain.com.pgp.key"
LACONIC_CONFIG="/etc/config/registry.yml"
```