|
6 | 6 | ## Table of Contents
|
7 | 7 | 1. [About](#about)
|
8 | 8 | 2. [Prerequisites](#prerequisites)
|
9 |
| -3. [Quickstart](#quickstart) |
| 9 | +3. [How to build an existing flavor?](#how-to-build-an-existing-flavor) |
| 10 | +4. [How to customize an existing flavor?](#how-to-customize-an-existing-flavor) |
| 11 | +5. [Partial builds or rebuilds](#partial-builds-and-rebuilds) |
| 12 | +6. [Using your own remote cache](#using-your-own-remote-cache) |
| 13 | +7. [Testing an existing flavor](#testing-an-existing-flavor) |
| 14 | +8. [Cleaning up after your are finished](#cleaning-up-after-your-are-finished) |
10 | 15 |
|
11 | 16 | ## About
|
12 |
| -This project contains implementations for user defined functions (UDF's) that can be used in the EXASOL database (version 6.0.0 or later) |
| 17 | +This project contains script language containers for user defined functions (UDF's) |
| 18 | +that can be used in the EXASOL database (version 6.0.0 or later). |
| 19 | +A script language container consists of a Linux container with a complete linux distribution and all required libraries, |
| 20 | +such as a script client. A script client is responsible for the communication with the database and for executing the script code. |
| 21 | +We provide in this repository several [flavors](flavors) of script language containers, |
| 22 | +such as the current standard implementation of the [script client](src) with support for Python 2/3, R und Java. |
| 23 | +We will show here how to customize and build the different flavors of the script language containers. |
| 24 | +Pre-built containers can you find in the [release section](https://github.com/exasol/script-languages/releases) of this repository. |
| 25 | +If you are interested in the script client you find more details [here](src/README.md). |
13 | 26 |
|
14 | 27 | ## Prerequisites
|
15 | 28 | In order to build this project, you need:
|
16 | 29 | * Linux or Mac OS X (experimental)
|
17 | 30 | * Docker
|
| 31 | +* Python >=3.6 with pip |
| 32 | +* We recommend at least 50 GB free disk space on the partition |
| 33 | + where Docker stores its images, on linux Docker typically stores |
| 34 | + the images at /var/lib/docker. |
| 35 | +* For the partition where the output directory (default: ./.build_output) |
| 36 | + is located we recommend additionally at least 10 GB free disk space. |
18 | 37 |
|
19 |
| -In order to follow the quickstart guide, you additionally need |
20 |
| -* Write-access to a bucket in a bucketfs in an EXASOL installation |
21 |
| -* curl |
22 |
| -* An SQL client connecting to the same EXASOL installation |
| 38 | +Further, prerequisites might be necessary for specific tasks. These are listed under the corresponding section. |
23 | 39 |
|
24 |
| -For running the tests you also need |
25 |
| -* Python |
26 |
| -* GCC |
27 |
| -* Java |
28 |
| -* unixODBC |
29 |
| -* Docker with privileged mode |
| 40 | +## How to build an existing flavor? |
30 | 41 |
|
31 |
| -## Quickstart |
32 |
| -1. Choose a flavor. Currently we have several pre-defined flavors available, e.g., `mini-EXASOL-6.0.0`, and `standard-EXASOL-6.1.0`. |
| 42 | +Choose a flavor. Currently we have several pre-defined flavors available, e.g., `mini-EXASOL-6.0.0`, and `standard-EXASOL-6.1.0`. |
33 | 43 | This project supports different versions of script language environments with different libraries and languages.
|
34 | 44 | We call these versions _flavors_. The pre-defined flavors can be modified and extended to create customized flavors.
|
35 |
| -Each pre-defined flavor has its own set of Docker build-files in a corresponding subfolder of [flavors](flavors). |
36 |
| -2. Create the language container. We choose to use the `mini` flavor which is the smallest of the currently available flavors and which only support the Python language. |
| 45 | +Each pre-defined flavor has its own set of Dockerfiles in a corresponding subfolder of [flavors](flavors). |
| 46 | + |
| 47 | +Create the language container and export it to the local file system |
| 48 | + |
37 | 49 | ```bash
|
38 |
| -$ ./build --flavor=mini-EXASOL-6.0.0 |
| 50 | +$ ./exaslct export --flavor-path=flavors/<flavor-name> --export-path <export-path> |
39 | 51 | ```
|
40 |
| -(on Mac OS X, use `./build -f mini-EXASOL-6.0.0`) |
41 | 52 |
|
42 |
| -3. Export it into a standalone archive |
| 53 | +or upload it directly into your BuckerFS (currently http only, https follows soon) |
| 54 | + |
43 | 55 | ```bash
|
44 |
| -$ ./export --flavor=mini-EXASOL-6.0.0 |
| 56 | +$ ./exaslct upload --flavor-path=flavors/<flavor-name> --database-host <hostname-or-ip> --bucketfs-port <port> \ |
| 57 | + --bucketfs-username w --bucketfs-password <password> --bucketfs-name <bucketfs-name> \ |
| 58 | + --bucket-name <bucket-name> --path-in-bucket <path/in/bucket> |
45 | 59 | ```
|
46 |
| -(on Mac OS X, use `./export -f mini-EXASOL-6.0.0`) |
47 |
| -This creates the file `mini-EXASOL-6.0.0.tar.gz`. |
48 | 60 |
|
49 |
| -Optionally, you can run some automated tests for your flavor by using |
50 |
| -```bash |
51 |
| -$ ./test_complete --flavor=mini-EXASOL-6.0.0 |
| 61 | +Once it is successfully uploaded, it will print the ALTER SESSION statement |
| 62 | +that can be used to activate the script language container in the database. |
| 63 | + |
| 64 | +## How to customize an existing flavor? |
| 65 | + |
| 66 | +To customize an existing flavor you can add your specific needs to the Dockerfile in the flavor-customization directory. |
| 67 | +You can run commands with: |
| 68 | + |
| 69 | +```Dockerfile |
| 70 | +RUN <command> |
52 | 71 | ```
|
53 |
| -(on Mac OS X you need to have pip installed for this to work) |
54 |
| -If the test fails with the message |
| 72 | + |
| 73 | +For example, to install new software you can use: |
| 74 | + |
| 75 | +```Dockerfile |
| 76 | +RUN apt-get -y update && \ |
| 77 | + apt-get install \<packages> && \ |
| 78 | + apt-get -y clean && \ |
| 79 | + apt-get -y autoremove |
| 80 | +``` |
| 81 | + |
| 82 | +You need to run apt-get update, because any previous step clears the cache of apt to keep the docker images small. |
| 83 | +The commands |
| 84 | + |
| 85 | +```Dockerfile |
| 86 | +apt-get -y clean and apt-get -y autoremove |
55 | 87 | ```
|
56 |
| -cp: cannot create regular file ‘/tmp/udftestdb/exa/etc/EXAConf’: Permission denied |
| 88 | + |
| 89 | +clear the cache. |
| 90 | + |
| 91 | +You can add to the flavor-customization directory additional files which you can use in the Dockerfile via: |
| 92 | + |
| 93 | +```Dockerfile |
| 94 | +COPY flavor-customization/<your-file-or-directory> <destination> |
57 | 95 | ```
|
58 |
| -then run `stop_dockerdb` and restart the test. |
59 | 96 |
|
60 |
| -4. Upload the file into bucketfs. For the following example we assume the password `pwd` and the bucketname `funwithudfs` in a bucketfs that is running on port `2580` on machine `192.168.122.158` |
| 97 | +or |
| 98 | + |
| 99 | +```Dockerfile |
| 100 | +ADD flavor-customization/<your-file-or-directory> <destination> |
| 101 | +``` |
| 102 | + |
| 103 | +Your changes on the file system will then be merged with the file system of the script client |
| 104 | +which contains all necessary libraries that are required to run the script language runtime. |
| 105 | + |
| 106 | +Be aware that the merge will override all changes which may prevent the execution of the script client. |
| 107 | +In details, this means if you change or remove packages or files in flavor-customization |
| 108 | +which are necessary for the script client they will be restored in the final container. |
| 109 | + |
| 110 | +After you finished your changes, rebuild with |
| 111 | + |
61 | 112 | ```bash
|
62 |
| -curl -v -X PUT -T mini-EXASOL-6.0.0.tar.gz w:pwd@192.168.122.158:2580/funwithudfs/mini-EXASOL-6.0.0.tar.gz |
| 113 | +$ ./exaslct export --flavor-path=flavors/<flavor-name> |
63 | 114 | ```
|
64 |
| -5. In SQL you activate the Python implementation of the flavor `mini-EXASOL-6.0.0` by using a statement like this |
65 |
| -```sql |
66 |
| -ALTER SESSION SET SCRIPT_LANGUAGES='MYPYTHON=localzmq+protobuf:///bucketfsname/funwithudfs/mini-EXASOL-6.0.0?lang=python#buckets/bucketfsname/funwithudfs/mini-EXASOL-6.0.0/exaudf/exaudfclient'; |
| 115 | + |
| 116 | +or upload it directly into your BuckerFS (currently http only, https follows soon) |
| 117 | + |
| 118 | +```bash |
| 119 | +$ ./exaslct upload --flavor-path=flavors/<flavor-name> --database-host <hostname-or-ip> --bucketfs-port <port> \ |
| 120 | + --bucketfs-username w --bucketfs-password <password> --bucketfs-name <bucketfs-name> \ |
| 121 | + --bucket-name <bucket-name> --path-in-bucket <path/in/bucket> |
67 | 122 | ```
|
68 |
| -Now the script language `MYPYTHON` can be used to define a script, e.g., |
| 123 | + |
| 124 | +Note: The tool `exaslct` tries to reuse as much as possible of the previous build or tries to pull already exising images from Docker Hub. |
| 125 | + |
| 126 | +## Force a rebuild |
| 127 | + |
| 128 | +Sometimes it is necessary to force a rebuild of a flavor. |
| 129 | +A typical reason is to update the dependencies in order to |
| 130 | +fix bugs and security vulnerabilities in the installed dependencies. |
| 131 | +To force a rebuild the command line option --force-rebuild can be used |
| 132 | +with basically all commands of ./exaslct, except the clean commands. |
| 133 | + |
| 134 | +## Partial builds and rebuilds |
| 135 | + |
| 136 | +In some circumstances you want to build or rebuild |
| 137 | +only some parts of the flavor. Most likely during development or during CI. |
| 138 | +You can specify for a build upper bounds (also called goals) |
| 139 | +until which the flavor should be build and for rebuilds |
| 140 | +you can define lower bounds from where the rebuild get forced. |
| 141 | + |
| 142 | +You can define upper bounds with the commandline option --goal |
| 143 | +for the ./exaslct commands build and push. |
| 144 | +The build command only rebuilds the docker images, |
| 145 | +but does not export a new container. |
| 146 | +All other commands don't support the --goal option, |
| 147 | +because they require specific images to be built, |
| 148 | +otherwise they would not proceed. |
| 149 | + |
| 150 | +```bash |
| 151 | +./exaslct build --flavor-path=<path-to-flavor> --goal <build-stage> |
69 | 152 | ```
|
70 |
| -CREATE SCHEMA S; |
71 |
| -CREATE mypython SCALAR SCRIPT small_test() RETURNS DOUBLE AS |
72 |
| -def run(ctx): |
73 |
| - return 1.2 |
74 |
| -/ |
| 153 | + |
| 154 | +If you want to build several different build-stages at once, you can repeat the --goal option. |
| 155 | + |
| 156 | +The following build-stage are currently available: |
| 157 | +* udfclient-deps |
| 158 | +* language-deps |
| 159 | +* build-deps |
| 160 | +* build-run |
| 161 | +* base-test-deps |
| 162 | +* base-test-build-run |
| 163 | +* flavor-test-build-run |
| 164 | +* flavor-base-deps |
| 165 | +* flavor-customization |
| 166 | +* release |
| 167 | + |
| 168 | + |
| 169 | +With the option --force-rebuild-from, you can specify from where the rebuild should be forced. |
| 170 | +All previous build-stages before this will use cached versions where possible. |
| 171 | +However, if a single stage is built, it will trigger a build for all following build-stages. |
| 172 | +The option --force-rebuild-from only has an effect together with the option --force-rebuild, |
| 173 | +without it is ignored. |
| 174 | + |
| 175 | +```bash |
| 176 | +./exaslct build --flavor-path=<path-to-flavor> --force-rebuild --force-rebuild-from <build-stage> |
75 | 177 | ```
|
76 |
| -The script can be executed as follows: |
| 178 | + |
| 179 | +Similar, as for the --goal option, you can specify multiple lower bounds |
| 180 | +by repeating the --force-rebuild-from with different build-stages. |
| 181 | + |
| 182 | +## Using your own remote cache |
| 183 | + |
| 184 | +Exaslct caches images locally and remotely. |
| 185 | +For remote caching exaslct can use a docker registry. |
| 186 | +The default registry is configured to Docker Hub. |
| 187 | +With the command line options --repository-name |
| 188 | +you can configure your own docker registry as cache. |
| 189 | +The --repository-name option can be used with all |
| 190 | +./exaslct commands that could trigger a build, |
| 191 | +which include build, export, upload and run-db-test commands. |
| 192 | +Furthermore, it can be used with the push command which |
| 193 | +uploads the build images to the docker registry. |
| 194 | +In this case the --repository-name option specifies |
| 195 | +not only from where to pull cached images during the build, |
| 196 | +but also to which cache the built images should be pushed. |
| 197 | + |
| 198 | +You can specify the repository name, as below: |
| 199 | + |
| 200 | +```bash |
| 201 | +./exaslct export --flavor-path=<path-to-flavor> --repository-name <hostname>[:port]/<user>/<repository-name> |
77 | 202 | ```
|
78 |
| -select small_test(); |
| 203 | + |
| 204 | +## Testing an existing flavor |
| 205 | + |
| 206 | +To test the script language container you can execute the following command: |
| 207 | + |
| 208 | +```bash |
| 209 | +$ ./exaslct run-db-test --flavor-path=flavors/<flavor-name> |
79 | 210 | ```
|
80 |
| -6. Afterwards you may choose to remove the Docker images for this flavor. This can be done as follows: |
| 211 | + |
| 212 | +**Note: you need docker in privileged mode to execute the tests** |
| 213 | + |
| 214 | +## Cleaning up after your are finished |
| 215 | + |
| 216 | +The creation of scripting language container creates or downloads several docker images |
| 217 | +which can consume a lot of disk space. Therefore, we recommand to remove the Docker images |
| 218 | +of a flavor after working with them. |
| 219 | + |
| 220 | +This can be done as follows: |
| 221 | + |
81 | 222 | ```bash
|
82 |
| -./clean --flavor=mini-EXASOL-6.0.0 |
| 223 | +./exaslct clean-flavor-images --flavor-path=flavors/<flavor-name> |
83 | 224 | ```
|
84 |
| -Please note that this script does not delete the Linux image that is used as basis for the images that were build in the previous steps. |
85 | 225 |
|
| 226 | +To remove all images of all flavors you can use: |
86 | 227 |
|
| 228 | +```bash |
| 229 | +./exaslct clean-all-images |
| 230 | +``` |
87 | 231 |
|
| 232 | +**Please note that this script does not delete the Linux image that is used as basis for the images that were build in the previous steps. |
| 233 | +Furthermore, this command doesn't delete cached files in the output directory. The default path for the output directory is .build-output.** |
0 commit comments