Skip to content

Commit a9b4a61

Browse files
authored
Merge pull request #6 from jimdigriz/getlic
add kc.lic.py and have travis build docker image
2 parents efb33e7 + 9fe3bec commit a9b4a61

File tree

7 files changed

+298
-64
lines changed

7 files changed

+298
-64
lines changed

.travis.yml

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
11
language: c
2+
23
os:
3-
- linux
4-
- osx
4+
- linux
5+
- osx
6+
7+
git:
8+
depth: 1
9+
510
script:
6-
- make p.so
7-
- echo "Preparing version $TRAVIS_BRANCH-$TRAVIS_COMMIT"
8-
- zip -r embedPy_$TRAVIS_OS_NAME-$TRAVIS_BRANCH.zip p.q p.k test.q tests m64/p.so
9-
l64/p.so LICENSE README.md || true
10-
- echo "Packaged as embedPy_$TRAVIS_OS_NAME-$TRAVIS_BRANCH.zip"
11-
compiler:
12-
- clang
13-
- gcc
11+
- export PROJECT=$(echo $TRAVIS_REPO_SLUG | cut -d/ -f2-)
12+
- if [ $TRAVIS_OS_NAME = linux ]; then QLIBDIR=l64; elif [ $TRAVIS_OS_NAME = osx ]; then QLIBDIR=m64; else echo "unknown OS ('$TRAVIS_OS_NAME')" >&2; exit 1; fi; export QLIBDIR
13+
- make $QLIBDIR/p.so
14+
- tar czf ${PROJECT}_${TRAVIS_TAG}_${TRAVIS_OS_NAME}.tgz LICENSE p.q p.k $QLIBDIR/p.so
15+
1416
deploy:
1517
provider: releases
16-
api_key: "$GITHUB_APIKEY"
17-
file_glob: true
18-
file: embedPy_*.zip
18+
api_key: $GITHUB_OAUTH_TOKEN
19+
file: ${PROJECT}_${TRAVIS_TAG}_${TRAVIS_OS_NAME}.tgz
1920
skip_cleanup: true
2021
on:
2122
tags: true
22-
notifications:
23-
slack:
24-
secure: "MR5icOywJJSFy7gnxeNXACN2nKiHniVgX1myiF+H9U4wsW6+2BHzPMcmy3FIUjL3Tb+PcAfq7+8RHerAx/XEB7nsVJsu9TyCjYWgaqx5Z9WNIDcjQh4wnFurhlzqrwF4gjelY+wxdffpsKUVaP+fermWbqHvv1aPPk4l3xEonXZ5J5uNkPTPufILzpx2cTxWg08o6PhvgjTrombs+9rGxahU8cfUSwTVuPCcPtOy70kcaowFfrU2kWzQk88NM5d/TVZdkOmGhLqVWSvRgaLXFkGYwRWatT7divlXX2evYwdYib++RUUhxDGZwJjdFCbGDNjrMyBbJOrCkndxLSATd6gN76dWuWsVV49K4YB0Mw5uFJFt6J0TnbkJC5Zsl9i6vik7m3anuIPOeAI54/wtlCvMeIpt2eQCPMy7xXu2hXNUR4ofM4yaVjKz69b5JIZ1o3vBxPQxAqIYggqPsTaLJM4vLpZlncnViBkfO/La5V9sJNQy3IyLSlEKry3giYfo8wbHT3PLn1xG7HW2DJ7hRn19yzTkCCNfaSzvq8YlSQvjNlPCO566ykYYG6SzG/NnbDqJAqydhpFuNC7ZB5dPuAOoDANCGs4gtfYKia+ZVxKYn25Y52vdi34L5TO83BUrsQWgytb0J6a4jDe3PWLVFSP7XLiy4h8Tyv76+Hm4lHk="
23+
24+
jobs:
25+
include:
26+
- stage: docker
27+
sudo: required
28+
services:
29+
- docker
30+
script:
31+
- eval ${DOCKER_IMAGE:+docker build -t $DOCKER_IMAGE -f docker/Dockerfile .}
32+
deploy:
33+
provider: script
34+
script: eval ${DOCKER_IMAGE:+echo $DOCKER_API_KEY | docker login --username $DOCKER_USERNAME --password-stdin && docker push $DOCKER_IMAGE}
35+
skip_cleanup: true
36+
on:
37+
tags: true

README.md

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,66 @@ To install, place `p.q` and `p.k` in `$QHOME` and `p.so` in `$QHOME/{l64,m64}`.
5050

5151
### Docker
5252

53-
If you have [Docker installed](https://www.docker.com/community-edition) you can alternatively create a directory called `q` and place your `kc.lic` (or `k4.lic`) file into a `q` directory and run:
53+
If you have [Docker installed](https://www.docker.com/community-edition) you can alternatively run:
5454

55-
$ docker run --rm -it -v `pwd`/q:/tmp/q kxsys/embedpy
56-
kx@1ba5d6c29709:~$ q
57-
KDB+ 3.5 2017.11.08 Copyright (C) 1993-2017 Kx Systems
58-
l64/ 4(16)core 7905MB kx 0123456789ab 172.17.0.2 EXPIRE 2018.12.04 [email protected] KOD #0000000
55+
$ docker run -it --name myembedpy kxsys/embedpy
56+
kdb+ on demand - Personal Edition
57+
58+
[snipped]
59+
60+
I agree to the terms of the license agreement for kdb+ on demand Personal Edition (N/y): y
61+
62+
If applicable please provide your company name (press enter for none): ACME Limited
63+
Please provide your name: Bob Smith
64+
Please provide your email (requires validation): [email protected]
65+
KDB+ 3.5 2018.04.25 Copyright (C) 1993-2018 Kx Systems
66+
l64/ 4()core 7905MB kx 0123456789ab 172.17.0.2 EXPIRE 2018.12.04 [email protected] KOD #0000000
67+
68+
q)
69+
70+
For subsequent runs, you will not be prompted to redo the license setup when calling:
5971

72+
$ docker start -ai myembedpy
73+
KDB+ 3.5 2018.04.25 Copyright (C) 1993-2018 Kx Systems
74+
l64/ 4()core 7905MB kx 0123456789ab 172.17.0.2 EXPIRE 2018.12.04 [email protected] KOD #0000000
75+
6076
q)
6177

62-
You can drop straight into `bash` with:
78+
If you prefer to drop straight into `bash` you can with:
6379

64-
$ docker run --rm -it -v `pwd`/q:/tmp/q kxsys/embedpy bash
80+
$ docker run -it kxsys/embedpy bash
81+
[snipped license setup]
6582
kx@8ac226623908:~$ conda info
6683

6784
active environment : kx
6885
active env location : /home/kx/.conda/envs/kx
6986
[snipped]
87+
kx@8ac226623908:~$ q
88+
KDB+ 3.5 2018.04.25 Copyright (C) 1993-2018 Kx Systems
89+
l64/ 4()core 7905MB kx 0123456789ab 172.17.0.2 EXPIRE 2018.12.04 [email protected] KOD #0000000
90+
91+
q)
7092

71-
Lastly you can also pipe your program in:
93+
**N.B.** [build instructions for the image are available](docker/README.md)
7294

73-
$ echo 'p)print(1+2)' | docker run --rm -i -v `pwd`/q:/tmp/q kxsys/embedpy q -q
74-
3
95+
#### Headless/Presets
7596

76-
**N.B.** [build instructions for the image are available](docker/README.md)
97+
If you are running this in a headless configuration, or wish to provide out-of-bound the answers to the license process, then you can call upon the following environment variables. This is handled either by [`--env` (or `--env-file`) as detailed on the docker website](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file).
98+
99+
* **`KDB_LICENSE_AGREE`:** pass in `yes` (case-insensitive) to agree to the license agreement
100+
* **`COMPANY` (optional):** provide company name
101+
* **`NAME`:** provide your name
102+
* **`EMAIL`:** provide your email address
103+
104+
If any of these are missing, then you will be prompted for the value as before.
105+
106+
**N.B.** alternatively you can use `QLIC_KC` (also supported is `QLIC_K4`) which is the base64 encoded contents of your `kc.lic` file
107+
108+
This allows for the following usage:
109+
110+
$ echo \\\\ | docker run -i -e QLIC_KC=$(cat $QHOME/kc.lic | base64 -w0) --name myembedpy embedpy q -q
111+
$ echo 'p)print(1+2)' | docker start -i myembedpy
112+
3
77113

78114
## Usage
79115

docker/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ RUN mkdir -p $QHOME
6565
RUN curl -o $QHOME/l64.zip -L http://dls.kx.com/253h1j3s2941/download/l64.zip \
6666
&& [ "$L64_SHA256" = "$(sha256sum $QHOME/l64.zip | cut -b1-64)" ] \
6767
&& unzip -d $QHOME $QHOME/l64.zip \
68-
&& rm $QHOME/l64.zip
68+
&& rm $QHOME/l64.zip \
69+
&& apt-get -yy --option=Dpkg::options::=--force-unsafe-io purge unzip
6970
COPY docker/q.wrapper /usr/local/bin/q
71+
COPY docker/kc.lic.py /opt/kx/
7072

7173
COPY --from=embedpy /opt/kx/embedPy /opt/kx/embedPy
7274
RUN ln -s -t $QHOME/l64 /opt/kx/embedPy/l64/p.so \

docker/README.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
The instructions below are for building your own docker image. A prebuilt docker image is available on docker cloud, if you only want to run the embedpy image then install docker and run
2-
3-
```bash
4-
docker run -it -v `pwd`/q:/tmp/q kxsys/embedpy
5-
```
1+
The instructions below are for building your own Docker image. A prebuilt Docker image is available on Docker Cloud, if you only want to run the embedPy image then install Docker and [read the main instructions](https://github.com/KxSystems/embedPy#docker) on how to do this.
62

73
# Preflight
84

@@ -18,16 +14,13 @@ To build locally the project you run:
1814

1915
docker build -t embedpy -f docker/Dockerfile .
2016

21-
Other build arguments are supported and you should browse the `Dockerfile` to see what they are, but note for Docker Cloud you will need to make sure they are also explicitly exported in [`docker/hooks/build`](hooks/build) too.
22-
2317
Once built, you should have a local `embedpy` image, you can run the following to use it:
2418

25-
docker run -it -v `pwd`/q:/tmp/q embedpy
26-
19+
docker run -it embedpy
2720

2821
# Deploy
2922

30-
[Google Cloud Builder](https://cloud.google.com/container-builder/docs/) is configured to monitor when tags of the format `/^[0-9.]+/` are added to the [GitHub hosted project](https://github.com/KxSystems/embedPy), a corresponding Docker image is generated and made available on docker [Docker Cloud](https://cloud.docker.com/)
23+
[Google Cloud Builder](https://cloud.google.com/container-builder/docs/) is configured to monitor when tags of the format `/^[0-9.]+/` are added to the [GitHub hosted project](https://github.com/KxSystems/embedPy), a corresponding Docker image is generated and made available on [Docker Cloud](https://cloud.docker.com/)
3124

3225
This is all done server side as the resulting image is north of 350MB.
3326

@@ -37,9 +30,9 @@ To do a deploy, you simply tag and push your releases as usual:
3730
git tag 0.7
3831
git push --tag
3932

33+
## Travis Option
4034

4135
## Related Links
4236

4337
* [Docker](https://docker.com)
4438
* [`Dockerfile`](https://docs.docker.com/engine/reference/builder/)
45-

docker/hooks/build

Lines changed: 0 additions & 9 deletions
This file was deleted.

docker/init

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,6 @@
22

33
set -eu
44

5-
[ -d /tmp/q ] \
6-
|| { echo q non-functional, did you include the q directory? >&2; exit 1; }
7-
8-
[ -f /tmp/q/kc.lic ] && cat /tmp/q/kc.lic > "$QHOME/kc.lic" || true
9-
[ -f /tmp/q/k4.lic ] && cat /tmp/q/k4.lic > "$QHOME/k4.lic" || true
10-
[ -f "$QHOME/kc.lic" -o -f "$QHOME/k4.lic" ] \
11-
|| { echo missing kc.lic/k4.lic >&2; exit 1; }
12-
13-
[ "$(echo '-1 getenv`QHOME;' | q -q)" = "$QHOME" ] \
14-
|| { echo q non-functional >&2; exit 1; }
15-
16-
RC=0
17-
CHECK=$(echo '.z.K>=3.5' | q -q) || RC=$?
18-
[ $RC -eq 0 ] || { echo q non-functional >&2; exit 1; }
19-
[ "$CHECK" = "1b" ] || { echo "kdb+ version must be >= 3.5" >&2; exit 1; }
20-
215
if ! test -x "$1"; then
226
SH=$(which "$1")
237
shift
@@ -33,4 +17,8 @@ fi
3317

3418
HOME=/home/kx
3519
cd $HOME
20+
21+
export QLIC=$HOME
22+
chpst -u kx /bin/sh -l -c 'exec python /opt/kx/kc.lic.py'
23+
3624
exec chpst -u kx "$@"

0 commit comments

Comments
 (0)