Skip to content

Commit

Permalink
Merge pull request #1 from umpc/docker
Browse files Browse the repository at this point in the history
A few potential improvement suggestions
  • Loading branch information
Ricard Bejarano authored May 15, 2018
2 parents 5e6a654 + a4d284c commit 192ae9c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 17 deletions.
53 changes: 37 additions & 16 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
FROM ubuntu:18.04

ENV FDB_UID="1000"
ENV FDB_GID="1000"

ARG FDB_LISTEN_ADDR="0.0.0.0"

ARG FDB_VERSION="5.1.7"
ARG FDB_REVISION="1"
ARG LISTEN_ADDR="0.0.0.0"
ARG FDB_DEB_REVISION="1"

ARG FDB_PKG_URL="https://www.foundationdb.org/downloads/${FDB_VERSION}/ubuntu/installers"
ARG FDB_CLIENTS_PKG="foundationdb-clients_${FDB_VERSION}-${FDB_DEB_REVISION}_amd64.deb"
ARG FDB_SERVER_PKG="foundationdb-server_${FDB_VERSION}-${FDB_DEB_REVISION}_amd64.deb"

ADD https://www.foundationdb.org/downloads/"$FDB_VERSION"/ubuntu/installers/foundationdb-clients_"$FDB_VERSION"-"$FDB_REVISION"_amd64.deb /tmp/foundationdb-clients_"$FDB_VERSION"-"$FDB_REVISION"_amd64.deb
ADD https://www.foundationdb.org/downloads/"$FDB_VERSION"/ubuntu/installers/foundationdb-server_"$FDB_VERSION"-"$FDB_REVISION"_amd64.deb /tmp/foundationdb-server_"$FDB_VERSION"-"$FDB_REVISION"_amd64.deb
ADD ${FDB_PKG_URL}/${FDB_CLIENTS_PKG} /tmp/${FDB_CLIENTS_PKG}
ADD ${FDB_PKG_URL}/${FDB_SERVER_PKG} /tmp/${FDB_SERVER_PKG}

RUN apt update &&\
RUN apt update && \
apt install -y python
RUN dpkg -i /tmp/foundationdb-clients_*_amd64.deb &&\
dpkg -i /tmp/foundationdb-server_*_amd64.deb &&\
service foundationdb stop &&\
rm -rf /tmp/foundationdb-*_"$FDB_VERSION"-"$FDB_REVISION"_amd64.deb /var/lib/foundationdb/data/*
RUN sed -i "s/^listen_address.*/listen_address = $LISTEN_ADDR:4500/" /etc/foundationdb/foundationdb.conf &&\
cp -r /etc/foundationdb /etc/foundationdb.default

CMD cp --no-clobber /etc/foundationdb.default/* /etc/foundationdb &&\
chown -R foundationdb:foundationdb /etc/foundationdb &&\
/usr/lib/foundationdb/fdbmonitor

EXPOSE 4500
RUN dpkg -i /tmp/${FDB_CLIENTS_PKG} /tmp/${FDB_SERVER_PKG} && \
rm /tmp/${FDB_CLIENTS_PKG} /tmp/${FDB_SERVER_PKG}

# Note: Remove this instruction if deb postinst is changed to not auto-start foundationdb.
RUN service foundationdb stop && \
rm -rf /var/lib/foundationdb/data/*

# Replace the default listen_address with 0.0.0.0 or an argument specified at build time.
RUN sed -i "s/^listen_address.*/listen_address = ${FDB_LISTEN_ADDR}:4500/" /etc/foundationdb/foundationdb.conf

# Keeps the default configuration from being overlaid by bind mounts.
RUN cp -r /etc/foundationdb /etc/foundationdb.default

# Writes the default configuration to bind mounts if not present.
CMD cp -r --no-clobber /etc/foundationdb.default/* /etc/foundationdb && \
# Syncs host and container file ownership for privilege separation.
groupmod -g ${FDB_GID} foundationdb && \
usermod -g ${FDB_GID} -u ${FDB_UID} --non-unique foundationdb && \
chown -R foundationdb:foundationdb \
/etc/foundationdb \
/var/log/foundationdb \
/var/lib/foundationdb && \
# Starts foundationdb
/usr/lib/foundationdb/fdbmonitor
10 changes: 9 additions & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,13 @@ docker build -t foundationdb:latest foundationdb/docker
## Usage

```bash
docker run -d -v $(pwd)/data:/var/lib/foundationdb/data -p 4500:4500 foundationdb:latest
docker run -d \
-e FDB_UID=$(id -u) \
-e FDB_GID=$(id -g) \
-v $(pwd)/etc:/etc/foundationdb \
-v $(pwd)/log:/var/log/foundationdb \
-v $(pwd)/data:/var/lib/foundationdb/data \
-p 127.0.0.1:4500:4500 \
--init \
foundationdb:latest
```
5 changes: 5 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ services:
db:
image: foundationdb:latest # Replace with specific version number if desired
volumes:
- ./etc:/etc/foundationdb
- ./log:/var/log/foundationdb
- ./data:/var/lib/foundationdb/data
ports:
- 4500:4500
environment:
- FDB_UID=1000 # Replace with the user/group IDs used for volume access in your setup.
- FDB_GID=1000

0 comments on commit 192ae9c

Please sign in to comment.