sandcastle-ng

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

README.md (7761B)


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