Skip to content

Instantly share code, notes, and snippets.

@manthey
Last active October 24, 2022 17:03
Show Gist options
  • Save manthey/78b331ae5b6503b27fae26faf2e720b5 to your computer and use it in GitHub Desktop.
Save manthey/78b331ae5b6503b27fae26faf2e720b5 to your computer and use it in GitHub Desktop.
---
version: '3'
services:
# To use a mongo container, uncomment this block and the links in the girder
# block. In the Dockerfile, disable starting mongo and enable the sysctl and
# iptables commands.
# mongodb:
# image: mongo:4.4
# command: bash -c "mkdir /dev/shm/mongo && mongod --nojournal --dbpath=/dev/shm/mongo --noauth --bind_ip_all --quiet --logpath /var/log/mongodb/mongod.log"
# # command: bash -c "mongod --nojournal --noauth --bind_ip_all --quiet --logpath /var/log/mongodb/mongod.log"
girder:
build:
context: .
dockerfile: test.Dockerfile
# links:
# - "mongodb:mongodb"
# Needed for mount tests
privileged: true
# Needed for ansible test
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker:ro
environment:
# Pass 3.6, 3.7, etc.
- "PYVER=${PYVER:-3.6}"
# pass, e.g. "-k test"
- "PYTESTARGS=${PYTESTARGS:-}"
# pass, e.g. "-R test"
- "CTESTARGS=${CTESTARGS:-}"
# pass any value to keep the docker running on success
- "STAYUP=${STAYUP:-}"
# test command:
# docker-compose -f docker-compose-test.yml down; PYVER=3.6 docker-compose -f docker-compose-test.yml up --build
FROM girder/tox-and-node
LABEL maintainer="Kitware, Inc. <kitware@kitware.com>"
# See http://click.pocoo.org/5/python3/#python-3-surrogate-handling for more detail on
# why this is necessary.
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
RUN npm install --global node-gyp && \
npm config set unsafe-perm true && \
npm install --global phantomjs-prebuilt && \
rm --force /etc/boto.cfg && \
\
chmod a+r /etc/fuse.conf && \
\
python3 -m pip install --no-cache-dir --upgrade pip setuptools && \
\
true
RUN \
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add - && \
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" > /etc/apt/sources.list.d/mongodb-org-4.4.list && \
apt-get update && \
apt-get install -y mongodb-org && \
true
RUN mkdir /girder
WORKDIR /girder
COPY . /girder/
RUN cd /girder && \
git clean -fxd
CMD \
set -e && \
\
mkdir /dev/shm/mongo && mongod --nojournal --dbpath=/dev/shm/mongo --noauth --bind_ip_all --quiet --logpath /var/log/mongodb/mongod.log & \
\
# # Needed to make mongo contain appear as localhost \
# sysctl -w net.ipv4.conf.eth0.route_localnet=1 && \
# iptables -t nat -A OUTPUT -o lo -p tcp -m tcp --dport 27017 -j DNAT --to-destination `dig +short mongodb`:27017 && \
# # iptables -t nat -A OUTPUT -o lo -p tcp -m tcp --dport 11211 -j DNAT --to-destination `dig +short memcached`:11211 && \
# iptables -t nat -A POSTROUTING -o eth0 -m addrtype --src-type LOCAL --dst-type UNICAST -j MASQUERADE && \
\
echo "PYTHON VERSION ##############################################" && \
echo $(basename $(find $PYENV_ROOT/versions -name ${PYVER:-'3\.6'}'*')) > $PYENV_ROOT/version && \
python --version && \
\
python3 -m venv /girder_env && \
. /girder_env/bin/activate && \
\
python3 -m pip install --upgrade pip --no-cache-dir setuptools setuptools_scm wheel && \
\
git clean -fxd && \
\
export PYTHON_EXECUTABLE=/girder_env/bin/python && \
export JASMINE_TIMEOUT=15000 && \
export NODE_DIR=$(dirname $(which node)) && \
export PATH="/girder_env/bin:$NODE_DIR:$PATH" && \
\
echo "LINT ########################################################" && \
tox -e lint && \
echo "PUBLIC NAMES ################################################" && \
tox -e public_names && \
echo "DOCS ########################################################" && \
tox -e docs && \
echo "PYTEST ######################################################" && \
tox -e pytest -- ${PYTESTARGS} || exit && \
\
echo "NPM CI ######################################################" && \
npm ci && \
echo "NPM LINT ####################################################" && \
npm run lint && \
echo "NPM DOCS ####################################################" && \
npm run docs && \
\
# This is needed -- the environnment is deactivated after tox \
echo "PYTHON INSTALL ##############################################" && \
python3 -m pip install --editable .[sftp,mount] --editable clients/python --requirement requirements-dev.txt && \
echo "GIRDER BUILD ################################################" && \
girder build --dev && \
\
(rm -rf /_build || true) && \
mkdir /_build && \
cd /_build && \
echo "CMAKE #######################################################" && \
cmake -DPYTHON_EXECUTABLE:FILEPATH="`which python`" -DPYTHON_VERSION=`python -c 'import sys;sys.stdout.write("%d.%d" % (sys.version_info.major, sys.version_info.minor))'` ../girder && \
echo "MAKE ########################################################" && \
make -j `nproc` && \
echo "CTEST #######################################################" && \
ctest --output-on-failure -j `nproc` ${CTESTARGS} && \
cd /girder && \
\
if [ -n "${STAYUP:-}" ]; then \
echo "WAITING #################################################" && \
while true; do sleep 10; done; \
fi && \
\
echo "COVERAGE ####################################################" && \
npm run coverage && \
\
echo "ANSIBLE #####################################################" && \
tox -e ansible && \
\
echo "COVERAGE ####################################################" && \
npm run coverage && \
\
echo "SUCCESS #####################################################" && \
\
true || (echo "FAILED #####################################################" && sleep 100000) && \
\
true
@manthey
Copy link
Author

manthey commented Sep 28, 2022

Stick these in the root girder directory and run something like docker-compose -f docker-compose-test.yml down; PYVER=3.6 docker-compose -f docker-compose-test.yml up --build. The harden-tests branch works as of 2022-09-28.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment