sandcastle-ng

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

README.md (8075B)


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