diff --git a/hbase/Dockerfile b/hbase/Dockerfile deleted file mode 100644 index 38c748843956f3a6b5f83d1dfe9c4fc96c0dd818..0000000000000000000000000000000000000000 --- a/hbase/Dockerfile +++ /dev/null @@ -1,45 +0,0 @@ -# HBase in Docker -# -# Version 0.4 - -# http://docs.docker.io/en/latest/use/builder/ - -FROM ubuntu:bionic -MAINTAINER Dave Beckett - -COPY sources.list /etc/apt/sources.list - -COPY *.sh /build/ - -ENV HBASE_VERSION 2.2.4 - -ADD hbase-$HBASE_VERSION-bin.tar.gz /opt/ - -RUN /build/prepare-hbase.sh && \ - cd /opt/hbase && /build/build-hbase.sh \ - cd / && /build/cleanup-hbase.sh && rm -rf /build - -VOLUME /data - -ADD ./hbase-site.xml /opt/hbase/conf/hbase-site.xml - -ADD ./zoo.cfg /opt/hbase/conf/zoo.cfg - -ADD ./replace-hostname /opt/replace-hostname - -ADD ./hbase-server /opt/hbase-server - -# REST API -EXPOSE 8080 -# REST Web UI at :8085/rest.jsp -EXPOSE 8085 -# Thrift API -EXPOSE 9090 -# Thrift Web UI at :9095/thrift.jsp -EXPOSE 9095 -# HBase's Embedded zookeeper cluster -EXPOSE 2181 -# HBase Master web UI at :16010/master-status; ZK at :16010/zk.jsp -EXPOSE 16010 - -CMD ["/opt/hbase-server"] diff --git a/hbase/Makefile b/hbase/Makefile deleted file mode 100644 index baeb78de635f9a4acd4e23152e874188cba264f3..0000000000000000000000000000000000000000 --- a/hbase/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -IMAGE_NAME=dajobe/hbase -IMAGE_TAG=latest - -HBASE_VERSION=$(shell awk '/^ENV HBASE_VERSION/ {print $3}' Dockerfile) - -build: - @echo "Building hbase docker image $(HBASE_VERSION)" - docker build -t $(IMAGE_NAME) . - -# This won't work unless you have already set up the repository config -push: - @echo "Pushing image to https://hub.docker.com/" - docker push $(IMAGE_NAME):$(IMAGE_TAG) diff --git a/hbase/README.md b/hbase/README.md deleted file mode 100644 index 27cbac2de3b3ded40ffa288322f1bf8422ec5bdc..0000000000000000000000000000000000000000 --- a/hbase/README.md +++ /dev/null @@ -1,196 +0,0 @@ -HBase in Docker -=============== - -This configuration builds a docker container to run HBase (with -embedded Zookeeper) running on the files inside the container. - -NOTE ----- - -The approach here requires editing the local server's `/etc/hosts` -file to add an entry for the container hostname. This is because -HBase uses hostnames to pass connection data back out of the -container (from it's internal Zookeeper). - -Hopefully this can be improved with Docker's newer networking -but this hasn't been fixed yet. - - -Build Image ------------ - - $ docker build -t dajobe/hbase . - - -Pull image ----------- - -If you want to pull the image already built then use this - - $ docker pull dajobe/hbase - -More details at https://hub.docker.com/r/dajobe/hbase/ - - -Run HBase ---------- - -To run HBase by hand: - - $ mkdir data - $ id=$(docker run --name=hbase-docker -h hbase-docker -d -v $PWD/data:/data dajobe/hbase) - -To run it and adjust the host system's locally by editing -`/etc/hosts` to alias the DNS hostname 'hbase-docker' to the -container, use this: - - $ ./start-hbase.sh - -This will require you to enter your sudo password to edit the host -machine's `/etc/hosts` file - -If you want to run multiple hbase dockers on the same host, you can -give them different hostnames with the '-h' / '--hostname' argument. -You may have to give them different ports though. Not tested. - -If you want to customize the hostname used, set the -`HBASE_DOCKER_HOSTNAME` envariable on the docker command line - - -Find Hbase status ------------------ - -Master status if docker container DNS name is 'hbase-docker' - - http://hbase-docker:16010/master-status - -The region servers status pages are linked from the above page. - -Thrift UI - - http://hbase-docker:9095/thrift.jsp - -REST server UI - - http://hbase-docker:8085/rest.jsp - -(Embedded) Zookeeper status - - http://hbase-docker:16010/zk.jsp - - -See HBase Logs --------------- - -If you want to see the latest logs live use: - - $ docker attach $id - -Then ^C to detach. - -To see all the logs since the HBase server started, use: - - $ docker logs $id - -and ^C to detach again. - -To see the individual log files without using `docker`, look into -the data volume dir eg $PWD/data/logs if invoked as above. - - -Test HBase is working via python over Thrift --------------------------------------------- - -Here I am connecting to a docker container with the name 'hbase-docker' -(such as created by the start-hbase.sh script). The port 9090 is the -Thrift API port because [Happybase][1] [2] uses Thrift to talk to HBase. - - $ python - Python 2.7.15 (default, Jan 12 2019, 21:07:57) - [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin - Type "help", "copyright", "credits" or "license" for more information. - >>> import happybase - >>> connection = happybase.Connection('hbase-docker', 9090) - >>> connection.create_table('table-name', { 'family': dict() } ) - >>> connection.tables() - ['table-name'] - >>> table = connection.table('table-name') - >>> table.put('row-key', {'family:qual1': 'value1', 'family:qual2': 'value2'}) - >>> for k, data in table.scan(): - ... print k, data - ... - row-key {'family:qual1': 'value1', 'family:qual2': 'value2'} - >>> - -(Simple install for happybase: `sudo pip install happybase` although I -use `pip install --user happybase` to get it just for me) - - -Test HBase is working from Java -------------------------------- - - $ docker run --rm -it --link $id:hbase-docker dajobe/hbase hbase shell - HBase Shell - Use "help" to get list of supported commands. - Use "exit" to quit this interactive shell. - For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell - Version 2.1.2, r1dfc418f77801fbfb59a125756891b9100c1fc6d, Sun Dec 30 21:45:09 PST 2018 - Took 0.0472 seconds - hbase(main):001:0> status - 1 active master, 0 backup masters, 1 servers, 0 dead, 2.0000 average load - Took 0.7255 seconds - hbase(main):002:0> list - TABLE - table-name - 1 row(s) - Took 0.0509 seconds - => ["table-name"] - hbase(main):003:0> - -Showing the `table-name` table made in the happybase example above. - -Alternatively if you have the Hbase distribution available on the -host you can use `bin/hbase shell` if the hbase configuration has -been set up to connect to host `hbase-docker` zookeeper port 2181 to -get the servers via configuration property `hbase.zookeeper.quorum` - - - -Proxy HBase UIs locally ------------------------ - -If you are running docker on a remote machine, it is handy to see -these server-private urls in a local browser so here is a -~/.ssh/config fragment to do that - - Host my-docker-server - Hostname 1.2.3.4 - LocalForward 127.0.0.1:16010 127.0.0.1:16010 - LocalForward 127.0.0.1:9095 127.0.0.1:9095 - LocalForward 127.0.0.1:8085 127.0.0.1:8085 - -When you `ssh my-docker-server` ssh connects to the docker server and -forwards request on your local machine on ports 16010 / 16030 to the -remote ports that are attached to the hbase container. - -The bottom line, you can use these URLs to see what's going on: - - * http://localhost:16010/master-status for the Master Server - * http://localhost:9095/thrift.jsp for the thrift UI - * http://localhost:8085/rest.jsp for the REST server UI - * http://localhost:16010/zk.jsp for the embedded Zookeeper - -to see what's going on in the container and since both your local -machine and the container are using localhost (aka 127.0.0.1), even -the links work! - - - - - -Notes ------ - -[1] http://happybase.readthedocs.org/en/latest/ - -[2] https://github.com/wbolster/happybase diff --git a/hbase/build-hbase.sh b/hbase/build-hbase.sh deleted file mode 100755 index 8247039b240de87efe0c92b8fafe18cba950dea6..0000000000000000000000000000000000000000 --- a/hbase/build-hbase.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -xe - -. /build/config-hbase.sh - -here=$(pwd) - -# delete files that are not needed to run hbase -rm -rf docs *.txt LEGAL -rm -f */*.cmd - -# Set Java home for hbase servers -sed -i "s,^. export JAVA_HOME.*,export JAVA_HOME=$JAVA_HOME," conf/hbase-env.sh - -# Set interactive shell defaults -cat > /etc/profile.d/defaults.sh < $logs_dir/hbase-thrift.log 2>&1 & - -# REST server (background) -# Ports: 8080 API -echo "hbase rest start logging to $logs_dir/hbase-rest.log" -hbase rest start > $logs_dir/hbase-rest.log 2>&1 & - -# Master server (Foreground) that also starts the region server -# Ports: Master: 16000 API, 16010 UI; 2181 ZK; Region: 16020 API, 16030 UI -echo "hbase master start logging to $logs_dir/hbase-master.log" -exec hbase master start 2>&1 | tee $logs_dir/hbase-master.log diff --git a/hbase/hbase-site.xml b/hbase/hbase-site.xml deleted file mode 100644 index b8c3be89b8386c37a3b4e923eb486675c69d7db5..0000000000000000000000000000000000000000 --- a/hbase/hbase-site.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - hbase.zookeeper.quorum - hbase-docker - - - hbase.rootdir - file:////data/hbase - - - - hbase.master.info.bindAddress - hbase-docker - - - - hbase.regionserver.info.bindAddress - hbase-docker - - - diff --git a/hbase/prepare-hbase.sh b/hbase/prepare-hbase.sh deleted file mode 100755 index d634315923942b3d78cc8e4d3162a5d8b2b0d2b8..0000000000000000000000000000000000000000 --- a/hbase/prepare-hbase.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -xe - -. /build/config-hbase.sh - -apt-get update -y - -apt-get install $minimal_apt_get_args $HBASE_BUILD_PACKAGES - -cd /opt - -#curl -SL $HBASE_DIST/$HBASE_VERSION/hbase-$HBASE_VERSION-bin.tar.gz | tar -x -z && mv hbase-${HBASE_VERSION} hbase - -mv hbase-${HBASE_VERSION} hbase diff --git a/hbase/replace-hostname b/hbase/replace-hostname deleted file mode 100755 index c8e8f1fb8c9ff126232a151822e5800a47287d49..0000000000000000000000000000000000000000 --- a/hbase/replace-hostname +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# Script that replaces the default hostname in files with the environments -# ${HOSTNAME} variable. -# -# This script is intended to be run before starting hbase-server to ensure -# that the hostname matches the configured environment variable. i.e. -# the -h --hostname flag. -# -declare -a files=( - '/opt/hbase/conf/hbase-site.xml' - '/opt/hbase/conf/zoo.cfg' -) - -# Optional custom hostname replacement -REPLACEMENT_HOSTNAME=${HBASE_DOCKER_HOSTNAME:-$HOSTNAME} - -for file in "${files[@]}"; do - if [ -f "${file}.bak" ]; then - cp "${file}.bak" "${file}" - else - cp "${file}" "${file}.bak" - fi - - sed -i "s/hbase-docker/${REPLACEMENT_HOSTNAME}/g" "${file}" -done diff --git a/hbase/sources.list b/hbase/sources.list deleted file mode 100644 index 82bd9625c805eae98764c57e76f03a3bb323a390..0000000000000000000000000000000000000000 --- a/hbase/sources.list +++ /dev/null @@ -1,19 +0,0 @@ -# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ bionic main restricted -deb-src http://archive.ubuntu.com/ubuntu bionic main restricted #Added by software-properties -deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted -deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted multiverse universe #Added by software-properties -deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted -deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted multiverse universe #Added by software-properties -deb http://mirrors.aliyun.com/ubuntu/ bionic universe -deb http://mirrors.aliyun.com/ubuntu/ bionic-updates universe -deb http://mirrors.aliyun.com/ubuntu/ bionic multiverse -deb http://mirrors.aliyun.com/ubuntu/ bionic-updates multiverse -deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse -deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse #Added by software-properties -deb http://archive.canonical.com/ubuntu bionic partner -deb-src http://archive.canonical.com/ubuntu bionic partner -deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted -deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted multiverse universe #Added by software-properties -deb http://mirrors.aliyun.com/ubuntu/ bionic-security universe -deb http://mirrors.aliyun.com/ubuntu/ bionic-security multiverse - diff --git a/hbase/start-hbase.sh b/hbase/start-hbase.sh deleted file mode 100755 index 2ce5562a5af65b272ad4afe185741607e2b80a2c..0000000000000000000000000000000000000000 --- a/hbase/start-hbase.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -e -# -# Script to start docker and update the /etc/hosts file to point to -# the hbase-docker container -# -# hbase thrift and master server logs are written to the local -# logs directory -# - -echo "Starting HBase container" -data_dir=$PWD/data -rm -rf $data_dir -mkdir -p $data_dir -id=$(docker run --name=hbase-docker -h hbase-docker -d -v $data_dir:/data dajobe/hbase) - -echo "Container has ID $id" - -# Get the hostname and IP inside the container -docker inspect $id > config.json -docker_hostname=$(python -c 'from __future__ import print_function; import json; c=json.load(open("config.json")); print(c[0]["Config"]["Hostname"])') -docker_ip=$(python -c 'from __future__ import print_function; import json; c=json.load(open("config.json")); print(c[0]["NetworkSettings"]["IPAddress"])') -rm -f config.json - -echo "Updating /etc/hosts to make hbase-docker point to $docker_ip ($docker_hostname)" -if grep 'hbase-docker' /etc/hosts >/dev/null; then - sudo sed -i.bak "s/^.*hbase-docker.*\$/$docker_ip hbase-docker $docker_hostname/" /etc/hosts -else - sudo sh -c "echo '\n$docker_ip hbase-docker $docker_hostname' >> /etc/hosts" -fi - -echo "Now connect to hbase at localhost on the standard ports" -echo " ZK 2181, Thrift 9090, Master 16000, Region 16020" -echo "Or connect to host hbase-docker (in the container) on the same ports" -echo "" -echo "For docker status:" -echo "$ id=$id" -echo "$ docker inspect \$id" diff --git a/hbase/test_hbase.py b/hbase/test_hbase.py deleted file mode 100644 index 040d21ea8eae086c275395f4f90fa6d2b687d34d..0000000000000000000000000000000000000000 --- a/hbase/test_hbase.py +++ /dev/null @@ -1,47 +0,0 @@ -# https://happybase.readthedocs.org/en/latest/ -# https://github.com/wbolster/happybase -import happybase - -def main(): - HOST='hbase-docker' - PORT=9090 - # Will create and then delete this table - TABLE_NAME='table-name' - ROW_KEY='row-key' - - connection = happybase.Connection(HOST, PORT) - - tables = connection.tables() - print "HBase has tables {0}".format(tables) - - if TABLE_NAME not in tables: - print "Creating table {0}".format(TABLE_NAME) - connection.create_table(TABLE_NAME, { 'family': dict() } ) - - - table = connection.table(TABLE_NAME) - - print "Storing values with row key '{0}'".format(ROW_KEY) - table.put(ROW_KEY, {'family:qual1': 'value1', - 'family:qual2': 'value2'}) - - print "Getting values for row key '{0}'".format(ROW_KEY) - row = table.row(ROW_KEY) - print row['family:qual1'] - - print "Printing rows with keys '{0}' and row-key-2".format(ROW_KEY) - for key, data in table.rows([ROW_KEY, 'row-key-2']): - print key, data - - print "Scanning rows with prefix 'row'" - for key, data in table.scan(row_prefix='row'): - print key, data # prints 'value1' and 'value2' - - print "Deleting row '{0}'".format(ROW_KEY) - row = table.delete(ROW_KEY) - - print "Deleting table {0}".format(TABLE_NAME) - connection.delete_table(TABLE_NAME, disable=True) - -if __name__ == "__main__": - main() diff --git a/hbase/zoo.cfg b/hbase/zoo.cfg deleted file mode 100644 index 5677f0fbfa7c3e5792ab9200a0c4704e8d6a66b1..0000000000000000000000000000000000000000 --- a/hbase/zoo.cfg +++ /dev/null @@ -1,3 +0,0 @@ -clientPort=2181 -clientPortAddress=hbase-docker -server.1=hbase-docker:2181 diff --git a/mongo/Dockerfile b/mongo/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..dcd4af0e20eac505eabcab7dfbaba01c6d90e71b --- /dev/null +++ b/mongo/Dockerfile @@ -0,0 +1,113 @@ +FROM ubuntu:18.04 +MAINTAINER xt + +COPY sources.list /etc/apt/sources.list + +# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added +RUN groupadd -r mongodb && useradd -r -g mongodb mongodb + +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + jq \ + numactl \ + ; \ + if ! command -v ps > /dev/null; then \ + apt-get install -y --no-install-recommends procps; \ + fi; \ + rm -rf /var/lib/apt/lists/* + +# grab gosu for easy step-down from root (https://github.com/tianon/gosu/releases) +ENV GOSU_VERSION 1.12 +# grab "js-yaml" for parsing mongod's YAML config files (https://github.com/nodeca/js-yaml/releases) +ENV JSYAML_VERSION 3.13.1 + +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + wget \ + ; \ + if ! command -v gpg > /dev/null; then \ + apt-get install -y --no-install-recommends gnupg dirmngr; \ + savedAptMark="$savedAptMark gnupg dirmngr"; \ + elif gpg --version | grep -q '^gpg (GnuPG) 1\.'; then \ +# "This package provides support for HKPS keyservers." (GnuPG 1.x only) + apt-get install -y --no-install-recommends gnupg-curl; \ + fi; \ + rm -rf /var/lib/apt/lists/*; \ + \ + dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \ + wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \ + wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \ + export GNUPGHOME="$(mktemp -d)"; \ + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ + gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ + command -v gpgconf && gpgconf --kill all || :; \ + rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \ +# \ +# wget -O /js-yaml.js "https://github.com/nodeca/js-yaml/raw/${JSYAML_VERSION}/dist/js-yaml.js"; \ +# TODO some sort of download verification here + \ + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark > /dev/null; \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + \ +# smoke test + chmod +x /usr/local/bin/gosu; \ + gosu --version; \ + gosu nobody true + +COPY js-yaml.min.js /js-yaml.js + +RUN mkdir /docker-entrypoint-initdb.d + +ENV GPG_KEYS E162F504A20CDF15827F718D4B7C549A058F8B6B +RUN set -ex; \ + export GNUPGHOME="$(mktemp -d)"; \ + for key in $GPG_KEYS; do \ + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done; \ + gpg --batch --export $GPG_KEYS > /etc/apt/trusted.gpg.d/mongodb.gpg; \ + command -v gpgconf && gpgconf --kill all || :; \ + rm -r "$GNUPGHOME"; \ + apt-key list + +# Allow build-time overrides (eg. to build image with MongoDB Enterprise version) +# Options for MONGO_PACKAGE: mongodb-org OR mongodb-enterprise +# Options for MONGO_REPO: repo.mongodb.org OR repo.mongodb.com +# Example: docker build --build-arg MONGO_PACKAGE=mongodb-enterprise --build-arg MONGO_REPO=repo.mongodb.com . +ARG MONGO_PACKAGE=mongodb-org +ARG MONGO_REPO=repo.mongodb.org +ENV MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO} + +ENV MONGO_MAJOR 4.2 +ENV MONGO_VERSION 4.2.6 +# bashbrew-architectures:amd64 arm64v8 s390x +RUN echo "deb http://$MONGO_REPO/apt/ubuntu bionic/${MONGO_PACKAGE%-unstable}/$MONGO_MAJOR multiverse" | tee "/etc/apt/sources.list.d/${MONGO_PACKAGE%-unstable}.list" + +RUN set -x \ +# installing "mongodb-enterprise" pulls in "tzdata" which prompts for input + && export DEBIAN_FRONTEND=noninteractive \ + && apt-get update \ + && apt-get install -y \ + ${MONGO_PACKAGE}=$MONGO_VERSION \ + ${MONGO_PACKAGE}-server=$MONGO_VERSION \ + ${MONGO_PACKAGE}-shell=$MONGO_VERSION \ + ${MONGO_PACKAGE}-mongos=$MONGO_VERSION \ + ${MONGO_PACKAGE}-tools=$MONGO_VERSION \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /var/lib/mongodb \ + && mv /etc/mongod.conf /etc/mongod.conf.orig + +RUN mkdir -p /data/db /data/configdb \ + && chown -R mongodb:mongodb /data/db /data/configdb +VOLUME /data/db /data/configdb + +COPY docker-entrypoint.sh /usr/local/bin/ +ENTRYPOINT ["docker-entrypoint.sh"] + +EXPOSE 27017 +CMD ["mongod"] diff --git a/mongo/docker-entrypoint.sh b/mongo/docker-entrypoint.sh new file mode 100755 index 0000000000000000000000000000000000000000..f310ad3fb718b868567b772243528dfc2e8d1a44 --- /dev/null +++ b/mongo/docker-entrypoint.sh @@ -0,0 +1,363 @@ +#!/bin/bash +set -Eeuo pipefail + +if [ "${1:0:1}" = '-' ]; then + set -- mongod "$@" +fi + +originalArgOne="$1" + +# allow the container to be started with `--user` +# all mongo* commands should be dropped to the correct user +if [[ "$originalArgOne" == mongo* ]] && [ "$(id -u)" = '0' ]; then + if [ "$originalArgOne" = 'mongod' ]; then + find /data/configdb /data/db \! -user mongodb -exec chown mongodb '{}' + + fi + + # make sure we can write to stdout and stderr as "mongodb" + # (for our "initdb" code later; see "--logpath" below) + chown --dereference mongodb "/proc/$$/fd/1" "/proc/$$/fd/2" || : + # ignore errors thanks to https://github.com/docker-library/mongo/issues/149 + + exec gosu mongodb "$BASH_SOURCE" "$@" +fi + +# you should use numactl to start your mongod instances, including the config servers, mongos instances, and any clients. +# https://docs.mongodb.com/manual/administration/production-notes/#configuring-numa-on-linux +if [[ "$originalArgOne" == mongo* ]]; then + numa='numactl --interleave=all' + if $numa true &> /dev/null; then + set -- $numa "$@" + fi +fi + +# usage: file_env VAR [DEFAULT] +# ie: file_env 'XYZ_DB_PASSWORD' 'example' +# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of +# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) +file_env() { + local var="$1" + local fileVar="${var}_FILE" + local def="${2:-}" + if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then + echo >&2 "error: both $var and $fileVar are set (but are exclusive)" + exit 1 + fi + local val="$def" + if [ "${!var:-}" ]; then + val="${!var}" + elif [ "${!fileVar:-}" ]; then + val="$(< "${!fileVar}")" + fi + export "$var"="$val" + unset "$fileVar" +} + +# see https://github.com/docker-library/mongo/issues/147 (mongod is picky about duplicated arguments) +_mongod_hack_have_arg() { + local checkArg="$1"; shift + local arg + for arg; do + case "$arg" in + "$checkArg"|"$checkArg"=*) + return 0 + ;; + esac + done + return 1 +} +# _mongod_hack_get_arg_val '--some-arg' "$@" +_mongod_hack_get_arg_val() { + local checkArg="$1"; shift + while [ "$#" -gt 0 ]; do + local arg="$1"; shift + case "$arg" in + "$checkArg") + echo "$1" + return 0 + ;; + "$checkArg"=*) + echo "${arg#$checkArg=}" + return 0 + ;; + esac + done + return 1 +} +declare -a mongodHackedArgs +# _mongod_hack_ensure_arg '--some-arg' "$@" +# set -- "${mongodHackedArgs[@]}" +_mongod_hack_ensure_arg() { + local ensureArg="$1"; shift + mongodHackedArgs=( "$@" ) + if ! _mongod_hack_have_arg "$ensureArg" "$@"; then + mongodHackedArgs+=( "$ensureArg" ) + fi +} +# _mongod_hack_ensure_no_arg '--some-unwanted-arg' "$@" +# set -- "${mongodHackedArgs[@]}" +_mongod_hack_ensure_no_arg() { + local ensureNoArg="$1"; shift + mongodHackedArgs=() + while [ "$#" -gt 0 ]; do + local arg="$1"; shift + if [ "$arg" = "$ensureNoArg" ]; then + continue + fi + mongodHackedArgs+=( "$arg" ) + done +} +# _mongod_hack_ensure_no_arg '--some-unwanted-arg' "$@" +# set -- "${mongodHackedArgs[@]}" +_mongod_hack_ensure_no_arg_val() { + local ensureNoArg="$1"; shift + mongodHackedArgs=() + while [ "$#" -gt 0 ]; do + local arg="$1"; shift + case "$arg" in + "$ensureNoArg") + shift # also skip the value + continue + ;; + "$ensureNoArg"=*) + # value is already included + continue + ;; + esac + mongodHackedArgs+=( "$arg" ) + done +} +# _mongod_hack_ensure_arg_val '--some-arg' 'some-val' "$@" +# set -- "${mongodHackedArgs[@]}" +_mongod_hack_ensure_arg_val() { + local ensureArg="$1"; shift + local ensureVal="$1"; shift + _mongod_hack_ensure_no_arg_val "$ensureArg" "$@" + mongodHackedArgs+=( "$ensureArg" "$ensureVal" ) +} + +# _js_escape 'some "string" value' +_js_escape() { + jq --null-input --arg 'str' "$1" '$str' +} + +jsonConfigFile="${TMPDIR:-/tmp}/docker-entrypoint-config.json" +tempConfigFile="${TMPDIR:-/tmp}/docker-entrypoint-temp-config.json" +_parse_config() { + if [ -s "$tempConfigFile" ]; then + return 0 + fi + + local configPath + if configPath="$(_mongod_hack_get_arg_val --config "$@")"; then + # if --config is specified, parse it into a JSON file so we can remove a few problematic keys (especially SSL-related keys) + # see https://docs.mongodb.com/manual/reference/configuration-options/ + mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile" + jq 'del(.systemLog, .processManagement, .net, .security)' "$jsonConfigFile" > "$tempConfigFile" + return 0 + fi + + return 1 +} +dbPath= +_dbPath() { + if [ -n "$dbPath" ]; then + echo "$dbPath" + return + fi + + if ! dbPath="$(_mongod_hack_get_arg_val --dbpath "$@")"; then + if _parse_config "$@"; then + dbPath="$(jq -r '.storage.dbPath // empty' "$jsonConfigFile")" + fi + fi + + if [ -z "$dbPath" ]; then + if _mongod_hack_have_arg --configsvr "$@" || { + _parse_config "$@" \ + && clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \ + && [ "$clusterRole" = 'configsvr' ] + }; then + # if running as config server, then the default dbpath is /data/configdb + # https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr + dbPath=/data/configdb + fi + fi + + : "${dbPath:=/data/db}" + + echo "$dbPath" +} + +if [ "$originalArgOne" = 'mongod' ]; then + file_env 'MONGO_INITDB_ROOT_USERNAME' + file_env 'MONGO_INITDB_ROOT_PASSWORD' + # pre-check a few factors to see if it's even worth bothering with initdb + shouldPerformInitdb= + if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then + # if we have a username/password, let's set "--auth" + _mongod_hack_ensure_arg '--auth' "$@" + set -- "${mongodHackedArgs[@]}" + shouldPerformInitdb='true' + elif [ "$MONGO_INITDB_ROOT_USERNAME" ] || [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then + cat >&2 <<-'EOF' + + error: missing 'MONGO_INITDB_ROOT_USERNAME' or 'MONGO_INITDB_ROOT_PASSWORD' + both must be specified for a user to be created + + EOF + exit 1 + fi + + if [ -z "$shouldPerformInitdb" ]; then + # if we've got any /docker-entrypoint-initdb.d/* files to parse later, we should initdb + for f in /docker-entrypoint-initdb.d/*; do + case "$f" in + *.sh|*.js) # this should match the set of files we check for below + shouldPerformInitdb="$f" + break + ;; + esac + done + fi + + # check for a few known paths (to determine whether we've already initialized and should thus skip our initdb scripts) + if [ -n "$shouldPerformInitdb" ]; then + dbPath="$(_dbPath "$@")" + for path in \ + "$dbPath/WiredTiger" \ + "$dbPath/journal" \ + "$dbPath/local.0" \ + "$dbPath/storage.bson" \ + ; do + if [ -e "$path" ]; then + shouldPerformInitdb= + break + fi + done + fi + + if [ -n "$shouldPerformInitdb" ]; then + mongodHackedArgs=( "$@" ) + if _parse_config "$@"; then + _mongod_hack_ensure_arg_val --config "$tempConfigFile" "${mongodHackedArgs[@]}" + fi + _mongod_hack_ensure_arg_val --bind_ip 127.0.0.1 "${mongodHackedArgs[@]}" + _mongod_hack_ensure_arg_val --port 27017 "${mongodHackedArgs[@]}" + _mongod_hack_ensure_no_arg --bind_ip_all "${mongodHackedArgs[@]}" + + # remove "--auth" and "--replSet" for our initial startup (see https://docs.mongodb.com/manual/tutorial/enable-authentication/#start-mongodb-without-access-control) + # https://github.com/docker-library/mongo/issues/211 + _mongod_hack_ensure_no_arg --auth "${mongodHackedArgs[@]}" + if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then + _mongod_hack_ensure_no_arg_val --replSet "${mongodHackedArgs[@]}" + fi + + # "BadValue: need sslPEMKeyFile when SSL is enabled" vs "BadValue: need to enable SSL via the sslMode flag when using SSL configuration parameters" + tlsMode='disabled' + if _mongod_hack_have_arg '--tlsCertificateKeyFile' "$@"; then + tlsMode='allowTLS' + elif _mongod_hack_have_arg '--sslPEMKeyFile' "$@"; then + tlsMode='allowSSL' + fi + # 4.2 switched all configuration/flag names from "SSL" to "TLS" + if [ "$tlsMode" = 'allowTLS' ] || mongod --help 2>&1 | grep -q -- ' --tlsMode '; then + _mongod_hack_ensure_arg_val --tlsMode "$tlsMode" "${mongodHackedArgs[@]}" + else + _mongod_hack_ensure_arg_val --sslMode "$tlsMode" "${mongodHackedArgs[@]}" + fi + + if stat "/proc/$$/fd/1" > /dev/null && [ -w "/proc/$$/fd/1" ]; then + # https://github.com/mongodb/mongo/blob/38c0eb538d0fd390c6cb9ce9ae9894153f6e8ef5/src/mongo/db/initialize_server_global_state.cpp#L237-L251 + # https://github.com/docker-library/mongo/issues/164#issuecomment-293965668 + _mongod_hack_ensure_arg_val --logpath "/proc/$$/fd/1" "${mongodHackedArgs[@]}" + else + initdbLogPath="$(_dbPath "$@")/docker-initdb.log" + echo >&2 "warning: initdb logs cannot write to '/proc/$$/fd/1', so they are in '$initdbLogPath' instead" + _mongod_hack_ensure_arg_val --logpath "$initdbLogPath" "${mongodHackedArgs[@]}" + fi + _mongod_hack_ensure_arg --logappend "${mongodHackedArgs[@]}" + + pidfile="${TMPDIR:-/tmp}/docker-entrypoint-temp-mongod.pid" + rm -f "$pidfile" + _mongod_hack_ensure_arg_val --pidfilepath "$pidfile" "${mongodHackedArgs[@]}" + + "${mongodHackedArgs[@]}" --fork + + mongo=( mongo --host 127.0.0.1 --port 27017 --quiet ) + + # check to see that our "mongod" actually did start up (catches "--help", "--version", MongoDB 3.2 being silly, slow prealloc, etc) + # https://jira.mongodb.org/browse/SERVER-16292 + tries=30 + while true; do + if ! { [ -s "$pidfile" ] && ps "$(< "$pidfile")" &> /dev/null; }; then + # bail ASAP if "mongod" isn't even running + echo >&2 + echo >&2 "error: $originalArgOne does not appear to have stayed running -- perhaps it had an error?" + echo >&2 + exit 1 + fi + if "${mongo[@]}" 'admin' --eval 'quit(0)' &> /dev/null; then + # success! + break + fi + (( tries-- )) + if [ "$tries" -le 0 ]; then + echo >&2 + echo >&2 "error: $originalArgOne does not appear to have accepted connections quickly enough -- perhaps it had an error?" + echo >&2 + exit 1 + fi + sleep 1 + done + + if [ "$MONGO_INITDB_ROOT_USERNAME" ] && [ "$MONGO_INITDB_ROOT_PASSWORD" ]; then + rootAuthDatabase='admin' + + "${mongo[@]}" "$rootAuthDatabase" <<-EOJS + db.createUser({ + user: $(_js_escape "$MONGO_INITDB_ROOT_USERNAME"), + pwd: $(_js_escape "$MONGO_INITDB_ROOT_PASSWORD"), + roles: [ { role: 'root', db: $(_js_escape "$rootAuthDatabase") } ] + }) + EOJS + fi + + export MONGO_INITDB_DATABASE="${MONGO_INITDB_DATABASE:-test}" + + echo + for f in /docker-entrypoint-initdb.d/*; do + case "$f" in + *.sh) echo "$0: running $f"; . "$f" ;; + *.js) echo "$0: running $f"; "${mongo[@]}" "$MONGO_INITDB_DATABASE" "$f"; echo ;; + *) echo "$0: ignoring $f" ;; + esac + echo + done + + "${mongodHackedArgs[@]}" --shutdown + rm -f "$pidfile" + + echo + echo 'MongoDB init process complete; ready for start up.' + echo + fi + + # MongoDB 3.6+ defaults to localhost-only binding + haveBindIp= + if _mongod_hack_have_arg --bind_ip "$@" || _mongod_hack_have_arg --bind_ip_all "$@"; then + haveBindIp=1 + elif _parse_config "$@" && jq --exit-status '.net.bindIp // .net.bindIpAll' "$jsonConfigFile" > /dev/null; then + haveBindIp=1 + fi + if [ -z "$haveBindIp" ]; then + # so if no "--bind_ip" is specified, let's add "--bind_ip_all" + set -- "$@" --bind_ip_all + fi + + unset "${!MONGO_INITDB_@}" +fi + +rm -f "$jsonConfigFile" "$tempConfigFile" + +exec "$@" diff --git a/mongo/js-yaml.min.js b/mongo/js-yaml.min.js new file mode 100644 index 0000000000000000000000000000000000000000..0623500e6dc5b86d65f9fd918a0f15a2eaff44c3 --- /dev/null +++ b/mongo/js-yaml.min.js @@ -0,0 +1 @@ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).jsyaml=e()}}(function(){return function o(a,s,c){function u(t,e){if(!s[t]){if(!a[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(l)return l(t,!0);var i=new Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}var r=s[t]={exports:{}};a[t][0].call(r.exports,function(e){return u(a[t][1][e]||e)},r,r.exports,o,a,s,c)}return s[t].exports}for(var l="function"==typeof require&&require,e=0;e=i.flowLevel;switch(H(r,n,i.indent,t,function(e){return function(e,t){var n,i;for(n=0,i=e.implicitTypes.length;n"+V(r,i.indent)+Z(L(function(t,n){var e,i,r=/(\n+)([^\n]*)/g,o=function(){var e=t.indexOf("\n");return e=-1!==e?e:t.length,r.lastIndex=e,z(t.slice(0,e),n)}(),a="\n"===t[0]||" "===t[0];for(;i=r.exec(t);){var s=i[1],c=i[2];e=" "===c[0],o+=s+(a||e||""===c?"":"\n")+z(c,n),a=e}return o}(r,t),e));case $:return'"'+function(e){for(var t,n,i,r="",o=0;ot&&o tag resolver accepts not "'+c+'" style');i=s.represent[c](t,c)}e.dump=i}return!0}return!1}function Q(e,t,n,i,r,o){e.tag=null,e.dump=n,J(e,n,!1)||J(e,n,!0);var a=p.call(e.dump);i&&(i=e.flowLevel<0||e.flowLevel>t);var s,c,u="[object Object]"===a||"[object Array]"===a;if(u&&(c=-1!==(s=e.duplicates.indexOf(n))),(null!==e.tag&&"?"!==e.tag||c||2!==e.indent&&0 "+e.dump)}return!0}function X(e,t){var n,i,r=[],o=[];for(function e(t,n,i){var r,o,a;if(null!==t&&"object"==typeof t)if(-1!==(o=n.indexOf(t)))-1===i.indexOf(o)&&i.push(o);else if(n.push(t),Array.isArray(t))for(o=0,a=t.length;ot)&&0!==i)N(e,"bad indentation of a sequence entry");else if(e.lineIndentt?d=1:e.lineIndent===t?d=0:e.lineIndentt?d=1:e.lineIndent===t?d=0:e.lineIndentt)&&($(e,t,b,!0,r)&&(m?d=e.result:h=e.result),m||(U(e,l,p,f,d,h,o,a),f=d=h=null),Y(e,!0,-1),s=e.input.charCodeAt(e.position)),e.lineIndent>t&&0!==s)N(e,"bad indentation of a mapping entry");else if(e.lineIndentl&&(l=e.lineIndent),j(o))p++;else{if(e.lineIndent>10),56320+(c-65536&1023)),e.position++}else N(e,"unknown escape sequence");n=i=e.position}else j(s)?(L(e,n,i,!0),B(e,Y(e,!1,t)),n=i=e.position):e.position===e.lineStart&&R(e)?N(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}N(e,"unexpected end of the stream within a double quoted scalar")}(e,p)?m=!0:!function(e){var t,n,i;if(42!==(i=e.input.charCodeAt(e.position)))return!1;for(i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!I(i)&&!O(i);)i=e.input.charCodeAt(++e.position);return e.position===t&&N(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),e.anchorMap.hasOwnProperty(n)||N(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],Y(e,!0,-1),!0}(e)?function(e,t,n){var i,r,o,a,s,c,u,l,p=e.kind,f=e.result;if(I(l=e.input.charCodeAt(e.position))||O(l)||35===l||38===l||42===l||33===l||124===l||62===l||39===l||34===l||37===l||64===l||96===l)return!1;if((63===l||45===l)&&(I(i=e.input.charCodeAt(e.position+1))||n&&O(i)))return!1;for(e.kind="scalar",e.result="",r=o=e.position,a=!1;0!==l;){if(58===l){if(I(i=e.input.charCodeAt(e.position+1))||n&&O(i))break}else if(35===l){if(I(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&R(e)||n&&O(l))break;if(j(l)){if(s=e.line,c=e.lineStart,u=e.lineIndent,Y(e,!1,-1),e.lineIndent>=t){a=!0,l=e.input.charCodeAt(e.position);continue}e.position=o,e.line=s,e.lineStart=c,e.lineIndent=u;break}}a&&(L(e,r,o,!1),B(e,e.line-s),r=o=e.position,a=!1),S(l)||(o=e.position+1),l=e.input.charCodeAt(++e.position)}return L(e,r,o,!1),!!e.result||(e.kind=p,e.result=f,!1)}(e,p,x===n)&&(m=!0,null===e.tag&&(e.tag="?")):(m=!0,null===e.tag&&null===e.anchor||N(e,"alias node should not have any properties")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===d&&(m=s&&P(e,f))),null!==e.tag&&"!"!==e.tag)if("?"===e.tag){for(c=0,u=e.implicitTypes.length;c tag; it should be "'+l.kind+'", not "'+e.kind+'"'),l.resolve(e.result)?(e.result=l.construct(e.result),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):N(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):N(e,"unknown tag !<"+e.tag+">");return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||m}function H(e){var t,n,i,r,o=e.position,a=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};0!==(r=e.input.charCodeAt(e.position))&&(Y(e,!0,-1),r=e.input.charCodeAt(e.position),!(0t/2-1){n=" ... ",i+=5;break}for(r="",o=this.position;ot/2-1){r=" ... ",o-=5;break}return a=this.buffer.slice(i,o),s.repeat(" ",e)+n+a+r+"\n"+s.repeat(" ",e+this.position-i+n.length)+"^"},i.prototype.toString=function(e){var t,n="";return this.name&&(n+='in "'+this.name+'" '),n+="at line "+(this.line+1)+", column "+(this.column+1),e||(t=this.getSnippet())&&(n+=":\n"+t),n},t.exports=i},{"./common":2}],7:[function(e,t,n){"use strict";var i=e("./common"),r=e("./exception"),o=e("./type");function a(e,t,i){var r=[];return e.include.forEach(function(e){i=a(e,t,i)}),e[t].forEach(function(n){i.forEach(function(e,t){e.tag===n.tag&&e.kind===n.kind&&r.push(t)}),i.push(n)}),i.filter(function(e,t){return-1===r.indexOf(t)})}function s(e){this.include=e.include||[],this.implicit=e.implicit||[],this.explicit=e.explicit||[],this.implicit.forEach(function(e){if(e.loadKind&&"scalar"!==e.loadKind)throw new r("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=a(this,"implicit",[]),this.compiledExplicit=a(this,"explicit",[]),this.compiledTypeMap=function(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{}};function i(e){n[e.kind][e.tag]=n.fallback[e.tag]=e}for(e=0,t=arguments.length;e>16&255),s.push(a>>8&255),s.push(255&a)),a=a<<6|o.indexOf(i.charAt(t));return 0==(n=r%4*6)?(s.push(a>>16&255),s.push(a>>8&255),s.push(255&a)):18==n?(s.push(a>>10&255),s.push(a>>2&255)):12==n&&s.push(a>>4&255),c?c.from?c.from(s):new c(s):s},predicate:function(e){return c&&c.isBuffer(e)},represent:function(e){var t,n,i="",r=0,o=e.length,a=u;for(t=0;t>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]),r=(r<<8)+e[t];return 0==(n=o%3)?(i+=a[r>>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]):2==n?(i+=a[r>>10&63],i+=a[r>>4&63],i+=a[r<<2&63],i+=a[64]):1==n&&(i+=a[r>>2&63],i+=a[r<<4&63],i+=a[64],i+=a[64]),i}})},{"../type":13}],15:[function(e,t,n){"use strict";var i=e("../type");t.exports=new i("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})},{"../type":13}],16:[function(e,t,n){"use strict";var i=e("../common"),r=e("../type"),o=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var a=/^[-+]?[0-9]+e/;t.exports=new r("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!o.test(e)||"_"===e[e.length-1])},construct:function(e){var t,n,i,r;return n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,r=[],0<="+-".indexOf(t[0])&&(t=t.slice(1)),".inf"===t?1==n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:0<=t.indexOf(":")?(t.split(":").forEach(function(e){r.unshift(parseFloat(e,10))}),t=0,i=1,r.forEach(function(e){t+=e*i,i*=60}),n*t):n*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||i.isNegativeZero(e))},represent:function(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(i.isNegativeZero(e))return"-0.0";return n=e.toString(10),a.test(n)?n.replace("e",".e"):n},defaultStyle:"lowercase"})},{"../common":2,"../type":13}],17:[function(e,t,n){"use strict";var i=e("../common"),r=e("../type");t.exports=new r("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,i,r,o=e.length,a=0,s=!1;if(!o)return!1;if("-"!==(t=e[a])&&"+"!==t||(t=e[++a]),"0"===t){if(a+1===o)return!0;if("b"===(t=e[++a])){for(a++;a