├── .github └── workflows │ └── CD.yaml ├── .gitignore ├── .travis.yml ├── Dockerfile ├── Makefile ├── README.md ├── agdock └── entrypoint.sh /.github/workflows/CD.yaml: -------------------------------------------------------------------------------- 1 | name: Build and Push 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build_and_push: 10 | runs-on: ubuntu-latest 11 | strategy: 12 | matrix: 13 | ag_version: ["7.3.1", "7.3.0", "7.2.0", "7.1.0", "7.0.4"] 14 | steps: 15 | - name: Set up QEMU 16 | uses: docker/setup-qemu-action@v2 17 | - name: Set up Docker Buildx 18 | uses: docker/setup-buildx-action@v2 19 | - name: Login to DockerHub 20 | uses: docker/login-action@v2 21 | with: 22 | username: ${{ secrets.DOCKERHUB_USERNAME }} 23 | password: ${{ secrets.DOCKERHUB_TOKEN }} 24 | - name: Checkout 25 | uses: actions/checkout@v2 26 | - name: Build 27 | run: ./agdock build --version=${{ matrix.ag_version }} --tag=franzinc/agraph:v${{ matrix.ag_version }} 28 | - name: Push 29 | run: ./agdock push --image=franzinc/agraph:v${{ matrix.ag_version }} 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: generic 2 | 3 | services: 4 | - docker 5 | 6 | env: 7 | global: 8 | - AGRAPH_SESSION_PORTS=30000-30034 9 | - AGRAPH_HTTP_PORT=30035 10 | jobs: 11 | - AGRAPH_SUPER_USER=admin 12 | AGRAPH_SUPER_PASSWORD=secret 13 | AG_USER=admin 14 | AG_PASSWORD=secret 15 | - AGRAPH_SUPER_USER_FILE=/agraph/etc/user.txt 16 | AGRAPH_SUPER_PASSWORD_FILE=/agraph/etc/password.txt 17 | AG_USER=user-from-file 18 | AG_PASSWORD=password-from-file 19 | 20 | install: 21 | - git clone http://github.com/franzinc/docker-agraph 22 | - cd docker-agraph 23 | - ./agdock build --version=7.0.0-nightly 24 | - mkdir agraph-etc 25 | - echo 'user-from-file' > agraph-etc/user.txt 26 | - echo 'password-from-file' > agraph-etc/password.txt 27 | 28 | script: 29 | - > 30 | docker run -d --rm --shm-size 1g \ 31 | -e AGRAPH_SUPER_USER \ 32 | -e AGRAPH_SUPER_USER_FILE \ 33 | -e AGRAPH_SUPER_PASSWORD \ 34 | -e AGRAPH_SUPER_PASSWORD_FILE \ 35 | -p 30000-30035:10000-10035 \ 36 | -v $(pwd)/agraph-etc:/agraph/etc \ 37 | --name agraph \ 38 | franzinc/agraph:v7.0.0-nightly 39 | - while [ ! $(curl http://localhost:30035/version) ]; do sleep 5; done 40 | - ./agdock agtool --name=agraph -- create-db $AG_USER:$AG_PASSWORD@127.0.0.2:10035/r0 41 | - ./agdock agtool --name=agraph -- triple-count $AG_USER:$AG_PASSWORD@127.0.0.2:10035/r0 | grep '^0$' 42 | - ./agdock agtool --name=agraph -- gruff install 8.0.1 # bug26201 43 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Stage 0 - pull the AG distribution tarball, unpack it and install it 2 | # into the /agraph directory. 3 | # NOTE: this is the official Ubuntu image 4 | FROM ubuntu:24.04 AS installation-stage 5 | 6 | ARG AG_ARCHIVE 7 | ARG AG_VERSION 8 | 9 | # Install the dependencies needed for AG installation. 10 | RUN apt-get update && apt-get install -y openssl 11 | 12 | # Pull AG distribution tarball into the image. 13 | ADD $AG_ARCHIVE ./ 14 | 15 | # Unpack AG distribution archive, install AG into /agraph directory 16 | # and delete the archive and unpacked files. 17 | RUN if [ -f "${AG_ARCHIVE##*/}" ]; \ 18 | then tar zxf "${AG_ARCHIVE##*/}" && rm -f "${AG_ARCHIVE##*/}"; fi \ 19 | && ./agraph-${AG_VERSION}/install-agraph /agraph --no-configure 20 | 21 | 22 | 23 | # Stage 1 - prepare a clean Ubuntu, install dependencies, setup a user 24 | # and copy the AG installed during stage 0. 25 | FROM ubuntu:24.04 26 | MAINTAINER Franz Support 27 | 28 | # Install the same dependencies as for the stage0 (installation) and 29 | # remove apt registries. 30 | # NOTE: update AND upgrade are required. 31 | RUN apt-get -y update && \ 32 | apt-get -y upgrade && \ 33 | apt-get -y install openssl sudo && \ 34 | apt-get clean && \ 35 | rm -rf /var/lib/apt/lists/* 36 | 37 | # Create agraph user, enable passwordless sudo and silence the "To run 38 | # a command as administrator ..." notification (for more details, see 39 | # https://askubuntu.com/questions/22607). 40 | RUN useradd -m -G sudo -s /bin/bash -d /agraph agraph \ 41 | && echo "agraph ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \ 42 | && touch /agraph/.sudo_as_admin_successful 43 | 44 | COPY --chown=agraph --from=installation-stage /agraph /agraph 45 | 46 | ENV PATH=/agraph/bin:$PATH 47 | 48 | USER agraph 49 | WORKDIR /agraph 50 | 51 | VOLUME /agraph/data 52 | VOLUME /agraph/etc 53 | 54 | EXPOSE 10000-10034 10035 55 | 56 | COPY entrypoint.sh / 57 | ENTRYPOINT ["/entrypoint.sh"] 58 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile 2 | # 3 | # This is supplied for convenience and backward compatibility. 4 | 5 | ifndef VERSION 6 | $(error VERSION must be supplied. Don't include the 'v') 7 | endif 8 | 9 | default: build 10 | 11 | build: 12 | ./agdock build --version=$(VERSION) 13 | 14 | run: 15 | ./agdock run --version=$(VERSION) 16 | 17 | push: FORCE 18 | ./agdock push --image=franzinc/agraph:v$(VERSION) 19 | 20 | FORCE: 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AllegroGraph in Docker 2 | 3 | This repository contains a set of instruments and configuration files 4 | needed to build, configure and run AllegroGraph in Docker. The new 5 | images use Ubuntu as a base image and are not compatible with the old 6 | DockerHub images (AG v6.6.0 and below), which use CentOS. 7 | 8 | 9 | 10 | ## Building AllegroGraph Docker images 11 | 12 | AllegroGraph Docker images can be conveniently built using the 13 | `agdock` tool by specifying the version of AllegroGraph release to use 14 | in the image. The version can be either a release version in the form 15 | `..` (e.g. `6.6.0` or `7.0.0`), a release 16 | candidate `.rc` (e.g. `7.0.0.rc1`), a test release 17 | `.t` (e.g. `7.0.0.t5`) or a latest nightly build 18 | `-nightly` (e.g. `7.0.0-nightly`): 19 | 20 | $ ./agdock build --version=6.6.0 21 | $ ./agdock build --version=7.0.0-nightly 22 | 23 | Alternatively, the AllegroGraph distribution tarball (either a local 24 | file or a URL) can be supplied via `--dist` argument: 25 | 26 | $ ./agdock build --dist=agraph-7.0.0-linuxamd64.64.tar.gz 27 | 28 | The same can be done via `make` by setting `VERSION` environment variable: 29 | 30 | $ VERSION=7.0.0 make 31 | 32 | Finally, images prebuilt by Franz, Inc. can be pulled from DockerHub: 33 | 34 | $ docker pull franzinc/agraph:v6.6.0 35 | 36 | For other `agdock build` parameters and details, see the help message 37 | that can be printed with `agdock --help`. 38 | 39 | 40 | 41 | ## Configuring and running AllegroGraph containers 42 | 43 | In order to run an AllegroGraph container with data and configuration 44 | persistence, the externally supplied data and configuration volumes 45 | (either as host directories or Docker volumes) must be mounted at 46 | `/agraph/data` and `/agraph/etc` respectively. The AllegroGraph 47 | configuration file `/agraph/etc/agraph.cfg` is generated on container 48 | start but only if it does not already exist. Superuser credentials can 49 | be supplied in plaintext via `AGRAPH_SUPER_USER` and 50 | `AGRAPH_SUPER_PASSWORD` variables or in files pointed to by 51 | `AGRAPH_SUPER_USER_FILE` and `AGRAPH_SUPER_PASSWORD_FILE` 52 | variables. If none of these variables are supplied, the default user 53 | (`admin`) and a randomly generated password will be created and 54 | printed at the beginning of the AllegroGraph log printed to the 55 | standard output. 56 | 57 | Example of configuring AllegroGraph container using Docker volumes: 58 | 59 | # Volume for AllegroGraph data and log files. 60 | $ docker volume create agdata 61 | 62 | # Volume for AllegroGraph config files. 63 | $ docker volume create agconfig 64 | 65 | # Start the container with a shared memory size of 1 Gb, which is 66 | # a required minimum. 67 | $ docker run -it --rm \ 68 | --shm-size 1g \ 69 | -v agdata:/agraph/data \ 70 | -v agconfig:/agraph/etc \ 71 | -e AGRAPH_SUPER_USER=admin \ 72 | -e AGRAPH_SUPER_PASSWORD=pass \ 73 | -p 10000-10035:10000-10035 \ 74 | --name agraph-instance-1 \ 75 | franzinc/agraph:v7.0.0 76 | 77 | The following example does the same but supplies superuser credentials 78 | as files - credentials are written to the files in the `secrets` 79 | directory, which is then mapped into the `/secrets` directory in the 80 | container: 81 | 82 | # Create a directory with username/password files. 83 | $ mkdir secrets 84 | $ echo admin > secrets/super_user.txt 85 | $ echo pass > secrets/super_password.txt 86 | 87 | # Start the container with superuser credentials supplied via files. 88 | $ docker run -it --rm \ 89 | --shm-size 1g \ 90 | -v agdata:/agraph/data \ 91 | -v agconfig:/agraph/etc \ 92 | -v $(pwd)/secrets:/secrets \ 93 | -e AGRAPH_SUPER_USER_FILE=/secrets/super_user.txt \ 94 | -e AGRAPH_SUPER_PASSWORD_FILE=/secrets/super_password.txt \ 95 | -p 10000-10035:10000-10035 \ 96 | --name agraph-instance-1 \ 97 | franzinc/agraph:v7.0.0 98 | 99 | 100 | Similarly, `AGRAPH_LICENSE` and `AGRAPH_LICENSE_FILE` variables can be 101 | used to supply a license section of `agraph.cfg`: 102 | 103 | # Create variables with username, password with LicenseCode config 104 | # directives. 105 | $ AGRAPH_SUPER_USER=admin 106 | $ AGRAPH_SUPER_PASSWORD=password 107 | $ AGRAPH_LICENSE=" 108 | 109 | # License code... 110 | 111 | " 112 | 113 | # Start AllegroGraph container with injected license. 114 | $ docker run -it --rm --shm-size 1g \ 115 | -e AGRAPH_SUPER_USER \ 116 | -e AGRAPH_SUPER_PASSWORD \ 117 | -e AGRAPH_LICENSE \ 118 | -p 10000-10035:10000-10035 \ 119 | --name agraph-instance-1 \ 120 | franzinc/agraph:v7.0.0 121 | 122 | 123 | AllegroGraph server is run as `agraph:agraph` user, which is also the 124 | default user for the container (it is used to run commands provided to 125 | `docker run` and `docker exec`). 126 | 127 | Note, that **`entrypoint.sh` recursively changes the owner of 128 | `/agraph/data` and `/agraph/etc` trees (which are the mount points for 129 | data and configuration volumes, respectively) to `agraph:agraph` user 130 | on container start**. This may be undesired when using host 131 | directories as data/configuration volumes. 132 | 133 | For convenience purposes, `agdock` tool provides a `run` command for 134 | running AllegroGraph containers, but it makes a lot of assumptions 135 | about the `docker run` arguments and as a result lacks flexibility. In 136 | the simplest case, the image name and tag can be computed from version 137 | specified in the same form as for `agdock build`: 138 | 139 | $ ./agdock run --version=7.0.0-nightly 140 | 141 | Alternatively, the image can be specified explicitly: 142 | 143 | $ ./agdock run --image=franzinc/agraph:v7.0.0 144 | 145 | Another useful `agdock` command is `agtool`, which can be used to run 146 | `agtool` CLI in a running AllegroGraph container. The same container 147 | name must be used: 148 | 149 | $ ./agdock run --version=7.0.0 --name=agraph-instance-1 150 | $ ./agdock agtool --name=agraph-instance-1 -- create-db user:pass@10035/test 151 | 152 | 153 | 154 | ## License 155 | 156 | Copyright (c) 2020, Franz, Inc. 157 | All rights reserved. 158 | 159 | Redistribution and use of this source code, with or without 160 | modification, are permitted provided that the following condition is 161 | met: source code must retain the above copyright notice, this 162 | condition and the following disclaimer. 163 | 164 | Redistributions of AllegroGraph in binary requires a license from 165 | Franz, Inc. 166 | 167 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 168 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 169 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 170 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 171 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 172 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 173 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 174 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 175 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 176 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 177 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 178 | -------------------------------------------------------------------------------- /agdock: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | set -ueE -o pipefail 4 | 5 | COMMAND_NAME=$0 6 | SUBCOMMAND_NAME=$1 7 | 8 | USAGE="Usage: 9 | $COMMAND_NAME COMMAND [ARGS] 10 | 11 | Commands (options must be of option=value form, if not stated otherwise): 12 | help - display this message 13 | 14 | build - build a docker image with a given AG version installed 15 | -v/--version - AG version to use; version should not start with 'v' but can end 16 | with '.tN', '.rcN' and '-nightly' for test releases, release 17 | candidates and nightly builds respectively (required if --dist is not 18 | supplied) 19 | -d/--dist - AG distribution archive to use; can be a path to local file or 20 | a tarball URL (required if --version is not supplied) 21 | -t/--tag - tag to use for the new image (defaults to franzinc/agraph:v) 22 | --no-cache - rebuild image without docker cache 23 | --pull - pull base docker image explicitly 24 | 25 | run - run a Docker image for a given AG version 26 | -v/--version - AG version to run; if specified, the franzinc/agraph image will be 27 | used (required if --image is not supplied) 28 | -i/--image - tag of the image to run (required if --version is not supplied) 29 | -n/--name - name of the container (optional, defaults to agraph) 30 | 31 | push - push a Docker image to the image repository 32 | -i/--image - tag of the image to push to DockerHub (required) 33 | --latest - additionally push the same image tagged 'latest' 34 | 35 | agtool - run agtool tool in a running AG container 36 | -n/--name - name of the running container in which to run the agtool 37 | 38 | 39 | Examples: 40 | 41 | # build Docker image for the latest 7.0.0 nightly AG build: 42 | $COMMAND_NAME build --version=7.0.0-nightly 43 | 44 | # build Docker image from a local AG tarball: 45 | $COMMAND_NAME build --dist=agraph-7.0.0-linuxamd64.64.tar.gz 46 | 47 | # run Docker container with 7.0.0 nightly (must be prebuilt): 48 | $COMMAND_NAME run --image=franzinc/agraph:v7.0.0-nightly 49 | 50 | # run Docker container named agraph1 specifying only the AG version: 51 | $COMMAND_NAME run --version=7.0.0.t1 --name=agraph1 52 | 53 | # create a new repository test by running agtool in an AG container 54 | # named agraph1 55 | $COMMAND_NAME agtool --name=agraph1 -- create-db user:pass@10035/test 56 | " 57 | 58 | 59 | DOC="$COMMAND_NAME - Franz Inc's AllegroGraph Dockerization tool 60 | 61 | Configure, build, publish and run multiple versions of Dockerized AllegroGraph. 62 | 63 | $USAGE 64 | " 65 | 66 | FULL_VERSION_REGEX='[0-9]+\.[0-9]+\.[0-9]+((\.rc[0-9]+)|(\.t[0-9]+)|(-nightly))?' 67 | 68 | # Print help/usage message. 69 | function agdock_help () { 70 | shift 71 | for i in "$@" 72 | do 73 | case $i in 74 | *) 75 | echo -e "$COMMAND_NAME help: unknown option $i\n\n$USAGE" 76 | exit 1 77 | ;; 78 | esac 79 | done 80 | echo -e "$DOC" | ${PAGER:-less} 81 | } 82 | 83 | 84 | # Build and tag the image. Tag image as latest, if this is a release 85 | # version (i.e. not .rcN, .tN or -nightly). 86 | function agdock_build () { 87 | shift 88 | for i in "$@" 89 | do 90 | case $i in 91 | -v=*|--version=*) 92 | full_version="${i#*=}" 93 | ;; 94 | -d=*|--dist=*) 95 | dist="${i#*=}" 96 | ;; 97 | -t=*|--tag=*) 98 | tag="${i#*=}" 99 | ;; 100 | --no-cache) 101 | no_docker_cache="--no-cache" 102 | ;; 103 | --pull) 104 | docker_build_pull="--pull" 105 | ;; 106 | *) 107 | echo -e "$COMMAND_NAME build: unknown option $i\n\n$USAGE" 108 | exit 1 109 | ;; 110 | esac 111 | done 112 | # Detect version and dist archive: if --dist is supplied, 113 | # determine the version from the archive name, otherwise expect it 114 | # to be supplied via --version argument; default to latest nightly 115 | # build. 116 | if [ "${dist-}" ] 117 | then 118 | # Full version (including test release, release candidate or nightly tag. 119 | full_version=$(echo "$dist" \ 120 | | grep -oE "$FULL_VERSION_REGEX" \ 121 | | head -n 1) 122 | # Short version (of the .. form). 123 | short_version=$(echo "$full_version" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') 124 | else 125 | # Full version is expected to be provided. 126 | full_version=${full_version:-7.0.0-nightly} 127 | # Short version (of the .. form). 128 | short_version=$(echo "$full_version" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') 129 | # If full_version contains "nightly" tag, find the latest nightly, 130 | # otherwise, use the release link. 131 | # TODO: this logic can be removed if we use consistent URLs 132 | # for releases/nightly builds. 133 | if echo "$full_version" | grep -q 'nightly' 134 | then 135 | version_url=https://franz.com/ftp/pub/agraph/nightly/$short_version/ 136 | latest_build=$(curl -s "$version_url" \ 137 | | grep -oE '[0-9]{8}-[0-9]{6}/' \ 138 | | head -n 1) 139 | url_base="$version_url$latest_build" 140 | else 141 | url_base=http://franz.com/ftp/pri/acl/ag/ag$full_version/linuxamd64.64/ 142 | fi 143 | archive_name="agraph-$short_version-linuxamd64.64.tar.gz" 144 | dist="$url_base$archive_name" 145 | fi 146 | tag=${tag:-franzinc/agraph:v$full_version} 147 | docker build \ 148 | --build-arg "AG_VERSION=$short_version" \ 149 | --build-arg "AG_ARCHIVE=$dist" \ 150 | ${no_docker_cache-} \ 151 | ${docker_build_pull-} \ 152 | -t "$tag" . 153 | } 154 | 155 | 156 | # Run a container from an image for a given AG version, capturing 157 | # AGRAPH_SUPER_USER and AGRAPH_SUPER_PASSWORD variables from host 158 | # environment. Command is run in a subshell with exported username and 159 | # password. 160 | function agdock_run () { 161 | shift 162 | for i in "$@" 163 | do 164 | case $i in 165 | -i=*|--image=*) 166 | image="${i#*=}" 167 | ;; 168 | -n=*|--name=*) 169 | name="${i#*=}" 170 | ;; 171 | -v=*|--version=*) 172 | version="${i#*=}" 173 | ;; 174 | --detach) 175 | detach=-d 176 | ;; 177 | *) 178 | echo -e "$COMMAND_NAME run: unknown option $i\n\n$USAGE" 179 | exit 1 180 | ;; 181 | esac 182 | done 183 | if [ "${image-}" ] 184 | then 185 | version=$(echo "$image" \ 186 | | grep -oE "$FULL_VERSION_REGEX") 187 | elif [ "${version-}" ] 188 | then 189 | image=franzinc/agraph:v$version 190 | else 191 | echo -e "$COMMAND_NAME run: either tag or version must be specified." 192 | exit 1 193 | fi 194 | 195 | name=${name:-agraph$version} 196 | ( 197 | export AGRAPH_SUPER_USER=${AGRAPH_SUPER_USER:-test}; 198 | export AGRAPH_SUPER_PASSWORD=${AGRAPH_SUPER_PASSWORD:-xyzzy}; 199 | export AGRAPH_SESSION_PORTS=${AGRAPH_SESSION_PORTS:-10000-10034} 200 | export AGRAPH_HTTP_PORT=${AGRAPH_HTTP_PORT:-10035} 201 | docker run $detach --rm \ 202 | --shm-size 1g \ 203 | -e AGRAPH_SUPER_USER \ 204 | -e AGRAPH_SUPER_PASSWORD \ 205 | -p "$AGRAPH_SESSION_PORTS:10000-10034" \ 206 | -p "$AGRAPH_HTTP_PORT:10035" \ 207 | --name "$name" \ 208 | "$image" 209 | ) 210 | } 211 | 212 | 213 | # Push the specified image to DockerHub, optionally tagged as latest. 214 | function agdock_push () { 215 | shift 216 | for i in "$@" 217 | do 218 | case $i in 219 | -i=*|--image=*) 220 | image="${i#*=}" 221 | ;; 222 | --latest) 223 | latest="t" 224 | ;; 225 | *) 226 | echo -e "$COMMAND_NAME push: unknown option $i\n\n$USAGE" 227 | exit 1 228 | ;; 229 | esac 230 | done 231 | if [ -z "${image-}" ] 232 | then 233 | echo -e "$COMMAND_NAME push: --image argument is required." 234 | exit 1 235 | fi 236 | docker push "$image" 237 | if [ "${latest-}" ] 238 | then 239 | image_latest="${image%:*}:latest" 240 | docker tag "$image" "$image_latest" 241 | docker push "$image_latest" 242 | fi 243 | } 244 | 245 | 246 | # Execute agtool command in the running container. 247 | function agdock_agtool () { 248 | shift 249 | for i in "$@" 250 | do 251 | case $i in 252 | -n=*|--name=*) 253 | name="${i#*=}" 254 | ;; 255 | --) 256 | break 257 | ;; 258 | *) 259 | echo -e "$COMMAND_NAME agtool: unknown option $i\n\n$USAGE" 260 | exit 1 261 | ;; 262 | esac 263 | done 264 | shift # skip --name argument 265 | shift # skip the -- marker argument 266 | if [ -z "${name-}" ] 267 | then 268 | echo -e "$COMMAND_NAME agtool: --name is required." 269 | exit 1 270 | fi 271 | docker exec "$name" agtool "$@" 272 | } 273 | 274 | 275 | # ------------------------------------------------------------------------------ 276 | # Entrypoint 277 | 278 | case $SUBCOMMAND_NAME in 279 | "help") 280 | agdock_help "$@" 281 | ;; 282 | "build") 283 | agdock_build "$@" 284 | ;; 285 | "run") 286 | agdock_run "$@" 287 | ;; 288 | "push") 289 | agdock_push "$@" 290 | ;; 291 | "agtool") 292 | agdock_agtool "$@" 293 | ;; 294 | *) 295 | echo -e "$COMMAND_NAME: unknown command '$SUBCOMMAND_NAME'\n\n$USAGE" 296 | exit 1 297 | ;; 298 | esac 299 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | AG_RUNAS_USER=agraph 4 | AG_DATA_DIR=/agraph/data 5 | AG_CFG_FILE=/agraph/etc/agraph.cfg 6 | AG_LOG_FILE=/agraph/data/agraph.log 7 | 8 | # Make sure shared memory requirements are met. 9 | shm_size=$(df -P /dev/shm | grep -v Filesystem | awk '{print $2}') 10 | 11 | # When using podman a request for 1g results in 12 | # a shared memory segment of 976564k bytes and not 1g 13 | # and that is good enough. 14 | 15 | if [ "$shm_size" -lt 976000 ] 16 | then 17 | cat <&2 "$var and $file_var are exclusive" 37 | exit 1 38 | fi 39 | local val="${2:-}" 40 | if [ "${!var:-}" ]; then 41 | val="${!var}" 42 | elif [ "${!file_var:-}" ]; then 43 | val="$(< "${!file_var}")" 44 | fi 45 | unset "$file_var" 46 | export "$var"="$val" 47 | } 48 | 49 | if [ -f $AG_CFG_FILE ] 50 | then # User provided an agraph.cfg 51 | echo "Found user-defined AllegroGraph configuration at $AG_CFG_FILE" 52 | if [ -z "$(grep -o SuperUser $AG_CFG_FILE)" ]; then 53 | file_env 'AGRAPH_SUPER_USER' 54 | file_env 'AGRAPH_SUPER_PASSWORD' 55 | if [ -z "$AGRAPH_SUPER_USER" ] || [ -z "$AGRAPH_SUPER_PASSWORD" ]; then 56 | cat <> $AG_CFG_FILE 113 | fi 114 | fi 115 | 116 | function terminate { 117 | echo Shutting down AllegroGraph 118 | /agraph/bin/agraph-control --config $AG_CFG_FILE stop 119 | exit 0 120 | } 121 | 122 | trap "echo Caught signal; terminate" SIGINT SIGTERM SIGQUIT 123 | 124 | # If container's entrypoint is run without arguments, start 125 | # AllegroGraph, otherwise interpret the arguments as a command to run. 126 | if [ "$#" -ne "0" ] 127 | then 128 | # Execute provided arguments. 129 | exec "$@" 130 | else 131 | # Start AllegroGraph daemon. 132 | /agraph/bin/agraph-control --config $AG_CFG_FILE start 133 | # Monitor the logfile. 134 | # This pattern (& to put the process in the background and 135 | # then blocking using 'wait') appears to be the most reliable 136 | # way of getting bash to respond to signals. 137 | tail -f $AG_LOG_FILE & 138 | wait $! 139 | fi 140 | --------------------------------------------------------------------------------