Go to file
2024-08-30 11:52:39 -05:00
__tests__ Add log API 2024-02-15 13:55:48 -06:00
src Support uploading config files. (#14) 2024-08-27 19:44:52 +00:00
.editorconfig Initial commit 2024-01-18 20:17:30 -06:00
.env add example .env 2024-05-23 15:25:35 +00:00
.eslintignore Initial commit 2024-01-18 20:17:30 -06:00
.eslintrc.json Initial commit 2024-01-18 20:17:30 -06:00
.gitignore Initial commit 2024-01-18 20:17:30 -06:00
.prettierrc Initial commit 2024-01-18 20:17:30 -06:00
docker-compose.yml Fixes for prod k8s 2024-02-09 00:17:26 +00:00
docker-wrapper.sh Support buildx imagetools 2024-02-23 18:50:36 -06:00
Dockerfile unpin cli version 2024-08-01 11:59:49 +00:00
jest.config.js Initial commit 2024-01-18 20:17:30 -06:00
LICENSE Initial commit 2024-01-18 20:17:30 -06:00
package.json Support uploading config files. (#14) 2024-08-27 19:44:52 +00:00
README.md README 2024-08-30 11:52:39 -05:00
run.sh \ 2024-08-27 15:00:21 -05:00
storage.conf Fixes for prod k8s 2024-02-09 00:17:26 +00:00
tsconfig.json Support uploading config files. (#14) 2024-08-27 19:44:52 +00:00
tsconfig.release.json Initial commit 2024-01-18 20:17:30 -06:00
yarn.lock Support uploading config files. (#14) 2024-08-27 19:44:52 +00:00

webapp-deployment-status-api

This API provides status information about webapp deployment requests and a mechanism for upload encrypted configuration files used by those requests.

Build and Run

$ yarn
$ yarn build
$ yarn start

Configuration

Keys

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.

To create and export a key in the necessary format use:

# Create a key
$ gpg --batch --passphrase "SECRET" --quick-generate-key webapp-deployer-api.my.domain.com default default never

# Export the public key
$ gpg --export webapp-deployer-api.my.domain.com > webapp-deployer-api.my.domain.com.pgp.pub

# Export the private key
$ gpg --export-secret-keys webapp-deployer-api.my.domain.com > webapp-deployer-api.my.domain.com.pgp.key

Create the Deployer Record

Every webapp deployer should have WebappDeployer record in the registry which looks something like:

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 ...

This record can most easily be created using laconic-so publish-deployer-to-registry.

$ 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

This will create the record in the proper format and assign its LRN.

Request Deployment

Users can now request deployment using the LRN of the deployer. This will allow them to:

  1. Discover the API URL for config uploads.
  2. Obtain the public key for encrypting config.
  3. See the minimum required payment.

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).

$ 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

Example Config

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"