# @adp-psych/container-tools

Tools for using containers for psychology experiments.

## Usage

### Installation

Install the package from [npm](https://www.npmjs.com/)
(requires [Node.js](https://nodejs.org/)):

```sh
npm install --save-dev @adp-psych/container-tools
```

### Dependencies

These tools depend on the following software:

- [**podman**](https://podman.io/):
  A tool for running [OCI](https://opencontainers.org/) containers.
  [\[Installation instructions\]](https://podman.io/getting-started/installation.html)

- [**buildah**](https://buildah.io/):
  A tool for building [OCI](https://opencontainers.org/) images.
  [\[Installation instructions\]](https://github.com/containers/buildah/blob/master/install.md)

- [**doctl**](https://docs.digitalocean.com/reference/doctl/):
  The [DigitalOcean](https://www.digitalocean.com/) command-line interface.
  [\[Installation instructions\]](https://docs.digitalocean.com/reference/doctl/how-to/install/)

- [**kubectl**](https://kubernetes.io/docs/tasks/tools/#kubectl):
  The [Kubernetes](https://kubernetes.io/) command-line interface.
  [\[Installation instructions\]](https://kubernetes.io/docs/tasks/tools/#kubectl)

- [**Helm**](https://helm.sh/):
  The [Kubernetes](https://kubernetes.io/) package manager.
  [\[Installation instructions\]](https://helm.sh/docs/intro/install/)

The above software must be installed and available via the system path
for these tools to work.

### Accounts

These tools require you to have a [DigitalOcean](https://www.digitalocean.com/)
account to host your experiments and a container registry account to host your
containers (e.g., [Quay.io](https://quay.io/)).

#### DigitalOcean

[Sign up for a DigitalOcean account](https://cloud.digitalocean.com/registrations/new)
and
[create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/).
I recommend creating a separate personal access token for each computer that
will have access to your DigitalOcean account, and naming each token after
the computer that will use it.

Configure doctl to access your account (replace `$TOKEN` with your token):

```sh
doctl auth init -t "$TOKEN"
```

Then
[create another personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/)
named `ExternalDNS` for
[ExternalDNS](https://github.com/kubernetes-sigs/external-dns) to use.

#### Quay.io

[Create a Quay.io account](https://quay.io/signin/).

Configure podman to access your account:

```sh
podman login quay.io
```

### Execution

Show the usage information for each command:

```sh
npx build-container --help
npx build-helm-chart --help
npx build-kubernetes-configuration --help
npx create-digitalocean-domain --help
npx create-kubernetes-cluster --help
npx install-cert-manager --help
npx install-experiment --help
npx install-external-dns --help
npx install-wave --help
```

## Development

### Cleaning

Remove generated files:

```sh
npm run clean
```

### Documentation

Generate documentation into the `doc` directory with
[JSDoc](https://jsdoc.app/):

```sh
npm run doc
```

### Linting

Lint the project with [ESLint](https://eslint.org/) and
[npm-package-json-lint](https://npmpackagejsonlint.org/):

```sh
npm run lint
```

### Testing

Test the command by running it:

```sh
npm run test
```

### Dependencies

Check for new dependencies with
[npm-check](https://github.com/dylang/npm-check):

```sh
npm run npm-check
```

### Release

Publish a release with [np](https://github.com/sindresorhus/np):

```sh
npm run release
```

## Legal Information

### Copyright

Copyright © 2021, 2022  Anthony Di Pietro

### License

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see
[https://www.gnu.org/licenses/](https://www.gnu.org/licenses/).
