Skip to content

Commit

Permalink
Added options via envvars
Browse files Browse the repository at this point in the history
Added INFO_ADDRESS

Updated README
  • Loading branch information
Richard Guo committed Feb 8, 2018
1 parent 3729a59 commit 99a333d
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ENV AEROSPIKE_SHA256 9b533226d4cc5473fc25f6cc4f81fdd5ba0864aeedef7adf14bdaa4ff1a

RUN \
apt-get update -y \
&& apt-get install -y wget python python-argparse python-bcrypt python-openssl logrotate net-tools iproute2 iputils-ping \
&& apt-get install -y wget python python-argparse python-bcrypt python-openssl logrotate net-tools iproute2 iputils-ping gettext-base\
&& wget "https://www.aerospike.com/artifacts/aerospike-server-community/${AEROSPIKE_VERSION}/aerospike-server-community-${AEROSPIKE_VERSION}-ubuntu16.04.tgz" -O aerospike-server.tgz \
&& echo "$AEROSPIKE_SHA256 *aerospike-server.tgz" | sha256sum -c - \
&& mkdir aerospike \
Expand All @@ -31,7 +31,7 @@ RUN \


# Add the Aerospike configuration specific to this dockerfile
COPY aerospike.conf /etc/aerospike/aerospike.conf
COPY aerospike.template.conf /etc/aerospike/aerospike.template.conf
COPY entrypoint.sh /entrypoint.sh
# Mount the Aerospike data directory
VOLUME ["/opt/aerospike/data"]
Expand Down
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,42 @@ The following will run `asd` with all the exposed ports forward to the host mach

## Custom Configuration

By default, `asd` will use the configuration file in `/etc/aerospike/aerospike.conf`, which is added to the directory by the Dockerfile. To provide a custom configuration, you should first mount a directory containing the file using the `-v` option for `docker`:
There are two ways to configure Aerospike.

**Environment Variables**

You can provide environment variables to the running container via the `-e` flag. To set my default Namespace name to "aerospike-demo":

docker run -e "NAMESPACE=aerospike-demo" aerospike/aerospike-server ...

List of Environment Variables:

* SERVICE_THREADS - Default: Number of vCPUs
* TRANSACTION_QUEUES - Default: Number of vCPUs
* TRANSACTION_THREADS_PER_QUEUE - Default: 4
* LOGFILE - Default: /dev/null, do not log to file, log to stdout
* SERVICE_ADDRESS - Default: any
* SERVICE_PORT - Default: 3000
* HB_ADDRESS - Default: any
* HB_PORT - Default: 3002
* FABRIC_ADDRESS - Default: any
* FABRIC_PORT - Default: 3001
* INFO_ADDRESS - Default: any
* INFO_PORT - Default: 3003
* NAMESPACE - Default: test
* REPL_FACTOR - Default: 2
* MEM_GB - Default: 1, the unit is always `G` (GB)
* DEFAULT_TTL - Default: 30d
* STORAGE_GB - Default: 4, the unit is always `G` (GB)

See the [configuration reference](https://www.aerospike.com/docs/reference/configuration/index.html) for what each controls.

This is not compatible with using custom configuration files.

**Custom Conf File**


By default, `asd` will use the configuration file in `/etc/aerospike/aerospike.conf`, which is generated by the entrypoint script. Environment variables will have no effect on your custom configuration file. To provide a custom configuration, you should first mount a directory containing the file using the `-v` option for `docker`:

-v <DIRECTORY>:/opt/aerospike/etc

Expand Down
32 changes: 18 additions & 14 deletions aerospike.conf → aerospike.template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ service {
group root
paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1.
pidfile /var/run/aerospike/asd.pid
service-threads 4
transaction-queues 4
transaction-threads-per-queue 4
service-threads ${SERVICE_THREADS}
transaction-queues ${TRANSACTION_QUEUES}
transaction-threads-per-queue ${TRANSACTION_THREADS_PER_QUEUE}
proto-fd-max 15000
}

logging {

# Log file must be an absolute path.
file /var/log/aerospike/aerospike.log {
file ${LOGFILE} {
context any info
}

Expand All @@ -27,8 +27,8 @@ logging {

network {
service {
address any
port 3000
address ${SERVICE_ADDRESS}
port ${SERVICE_PORT}

# Uncomment the following to set the `access-address` parameter to the
# IP address of the Docker host. This will the allow the server to correctly
Expand All @@ -39,9 +39,10 @@ network {

heartbeat {

address ${HB_ADDRESS}
# mesh is used for environments that do not support multicast
mode mesh
port 3002
port ${HB_PORT}

# use asinfo -v 'tip:host=<ADDR>;port=3002' to inform cluster of
# other mesh nodes
Expand All @@ -51,26 +52,29 @@ network {
}

fabric {
port 3001
address ${FABRIC_ADDRESS}
port ${FABRIC_PORT}
}

info {
port 3003
address ${INFO_ADDRESS}
port ${INFO_PORT}
}
}

namespace test {
replication-factor 2
memory-size 1G
default-ttl 5d # 5 days, use 0 to never expire/evict.
namespace ${NAMESPACE} {
replication-factor ${REPL_FACTOR}
memory-size ${MEM_GB}G
default-ttl ${DEFAULT_TTL} # 5 days, use 0 to never expire/evict.

# storage-engine memory

# To use file storage backing, comment out the line above and use the
# following lines instead.

storage-engine device {
file /opt/aerospike/data/test.dat
filesize 4G
filesize ${STORAGE_GB}G
data-in-memory true # Store data in memory in addition to file.
}
}
Expand Down
21 changes: 21 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
#!/bin/bash
set -e

export CORES=$(grep -c ^processor /proc/cpuinfo)
export SERVICE_THREADS=${SERVICE_THREADS:-$CORES}
export TRANSACTION_QUEUES=${TRANSACTION_QUEUES:-$CORES}
export TRANSACTION_THREADS_PER_QUEUE=${TRANSACTION_THREADS_PER_QUEUE:-4}
export LOGFILE=${LOGFILE:-/dev/null}
export SERVICE_ADDRESS=${SERVICE_ADDRESS:-any}
export SERVICE_PORT=${SERVICE_PORT:-3000}
export HB_ADDRESS=${HB_ADDRESS:-any}
export HB_PORT=${HB_PORT:-3002}
export FABRIC_ADDRESS=${FABRIC_ADDRESS:-any}
export FABRIC_PORT=${FABRIC_PORT:-3001}
export INFO_ADDRESS=${INFO_ADDRESS:-any}
export INFO_PORT=${INFO_PORT:-3003}
export NAMESPACE=${NAMESPACE:-test}
export REPL_FACTOR=${REPL_FACTOR:-2}
export MEM_GB=${MEM_GB:-1}
export DEFAULT_TTL=${DEFAULT_TTL:-30d}
export STORAGE_GB=${STORAGE_GB:-4}

# Fill out conffile with above values
envsubst < /etc/aerospike/aerospike.template.conf > /etc/aerospike/aerospike.conf

# if command starts with an option, prepend asd
if [ "${1:0:1}" = '-' ]; then
Expand Down

0 comments on commit 99a333d

Please sign in to comment.