Skip to content

Commit

Permalink
Minor code improvements in Dockerfile
Browse files Browse the repository at this point in the history
Dropped `.sh` file extensions from set-up scripts, placed them
under `/usr/local/bin/` (making them available in `$PATH`),
finessed `RUN` command formatting.
  • Loading branch information
chris-kobrzak committed May 24, 2015
1 parent 9a3193f commit 55c1fc7
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 33 deletions.
53 changes: 30 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ MAINTAINER Krzysztof Kobrzak <[email protected]>
ENV COUCHDB_VERSION 1.6.1

# CouchDB dependencies and required utilities
RUN DEBIAN_FRONTEND=noninteractive && \
apt-get update && apt-get install -y --force-yes --no-install-recommends \
RUN \
apt-get update && \
DEBIAN_FRONTEND=noninteractive && \
apt-get install -y --force-yes --no-install-recommends \
build-essential \
curl \
erlang-dev \
Expand All @@ -18,34 +20,38 @@ RUN DEBIAN_FRONTEND=noninteractive && \
netcat \
pwgen

ADD scripts /usr/local/bin

RUN \
groupadd -r couchdb && \
useradd -d /usr/local/var/lib/couchdb -g couchdb couchdb && \
chown -R couchdb:couchdb /usr/local/bin/* && \
chmod -R +x /usr/local/bin/*

# CouchDB installation from source
RUN DEBIAN_FRONTEND=noninteractive && \
RUN \
DEBIAN_FRONTEND=noninteractive && \
cd /usr/src && \
curl -s -o apache-couchdb.tar.gz http://mirror.ox.ac.uk/sites/rsync.apache.org/couchdb/source/$COUCHDB_VERSION/apache-couchdb-$COUCHDB_VERSION.tar.gz && \
tar -xzf apache-couchdb.tar.gz && \
cd /usr/src/apache-couchdb-$COUCHDB_VERSION && \
./configure && \
make --quiet && \
make install && \
sed -e 's/^bind_address = .*$/bind_address = 0.0.0.0/' -i /usr/local/etc/couchdb/default.ini

# CORS support in CouchDB
RUN sed -i '/\[httpd\]/a enable_cors = true' /usr/local/etc/couchdb/local.ini && \
echo '[cors] \
\norigins = * \
\ncredentials = true \
\nheaders = accept, authorization, content-type, origin, referer \
\nmethods = GET, PUT, POST, HEAD' >> /usr/local/etc/couchdb/local.ini

RUN groupadd -r couchdb && \
useradd -d /usr/local/var/lib/couchdb -g couchdb couchdb
make install

ADD scripts /usr/local/scripts
RUN \
sed -e 's/^bind_address = .*$/bind_address = 0.0.0.0/' -i /usr/local/etc/couchdb/default.ini && \
# CORS support in CouchDB
sed -i '/\[httpd\]/a enable_cors = true' /usr/local/etc/couchdb/local.ini && \
echo '[cors] \
\norigins = * \
\ncredentials = true \
\nheaders = accept, authorization, content-type, origin, referer \
\nmethods = GET, PUT, POST, HEAD, DELETE' >> /usr/local/etc/couchdb/local.ini

RUN touch /usr/local/scripts/couchdb-not-inited && \
chmod +x /usr/local/scripts/*.sh && \
chown -R couchdb:couchdb /usr/local/scripts && \
RUN \
mkdir /var/lib/couchdb && \
touch /var/lib/couchdb/couchdb-not-inited && \
chown -R couchdb:couchdb /var/lib/couchdb && \
chown -R couchdb:couchdb /usr/local/etc/couchdb && \
chown -R couchdb:couchdb /usr/local/var/lib/couchdb && \
Expand All @@ -56,7 +62,8 @@ RUN touch /usr/local/scripts/couchdb-not-inited && \
chmod -R 0770 /usr/local/var/log/couchdb && \
chmod -R 0770 /usr/local/var/run/couchdb

RUN apt-get purge -y \
RUN \
apt-get purge -y \
binutils \
build-essential \
cpp \
Expand All @@ -70,12 +77,12 @@ RUN apt-get purge -y \

USER couchdb

ENTRYPOINT ["/usr/local/scripts/start_couchdb.sh"]
ENTRYPOINT ["start_couchdb"]
CMD [""]

EXPOSE 5984

WORKDIR /usr/local/scripts
WORKDIR /usr/local/var/lib/couchdb

# Expose our data, logs and configuration volumes
VOLUME ["/usr/local/var/lib/couchdb", "/usr/local/var/log/couchdb", "/usr/local/etc/couchdb"]
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ if [ ! -z "$DB" ]; then
fi
echo "========================================================"

rm -f /usr/local/scripts/couchdb-not-inited
rm -f /var/lib/couchdb/couchdb-not-inited
9 changes: 9 additions & 0 deletions scripts/start_couchdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

if [[ -e /var/lib/couchdb/couchdb-not-inited ]]; then
echo "Initialising CouchDB..."
initialise_couchdb
fi

echo "Starting CouchDB..."
/usr/local/bin/couchdb
9 changes: 0 additions & 9 deletions scripts/start_couchdb.sh

This file was deleted.

0 comments on commit 55c1fc7

Please sign in to comment.