Adds a dockerfile for building an image to run FoundationDB.
This commit is contained in:
parent
2f2aaf5bce
commit
6e076dff8a
|
@ -0,0 +1,69 @@
|
|||
# Dockerfile
|
||||
#
|
||||
# This source file is part of the FoundationDB open source project
|
||||
#
|
||||
# Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
FROM ubuntu:18.04
|
||||
|
||||
# Install dependencies
|
||||
|
||||
RUN apt-get update; apt-get install -y wget=1.19.4-1ubuntu2 \
|
||||
dnsutils=1:9.11.3+dfsg-1ubuntu1.1
|
||||
|
||||
# Install FoundationDB Binaries
|
||||
|
||||
ARG FDB_VERSION
|
||||
ARG FDB_WEBSITE=https://www.foundationdb.org
|
||||
|
||||
RUN mkdir -p /var/fdb/tmp
|
||||
WORKDIR /var/fdb/tmp
|
||||
ADD $FDB_WEBSITE/downloads/$FDB_VERSION/linux/fdb_$FDB_VERSION.tar.gz .
|
||||
RUN tar -xzf fdb_$FDB_VERSION.tar.gz --strip-components=1
|
||||
RUN rm fdb_$FDB_VERSION.tar.gz
|
||||
RUN chmod u+x fdb*
|
||||
RUN mv fdb* /usr/bin
|
||||
WORKDIR /var/fdb
|
||||
RUN rm -r tmp
|
||||
|
||||
# Install FoundationDB Client Libraries
|
||||
|
||||
ARG FDB_ADDITIONAL_VERSIONS="5.1.7"
|
||||
|
||||
RUN mkdir -p scripts
|
||||
COPY download_multiversion_libraries.bash scripts
|
||||
|
||||
RUN mkdir -p /usr/lib/fdb
|
||||
ADD $FDB_WEBSITE/downloads/$FDB_VERSION/linux/libfdb_c_$FDB_VERSION.so /usr/lib/fdb
|
||||
RUN bash scripts/download_multiversion_libraries.bash $FDB_WEBSITE $FDB_ADDITIONAL_VERSIONS
|
||||
|
||||
# Set Up Runtime Scripts and Directoris
|
||||
|
||||
COPY fdb.bash scripts
|
||||
COPY create_server_environment.bash scripts
|
||||
COPY create_cluster_file.bash scripts
|
||||
RUN chmod u+x scripts/*.bash
|
||||
RUN mkdir -p logs
|
||||
VOLUME /var/fdb/data
|
||||
|
||||
CMD /var/fdb/scripts/fdb.bash
|
||||
|
||||
# Runtime Configuration Options
|
||||
|
||||
ENV FDB_PORT 4500
|
||||
ENV FDB_CLUSTER_FILE /var/fdb/fdb.cluster
|
||||
ENV FDB_NETWORKING_MODE container
|
||||
ENV FDB_COORDINATOR ""
|
|
@ -0,0 +1,71 @@
|
|||
# Overview
|
||||
|
||||
This directory provides a Docker image for running FoundationDB.
|
||||
|
||||
The image in this directory is based on Ubuntu 18.0.4, but the commands and
|
||||
scripts used to build it should be suitable for most other distros with small
|
||||
tweaks to the installation of dependencies.
|
||||
|
||||
The image relies on the following dependencies:
|
||||
|
||||
* bash
|
||||
* wget
|
||||
* dig
|
||||
* glibc
|
||||
|
||||
# Build Configuration
|
||||
|
||||
This image supports several build arguments for build-time configuration.
|
||||
|
||||
### FDB_VERSION
|
||||
|
||||
The version of FoundationDB to install in the container. This is required.
|
||||
|
||||
### FDB_WEBSITE
|
||||
|
||||
The base URL for the FoundationDB website. The default is
|
||||
`https://www.foundationdb.org`.
|
||||
|
||||
### FDB_ADDITIONAL_VERSIONS
|
||||
|
||||
A list of additional client library versions to include in this image. These
|
||||
libraries will be in a special multiversion library folder.
|
||||
|
||||
# Runtime Configuration
|
||||
|
||||
This image supports several environment variables for run-time configuration.
|
||||
|
||||
### FDB_PORT
|
||||
|
||||
The port that FoundationDB should bind to. The default is 4500.
|
||||
|
||||
### FDB_NETWORKING
|
||||
|
||||
A networking mode that controls what address FoundationDB listens on. If this
|
||||
is `container` (the default), then the server will listen on its public IP
|
||||
within the docker network, and will only be accessible from other containers.
|
||||
|
||||
If this is `host`, then the server will listen on `127.0.0.1`, and will not be
|
||||
accessible from other containers. You should use `host` networking mode if you
|
||||
want to access your container from your host machine, and you should also
|
||||
map the port to the same port on your host machine when you run the container.
|
||||
|
||||
### FDB_COORDINATOR
|
||||
|
||||
A name of another FDB instance to use as a coordinator process. This can be
|
||||
helpful when setting up a larger cluster inside a docker network, for instance
|
||||
when using Docker Compose. The name you provide must be resolvable through the
|
||||
DNS on the container you are running.
|
||||
|
||||
# Copying Into Other Images
|
||||
|
||||
You can also use this image to provide files for images that are clients of a
|
||||
FoundationDB cluster, by using the `from` argument of the `COPY` command. Some
|
||||
files you may want to copy are:
|
||||
|
||||
* `/usr/lib/fdb/libfdb_*.so`: The primary FoundationDB client library
|
||||
* `/usr/lib/fdb/multiversion/libfdb_*.so`: Additional versions of the client
|
||||
library, which you can use if you are setting up a multiversion client.
|
||||
* `/var/fdb/scripts/create_cluster_file.bash`: A script for setting up the
|
||||
cluster file based on an `FDB_COORDINATOR` environment variable.
|
||||
* `/usr/bin/fdbcli`: The FoundationDB CLI.
|
|
@ -0,0 +1,37 @@
|
|||
#! /bin/bash
|
||||
|
||||
#
|
||||
# create_cluster_file.bash
|
||||
#
|
||||
# This source file is part of the FoundationDB open source project
|
||||
#
|
||||
# Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# This script creates a cluster file for a server or client.
|
||||
# This takes the cluster file path from the FDB_CLUSTER_FILE
|
||||
# environment variable, with a default of /etc/foundationdb/fdb.cluster
|
||||
#
|
||||
# The name of the coordinator must be defined in the FDB_COORDINATOR environment
|
||||
# variable, and it must be a name that can be resolved through DNS.
|
||||
|
||||
if [[ -z $FDB_COORDINATOR ]]; then
|
||||
echo "FDB_COORDINATOR environment variable not defined"
|
||||
fi
|
||||
|
||||
FDB_CLUSTER_FILE=${FDB_CLUSTER_FILE:-/etc/foundationdb/fdb.cluster}
|
||||
mkdir -p $(dirname $FDB_CLUSTER_FILE)
|
||||
coordinator_ip=$(dig +short $FDB_COORDINATOR)
|
||||
echo "docker:docker@$coordinator_ip:4500" > $FDB_CLUSTER_FILE
|
|
@ -0,0 +1,42 @@
|
|||
#! /bin/bash
|
||||
|
||||
#
|
||||
# create_server_environment.bash
|
||||
#
|
||||
# This source file is part of the FoundationDB open source project
|
||||
#
|
||||
# Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
fdb_dir=/var/fdb
|
||||
env_file=$fdb_dir/.fdbenv
|
||||
|
||||
: > $env_file
|
||||
|
||||
if [[ "$FDB_NETWORKING" == "host" ]]; then
|
||||
public_ip=127.0.0.1
|
||||
elif [[ "$FDB_NETWORKING_MODE" == "container" ]]; then
|
||||
public_ip=$(grep `hostname` /etc/hosts | sed -e "s/\s *`hostname`//")
|
||||
else
|
||||
echo "Unknown FDB Networking mode \"$FDB_NETWORKING_MODE\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "export PUBLIC_IP=$public_ip" >> $env_file
|
||||
if [[ -z $FDB_COORDINATOR ]]; then
|
||||
FDB_COORDINATOR=$public_ip
|
||||
fi
|
||||
/var/fdb/scripts/create_cluster_file.bash
|
||||
echo $env_file
|
|
@ -0,0 +1,31 @@
|
|||
#! /bin/bash
|
||||
|
||||
#
|
||||
# download_multiversion_libraries.bash
|
||||
#
|
||||
# This source file is part of the FoundationDB open source project
|
||||
#
|
||||
# Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
mkdir -p /usr/lib/fdb/multiversion
|
||||
website=$1
|
||||
shift
|
||||
for version in $*; do
|
||||
origin=$website/downloads/$version/linux/libfdb_c_$version.so
|
||||
destination=/usr/lib/fdb/multiversion/libfdb_c_$version.so
|
||||
echo "Downloading $origin to $destination"
|
||||
wget $origin -o $destination
|
||||
done
|
|
@ -0,0 +1,26 @@
|
|||
#! /bin/bash
|
||||
|
||||
#
|
||||
# fdb.bash
|
||||
#
|
||||
# This source file is part of the FoundationDB open source project
|
||||
#
|
||||
# Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
source $(/var/fdb/scripts/create_server_environment.bash)
|
||||
echo "Starting FDB server on $PUBLIC_IP:4500"
|
||||
fdbserver --listen_address 0.0.0.0:$FDB_PORT --public_address $PUBLIC_IP:4500 \
|
||||
--datadir /var/fdb/data --logdir /var/fdb/logs
|
Loading…
Reference in New Issue