-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabling CouchDB unit-tests for all ARCH CI Environment
Spinning up a CouchDB container in unit-test setup, and making necessary config changes so that existing CouchDB unit-tests run as a part of Continuous Integration (CI). Change-Id: I4aabc587d9cba220b6385e410786b35230118a9a Signed-off-by: Adnan Choudhury <adnan.choudhury@itpeoplecorp.com>
- Loading branch information
Showing
7 changed files
with
191 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
FROM hyperledger/fabric-baseimage:_BASE_TAG_ | ||
|
||
# Based on https://github.com/klaemo/docker-couchdb/blob/master/2.0.0/Dockerfile | ||
|
||
# Add CouchDB user account | ||
RUN groupadd -r couchdb && useradd -d /opt/couchdb -g couchdb couchdb | ||
|
||
RUN apt-get update -y && apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
curl \ | ||
erlang-nox \ | ||
erlang-reltool \ | ||
haproxy \ | ||
libicu5. \ | ||
libmozjs185-1.0 \ | ||
openssl \ | ||
cmake \ | ||
apt-transport-https \ | ||
gcc \ | ||
g++ \ | ||
erlang-dev \ | ||
libcurl4-openssl-dev \ | ||
libicu-dev \ | ||
libmozjs185-dev \ | ||
make \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Grab su-exec and tini | ||
RUN set -x \ | ||
&& git clone https://github.com/ncopa/su-exec /tmp/su-exec/ \ | ||
&& cd /tmp/su-exec \ | ||
&& make all \ | ||
&& cp su-exec /usr/bin/ \ | ||
&& git clone https://github.com/krallin/tini/ /tmp/tini/ \ | ||
&& cd /tmp/tini/ \ | ||
&& git checkout v0.14.0 \ | ||
&& cmake . && make \ | ||
&& cp tini tini-static /usr/local/bin/ \ | ||
# Clean up su-exec and tini | ||
&& rm -rf /tmp/tini \ | ||
&& rm -rf /tmp/su-exec | ||
|
||
ARG COUCHDB_VERSION=2.0.0 | ||
|
||
# Download dev dependencies | ||
RUN set -x \ | ||
&& npm install -g grunt-cli \ | ||
# Acquire CouchDB source code | ||
&& cd /usr/src && mkdir couchdb \ | ||
&& curl -fSL https://dist.apache.org/repos/dist/release/couchdb/source/$COUCHDB_VERSION/apache-couchdb-$COUCHDB_VERSION.tar.gz -o couchdb.tar.gz \ | ||
&& tar -xzf couchdb.tar.gz -C couchdb --strip-components=1 \ | ||
&& cd couchdb \ | ||
# Build the release and install into /opt | ||
&& ./configure --disable-docs \ | ||
&& make release \ | ||
&& mv /usr/src/couchdb/rel/couchdb /opt/ \ | ||
# Cleanup build detritus | ||
&& rm -rf /var/lib/apt/lists/* /usr/lib/node_modules /usr/src/couchdb* | ||
|
||
# Add configuration | ||
COPY payload/local.ini /opt/couchdb/etc/local.d/ | ||
COPY payload/vm.args /opt/couchdb/etc/ | ||
COPY payload/docker-entrypoint.sh / | ||
|
||
# Setup directories and permissions | ||
RUN chmod +x /docker-entrypoint.sh \ | ||
&& mkdir /opt/couchdb/data /opt/couchdb/etc/default.d \ | ||
&& chown -R couchdb:couchdb /opt/couchdb/ | ||
|
||
WORKDIR /opt/couchdb | ||
EXPOSE 5984 4369 9100 | ||
VOLUME ["/opt/couchdb/data"] | ||
|
||
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"] | ||
CMD ["/opt/couchdb/bin/couchdb"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
# 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. | ||
|
||
set -e | ||
|
||
if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then | ||
# we need to set the permissions here because docker mounts volumes as root | ||
chown -R couchdb:couchdb /opt/couchdb | ||
|
||
chmod -R 0770 /opt/couchdb/data | ||
|
||
chmod 664 /opt/couchdb/etc/*.ini | ||
chmod 664 /opt/couchdb/etc/local.d/*.ini | ||
chmod 775 /opt/couchdb/etc/*.d | ||
|
||
if [ ! -z "$NODENAME" ] && ! grep "couchdb@" /opt/couchdb/etc/vm.args; then | ||
echo "-name couchdb@$NODENAME" >> /opt/couchdb/etc/vm.args | ||
fi | ||
|
||
if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then | ||
# Create admin | ||
printf "[admins]\n%s = %s\n" "$COUCHDB_USER" "$COUCHDB_PASSWORD" > /opt/couchdb/etc/local.d/docker.ini | ||
chown couchdb:couchdb /opt/couchdb/etc/local.d/docker.ini | ||
fi | ||
|
||
# if we don't find an [admins] section followed by a non-comment, display a warning | ||
if ! grep -Pzoqr '\[admins\]\n[^;]\w+' /opt/couchdb/etc/local.d/*.ini; then | ||
# The - option suppresses leading tabs but *not* spaces. :) | ||
cat >&2 <<-'EOWARN' | ||
**************************************************** | ||
WARNING: CouchDB is running in Admin Party mode. | ||
This will allow anyone with access to the | ||
CouchDB port to access your database. In | ||
Docker's default configuration, this is | ||
effectively any other container on the same | ||
system. | ||
Use "-e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password" | ||
to set it in "docker run". | ||
**************************************************** | ||
EOWARN | ||
fi | ||
|
||
|
||
exec su-exec couchdb "$@" | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
; CouchDB Configuration Settings | ||
|
||
; Custom settings should be made in this file. They will override settings | ||
; in default.ini, but unlike changes made to default.ini, this file won't be | ||
; overwritten on server upgrade. | ||
|
||
[chttpd] | ||
bind_address = any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# 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. | ||
|
||
# Ensure that the Erlang VM listens on a known port | ||
-kernel inet_dist_listen_min 9100 | ||
-kernel inet_dist_listen_max 9100 | ||
|
||
# Tell kernel and SASL not to log anything | ||
-kernel error_logger silent | ||
-sasl sasl_error_logger false | ||
|
||
# Use kernel poll functionality if supported by emulator | ||
+K true | ||
|
||
# Start a pool of asynchronous IO threads | ||
+A 16 | ||
|
||
# Comment this line out to enable the interactive Erlang shell on startup | ||
+Bd -noinput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters