sandcastle-ng

Scripts for the deployment of Sandcastle (GNU Taler)
Log | Files | Refs | README

README.md (9462B)


      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 * ``ENABLE_KYC``: Set to `1` to enable KYC; it is disabled by default.
    119 * ``ENABLE_TURNSTILE``: Set to `0` to omit the Drupal Turnstile setup; it is
    120   enabled by default.
    121 
    122 
    123 # Running the Deployment
    124 
    125 Run ``./sandcastle-run`` to run the single container.
    126 The container will be named `taler-sandcastle`.
    127 On the first run, wait until everything has been set up:
    128 
    129     ./sandcastle-logs
    130 
    131 
    132 Note that ``./sandcastle-run`` is just a wrapper around ``podman run``.
    133 If required, you can pass addtional arguments to ``./sandcastle-run``.
    134 These will be passed on to ``podman run``. Example:
    135 
    136     ./sandcastle-run --log-level=debug
    137 
    138 The running container publishes ports to the host as defined in ``./sandcastle-run``.
    139 You can manually verify these port mappings via ``podman port taler-sandcastle``.
    140 
    141 When starting sandcastle like
    142 
    143     SANDCASTLE_OVERRIDE_NAME=taler.localhost ./sandcastle-run
    144 
    145 the services will be available as
    146 
    147  - http://taler.localhost:4321
    148  - http://bank.taler.localhost:4321
    149  - http://shop.taler.localhost:4321
    150  - http://donations.taler.localhost:4321
    151  - http://backend.taler.localhost:4321  - the merchant backend
    152  - http://exchange.taler.localhost:4321
    153  - http://auditor.taler.localhost:4321
    154  - http://challenger.taler.localhost:4321
    155  - http://paivana.taler.localhost:4321/en/  - www.taler.net behind a Taler paywall
    156    (use the ``/en/`` entry point, as www.taler.net redirects ``/`` to its own domain)
    157 
    158 This gives a nice environment for integration testing.
    159 
    160 
    161 # Stopping the deployment
    162 
    163 For stopping the deployment simply run
    164 
    165 ```
    166 ./sandcastle-stop
    167 ```
    168 
    169 which is just a shortcut for ``podman stop taler-sandcastle``.
    170 
    171 
    172 # Watching Logs
    173 
    174 Run ``./sandcastle-logs`` to watch the logs within the container.
    175 You can pass addtional arguments to ``./sandcastle-logs``,
    176 which will be passed on to ``journalctl`` in the container.  Example:
    177 
    178     ./sandcastle-logs --output=cat
    179 
    180 
    181 # Poking Around
    182 
    183 You can poke around in a running sandcastle instance by running
    184 
    185 ```
    186 podman exec -it taler-sandcastle /bin/bash
    187 ```
    188 
    189 Or, as a shortcut:
    190 
    191 ```
    192 ./sandcastle-enter
    193 ```
    194 
    195 This will drop you into a shell inside the running container,
    196 where you have access to systemd, journalctl, etc.
    197 
    198 
    199 # Data Storage
    200 
    201 All persistent data is stored in a podman volume called
    202 _talerdata_.  You can see where it is in your filesystem
    203 by running ``podman volume inspect talerdata``.
    204 
    205 That volume also contains the postgres database files.
    206 
    207 ## Cleaning the Data Storage
    208 
    209 For cleaning the data storage run
    210 
    211     ./sandcastle-plow
    212 
    213 and for cleaning also the persistent storage run
    214 
    215     ./sandcastle-plow all
    216 
    217 
    218 # Provisioning Details
    219 
    220 The whole deployment is configured by a script
    221 mounted into the container as ``/provision/setup-sandcastle.sh``.
    222 This script will be run as a oneshot systemd service and will disable itself after
    223 the first success.
    224 
    225 To troubleshoot, run ``journalctl -u setup-sandcastle.service``.
    226 
    227 There are different setup scripts in the ``scripts/$SANDCASTLE_SETUP_NAME``
    228 folders. Specifically:
    229 
    230 * ``none`` does no setup at all
    231 * ``demo`` set up the usual Taler demo
    232 * TBD: ``regio`` is a currency conversion setup
    233 
    234 By default, ``demo`` is used.
    235 To mount a different provision script,
    236 set ``$SANDCASTLE_SETUP_NAME`` when running ``./sandcastle-run``,
    237 like this
    238 
    239     SANDCASTLE_SETUP_NAME=none ./sandcastle-run
    240 
    241 
    242 You can always manually run any of the provisioning script inside the container as
    243 ``/scripts/$SANDCASTLE_SETUP_NAME/setup-sandcastle.sh``.
    244 
    245 # Importing / exporting
    246 
    247 To migrate a sandcastle deployment, export / import can be used.
    248 
    249 ```
    250 # Requires taler-sandcastle to be running.
    251 # Export the sandcastle data to ./exported/
    252 ./sandcastle-export
    253 
    254 # Other host:
    255 # Request an import
    256 touch exported/import-request
    257 # Now the deployment script will pick up the data to import
    258 ./sandcastle-run
    259 ```
    260 
    261 # Neat Things That Already Work
    262 
    263 * Rebulding the base image is incremental, since we use layers.  If the tag
    264   of the exchange is changed, only the exchange and components that depend
    265   on it are rebuilt.
    266 * Inside the container, the service names resolve to localhost,
    267   and on localhost a reverse proxy with locally signed certificates
    268   ensures that services can talk to each other *within* the container
    269   by using their *public* base URL.
    270 
    271 
    272 # Future Extensions
    273 
    274 * Better way to access logs, better way to expose errors during provisioning
    275 * The Dockerfile should introduce nightly tags for debian packages it builds.
    276   Currently it just uses the latest defined version, which is confusing.
    277 * Deploy the Taler woocommerce plugin, wordpress plugin, Joomla plugin
    278 * Do self-tests of the deployment using the wallet CLI
    279 * Running the auditor
    280 * Running a currency conversion setup with multiple libeufin-bank instances
    281 * Instead of exposing HTTP ports, we could expose everything via unix domain sockets,
    282   avoiding port collision problems.
    283 * Instead of requiring the reverse proxy to handle TLS,
    284   the sandcastle container itself could do TLS termination with caddy.
    285 * To improve performance, allow connecting to an external database
    286 * Make it easy to import and export the persistent data
    287 * Extra tooling to checkpoint images/containers to revert to a previous
    288   state quickly.