README.md (9292B)
1 # Introduction 2 3 The sandcastle is a containerized deployment of GNU Taler 4 5 It uses podman to build an image and run a single container that 6 has systemd running inside. 7 8 9 # Prerequisites 10 11 You need (on your host system): 12 13 * podman 14 * bash 15 16 The sandcastle-ng container exposes TCP ports that serve the APIs / Web 17 interfaces of the respective GNU Taler service via HTTP. 18 19 Some of these services expect to be accessed via a certain hostname, 20 so it is recommended that you set up the following domain names: 21 22 * `exchange.$MYDOMAIN` for taler-exchange 23 * `backend.$MYDOMAIN` for taler-merchant 24 * `bank.$MYDOMAIN` for libeufin-bank 25 * `landing.$MYDOMAIN` for the demo landing page 26 * `shop.$MYDOMAIN` for the demo blog shop page 27 * `donations.$MYDOMAIN` for the demo donations page 28 * `paivana.$MYDOMAIN` for the demo Paivana paywall 29 30 Your host system should reverse-proxy HTTP(s) traffic to the respective service 31 port for each of the services. 32 33 34 # Upgrading Component Versions 35 36 Run `./sandcastle-upgrade` to update the git tags in `buildconfig/$component.tag` 37 to the latest upstream tag of the respective repository 38 (taken from `buildconfig/$component.giturl`). 39 40 By default only production tags (`vX.Y.Z`, `deb-vX.Y.Z-R`) are considered. 41 Pass `--dev` to also consider dev tags (`vX.Y.Z-dev.N`). 42 Pass `--dry` to only show what would change. 43 Individual components can be given as arguments, e.g. 44 45 ./sandcastle-upgrade --dev taler-exchange gnunet 46 47 Components whose tag file pins something that is not a version tag 48 (such as a branch name) are left alone, as are components without a 49 `.giturl` file. 50 51 To only *show* the latest upstream versions without changing anything, 52 use `./print-latest-versions`. 53 54 55 # Building the Container Image 56 57 1. In `buildconfig/$component.tag` set the git tag you want to build. 58 59 2. Run `./sandcastle-build` to build the Taler container. The resulting container 60 will be tagged as `taler-base-all`. 61 62 By default `sandcastle-build` builds from the `Dockerfile` 63 in the same directory as the script. 64 Anyhow you can pass a different container file like this: 65 66 ./sandcastle-build nightly.Dockerfile 67 68 69 # Configuring the Deployment 70 71 If you just want to play around with the Taler services inside the container, 72 or want to get an integration development environment, 73 there is a nice preset, see below. 74 Thus in these cases no configuration is required 75 and you can skip to "Running the Deployment" below. 76 77 For Taler developers, it is recommended that for each sandcastle deployment, 78 you clone the sandcastle-ng.git repository 79 (https://git.taler.net/sandcastle-ng.git) and create a branch with 80 deployment-specific changes. 81 82 Currently there is not much configuration. 83 84 The main adjustments to be made are: 85 86 * scripts/demo/setup-sandcastle.sh has the currency on top of the file 87 * sandcastle-run has variables for the ports that'll be exposed ("published") on 88 the host. They can be overwritten with environment variables 89 (``TALER_SANDCASTLE_PORT_$COMPONENT``). 90 91 To make adjustments for an environment without changing the 92 ``setup-sandcastle.sh`` script, you can use an override file 93 ``overrides/$YOUR_ENVIRONMENT``. This is a bash script that is sourced at the 94 beginning of ``setup-sandcastle.sh`` and can be used to customize 95 environment-specific settings such as hostnames. 96 97 In order to choose an override, 98 set the ``SANDCASTLE_OVERRIDE_NAME`` environment variable 99 before running `./sandcastle-run`: 100 101 SANDCASTLE_OVERRIDE_NAME=$YOUR_ENVIRONMENT ./sandcastle-run 102 103 104 The following variables are typically adjusted in an override file: 105 106 * ``CURRENCY``: Currency of the deployment 107 * ``MYDOMAIN``: Parent domain name for ``{bank,exchange,backend}`` services. 108 * ``EXTERNAL_PORT``: The host port the services will be available on. 109 * ``EXTERNAL_IP``: The host IP the services will be available on. 110 For security reasons this defaults to localhost (127.0.0.1). 111 * ``USE_INSECURE_SANDBOX_PASSWORDS``: 112 If set to `1`, use password `sandbox` for all services instead of random ones. 113 WARNING! Use only when listening to localhost! 114 * ``PAIVANA_DESTINATION``: Upstream website that the Paivana paywall 115 protects. Defaults to `https://www.taler.net/`. Note that this is an 116 *external* server that the container proxies to, it is not served by the 117 sandcastle itself. 118 119 120 # Running the Deployment 121 122 Run ``./sandcastle-run`` to run the single container. 123 The container will be named `taler-sandcastle`. 124 On the first run, wait until everything has been set up: 125 126 ./sandcastle-logs 127 128 129 Note that ``./sandcastle-run`` is just a wrapper around ``podman run``. 130 If required, you can pass addtional arguments to ``./sandcastle-run``. 131 These will be passed on to ``podman run``. Example: 132 133 ./sandcastle-run --log-level=debug 134 135 The running container publishes ports to the host as defined in ``./sandcastle-run``. 136 You can manually verify these port mappings via ``podman port taler-sandcastle``. 137 138 When starting sandcastle like 139 140 SANDCASTLE_OVERRIDE_NAME=taler.localhost ./sandcastle-run 141 142 the services will be available as 143 144 - http://taler.localhost:4321 145 - http://bank.taler.localhost:4321 146 - http://shop.taler.localhost:4321 147 - http://donations.taler.localhost:4321 148 - http://backend.taler.localhost:4321 - the merchant backend 149 - http://exchange.taler.localhost:4321 150 - http://auditor.taler.localhost:4321 151 - http://challenger.taler.localhost:4321 152 - http://paivana.taler.localhost:4321/en/ - www.taler.net behind a Taler paywall 153 (use the ``/en/`` entry point, as www.taler.net redirects ``/`` to its own domain) 154 155 This gives a nice environment for integration testing. 156 157 158 # Stopping the deployment 159 160 For stopping the deployment simply run 161 162 ``` 163 ./sandcastle-stop 164 ``` 165 166 which is just a shortcut for ``podman stop taler-sandcastle``. 167 168 169 # Watching Logs 170 171 Run ``./sandcastle-logs`` to watch the logs within the container. 172 You can pass addtional arguments to ``./sandcastle-logs``, 173 which will be passed on to ``journalctl`` in the container. Example: 174 175 ./sandcastle-logs --output=cat 176 177 178 # Poking Around 179 180 You can poke around in a running sandcastle instance by running 181 182 ``` 183 podman exec -it taler-sandcastle /bin/bash 184 ``` 185 186 Or, as a shortcut: 187 188 ``` 189 ./sandcastle-enter 190 ``` 191 192 This will drop you into a shell inside the running container, 193 where you have access to systemd, journalctl, etc. 194 195 196 # Data Storage 197 198 All persistent data is stored in a podman volume called 199 _talerdata_. You can see where it is in your filesystem 200 by running ``podman volume inspect talerdata``. 201 202 That volume also contains the postgres database files. 203 204 ## Cleaning the Data Storage 205 206 For cleaning the data storage run 207 208 ./sandcastle-plow 209 210 and for cleaning also the persistent storage run 211 212 ./sandcastle-plow all 213 214 215 # Provisioning Details 216 217 The whole deployment is configured by a script 218 mounted into the container as ``/provision/setup-sandcastle.sh``. 219 This script will be run as a oneshot systemd service and will disable itself after 220 the first success. 221 222 To troubleshoot, run ``journalctl -u setup-sandcastle.service``. 223 224 There are different setup scripts in the ``scripts/$SANDCASTLE_SETUP_NAME`` 225 folders. Specifically: 226 227 * ``none`` does no setup at all 228 * ``demo`` set up the usual Taler demo 229 * TBD: ``regio`` is a currency conversion setup 230 231 By default, ``demo`` is used. 232 To mount a different provision script, 233 set ``$SANDCASTLE_SETUP_NAME`` when running ``./sandcastle-run``, 234 like this 235 236 SANDCASTLE_SETUP_NAME=none ./sandcastle-run 237 238 239 You can always manually run any of the provisioning script inside the container as 240 ``/scripts/$SANDCASTLE_SETUP_NAME/setup-sandcastle.sh``. 241 242 # Importing / exporting 243 244 To migrate a sandcastle deployment, export / import can be used. 245 246 ``` 247 # Requires taler-sandcastle to be running. 248 # Export the sandcastle data to ./exported/ 249 ./sandcastle-export 250 251 # Other host: 252 # Request an import 253 touch exported/import-request 254 # Now the deployment script will pick up the data to import 255 ./sandcastle-run 256 ``` 257 258 # Neat Things That Already Work 259 260 * Rebulding the base image is incremental, since we use layers. If the tag 261 of the exchange is changed, only the exchange and components that depend 262 on it are rebuilt. 263 * Inside the container, the service names resolve to localhost, 264 and on localhost a reverse proxy with locally signed certificates 265 ensures that services can talk to each other *within* the container 266 by using their *public* base URL. 267 268 269 # Future Extensions 270 271 * Better way to access logs, better way to expose errors during provisioning 272 * The Dockerfile should introduce nightly tags for debian packages it builds. 273 Currently it just uses the latest defined version, which is confusing. 274 * Deploy the Taler woocommerce plugin, wordpress plugin, Joomla plugin 275 * Do self-tests of the deployment using the wallet CLI 276 * Running the auditor 277 * Running a currency conversion setup with multiple libeufin-bank instances 278 * Instead of exposing HTTP ports, we could expose everything via unix domain sockets, 279 avoiding port collision problems. 280 * Instead of requiring the reverse proxy to handle TLS, 281 the sandcastle container itself could do TLS termination with caddy. 282 * To improve performance, allow connecting to an external database 283 * Make it easy to import and export the persistent data 284 * Extra tooling to checkpoint images/containers to revert to a previous 285 state quickly.