Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Unified docker build shell script.

Kishore Nallan4c32dbfa0719
diff --git a/dockcross b/dockcross
deleted file mode 100755
index 536edd31..00000000
--- a/dockcross
+++ /dev/null
@@ -1,234 +0,0 @@
-#!/bin/bash
-
-DEFAULT_DOCKCROSS_IMAGE=dockcross/linux-x64
-
-#------------------------------------------------------------------------------
-# Helpers
-#
-err() {
- echo -e >&2 ERROR: $@\\n
-}
-
-die() {
- err $@
- exit 1
-}
-
-has() {
- # eg. has command update
- local kind=$1
- local name=$2
-
- type -t $kind:$name | grep -q function
-}
-
-#------------------------------------------------------------------------------
-# Command handlers
-#
-command:update-image() {
- docker pull $FINAL_IMAGE
-}
-
-help:update-image() {
- echo Pull the latest $FINAL_IMAGE .
-}
-
-command:update-script() {
- if cmp -s <( docker run --rm $FINAL_IMAGE ) $0; then
- echo $0 is up to date
- else
- echo -n Updating $0 '... '
- docker run --rm $FINAL_IMAGE > $0 && echo ok
- fi
-}
-
-help:update-image() {
- echo Update $0 from $FINAL_IMAGE .
-}
-
-command:update() {
- command:update-image
- command:update-script
-}
-
-help:update() {
- echo Pull the latest $FINAL_IMAGE, and then update $0 from that.
-}
-
-command:help() {
- if [[ $# != 0 ]]; then
- if ! has command $1; then
- err \"$1\" is not an dockcross command
- command:help
- elif ! has help $1; then
- err No help found for \"$1\"
- else
- help:$1
- fi
- else
- cat >&2 <<ENDHELP
-Usage: dockcross [options] [--] command [args]
-
-By default, run the given *command* in an dockcross Docker container.
-
-The *options* can be one of:
-
- --args|-a Extra args to the *docker run* command
- --image|-i Docker cross-compiler image to use
- --config|-c Bash script to source before running this script
-
-
-Additionally, there are special update commands:
-
- update-image
- update-script
- update
-
-For update command help use: $0 help <command>
-ENDHELP
- exit 1
- fi
-}
-
-#------------------------------------------------------------------------------
-# Option processing
-#
-special_update_command=''
-while [[ $# != 0 ]]; do
- case $1 in
-
- --)
- break
- ;;
-
- --args|-a)
- ARG_ARGS="$2"
- shift 2
- ;;
-
- --config|-c)
- ARG_CONFIG="$2"
- shift 2
- ;;
-
- --image|-i)
- ARG_IMAGE="$2"
- shift 2
- ;;
- update|update-image|update-script)
- special_update_command=$1
- break
- ;;
- -*)
- err Unknown option \"$1\"
- command:help
- exit
- ;;
-
- *)
- break
- ;;
-
- esac
-done
-
-# The precedence for options is:
-# 1. command-line arguments
-# 2. environment variables
-# 3. defaults
-
-# Source the config file if it exists
-DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
-FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
-
-[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
-
-# Set the docker image
-FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
-
-# Handle special update command
-if [ "$special_update_command" != "" ]; then
- case $special_update_command in
-
- update)
- command:update
- exit $?
- ;;
-
- update-image)
- command:update-image
- exit $?
- ;;
-
- update-script)
- command:update-script
- exit $?
- ;;
-
- esac
-fi
-
-# Set the docker run extra args (if any)
-FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
-
-# Bash on Ubuntu on Windows
-UBUNTU_ON_WINDOWS=$([ -e /proc/version ] && grep -l Microsoft /proc/version || echo "")
-# MSYS, Git Bash, etc.
-MSYS=$([ -e /proc/version ] && grep -l MINGW /proc/version || echo "")
-
-if [ -z "$UBUNTU_ON_WINDOWS" -a -z "$MSYS" ]; then
- USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )"
-fi
-
-# Change the PWD when working in Docker on Windows
-if [ -n "$UBUNTU_ON_WINDOWS" ]; then
- HOST_PWD=$PWD
- HOST_PWD=${HOST_PWD/\/mnt\//}
- HOST_PWD=${HOST_PWD/\//:\/}
-elif [ -n "$MSYS" ]; then
- HOST_PWD=$PWD
- HOST_PWD=${HOST_PWD/\//}
- HOST_PWD=${HOST_PWD/\//:\/}
-else
- HOST_PWD=$PWD
-fi
-
-#------------------------------------------------------------------------------
-# Now, finally, run the command in a container
-#
-tty -s && TTY_ARGS=-ti || TTY_ARGS=
-CONTAINER_NAME=dockcross_$RANDOM
-docker run $TTY_ARGS --name $CONTAINER_NAME \
- -v "$HOST_PWD":/work \
- $USER_IDS \
- $FINAL_ARGS \
- $FINAL_IMAGE "$@"
-run_exit_code=$?
-
-# Attempt to delete container
-rm_output=$(docker rm -f $CONTAINER_NAME 2>&1)
-rm_exit_code=$?
-if [[ $rm_exit_code != 0 ]]; then
- if [[ "$CIRCLECI" == "true" ]] && [[ $rm_output == *"Driver btrfs failed to remove"* ]]; then
- : # Ignore error because of https://circleci.com/docs/docker-btrfs-error/
- else
- echo "$rm_output"
- exit $rm_exit_code
- fi
-fi
-
-exit $run_exit_code
-
-################################################################################
-#
-# This image is not intended to be run manually.
-#
-# To create a dockcross helper script for the
-# dockcross/linux-armv7 image, run:
-#
-# docker run --rm dockcross/linux-armv7 > dockcross-linux-armv7
-# chmod +x dockcross-linux-armv7
-#
-# You may then wish to move the dockcross script to your PATH.
-#
-################################################################################
diff --git a/docker-build.sh b/docker-build.sh
index 02df235a..73f7a22d 100755
--- a/docker-build.sh
+++ b/docker-build.sh
@@ -1,17 +1,37 @@
#!/bin/sh
-set -o xtrace
-PROJECT_DIR=`dirname $0`
+set -ex
+PROJECT_DIR=`dirname $0 | while read a; do cd $a && pwd && break; done`
-if [ "$1" = "--clean" ]; then
+if [[ "$@" == *"--clean"* ]]; then
+ echo "Cleaning..."
rm -rf $PROJECT_DIR/build
mkdir $PROJECT_DIR/build
+fi
- # rm -rf $PROJECT_DIR/external
- # DOCKER_NO_CACHE=" --no-cache"
+if [[ "$@" == *"--depclean"* ]]; then
+ echo "Cleaning dependencies..."
+ rm -rf $PROJECT_DIR/external
fi
-docker build --file $PROJECT_DIR/docker/development.Dockerfile --tag wreally/typesense-development $DOCKER_NO_CACHE $PROJECT_DIR/docker
+echo "Creating development image..."
+docker build --file $PROJECT_DIR/docker/development.Dockerfile --tag wreally/typesense-development:latest $PROJECT_DIR/docker
+
+echo "Building Typesense..."
+docker run -v $PROJECT_DIR:/typesense wreally/typesense-development cmake -H/typesense -B/typesense/build
+docker run -v $PROJECT_DIR:/typesense wreally/typesense-development make -C/typesense/build
+
+if [[ "$@" == *"--build-deploy-image"* ]]; then
+ echo "Creating deployment image for Typesense server..."
+
+ if [ -z "$TYPESENSE_IMG_VERSION" ]; then
+ echo "Need to set TYPESENSE_IMG_VERSION environment variable."
+ exit 1
+ fi
+
+ cp $PROJECT_DIR/docker/deployment.Dockerfile $PROJECT_DIR/build
+ docker build --file $PROJECT_DIR/build/deployment.Dockerfile --tag wreally/typesense-server:$TYPESENSE_IMG_VERSION \
+ $PROJECT_DIR/build
+fi
-./dockcross --image wreally/typesense-development cmake -H$PROJECT_DIR -B$PROJECT_DIR/build
-./dockcross --image wreally/typesense-development make -C $PROJECT_DIR/build
\ No newline at end of file
+echo "Done... quitting."
\ No newline at end of file
diff --git a/docker/build.Dockerfile b/docker/build.Dockerfile
deleted file mode 100644
index 37bd5110..00000000
--- a/docker/build.Dockerfile
+++ /dev/null
@@ -1,28 +0,0 @@
-FROM ubuntu:12.04
-
-RUN apt-get update
-RUN apt-get install -y build-essential
-RUN apt-get install -y python-software-properties
-RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
-RUN apt-get update
-
-RUN apt-get install -y gcc-4.9
-RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50
-RUN apt-get install -y g++-4.9
-RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 50
-
-RUN apt-get install -y zlib1g-dev
-RUN apt-get install -y liblist-compare-perl
-RUN apt-get install -y wget
-RUN wget https://openssl.org/source/openssl-1.0.2k.tar.gz -P /opt
-RUN tar -C /opt -xvzf /opt/openssl-1.0.2k.tar.gz
-RUN cd /opt/openssl-1.0.2k && sh ./config --prefix=/usr --openssldir=/usr zlib-dynamic
-RUN make -C /opt/openssl-1.0.2k depend
-RUN make -C /opt/openssl-1.0.2k -j4
-RUN make -C /opt/openssl-1.0.2k install
-
-RUN apt-get install -y libsnappy-dev
-
-RUN wget http://www.cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz -P /opt
-RUN tar -C /opt -xvzf /opt/cmake-3.3.2-Linux-x86_64.tar.gz
-RUN cp -r /opt/cmake-3.3.2-Linux-x86_64/* /usr
\ No newline at end of file
diff --git a/docker/deployment.Dockerfile b/docker/deployment.Dockerfile
new file mode 100644
index 00000000..be92a5e6
--- /dev/null
+++ b/docker/deployment.Dockerfile
@@ -0,0 +1,7 @@
+FROM ubuntu:16.04
+
+RUN mkdir -p /opt
+COPY typesense-server /opt
+RUN chmod +x /opt/typesense-server
+EXPOSE 8108
+ENTRYPOINT ["/opt/typesense-server"]
\ No newline at end of file
diff --git a/docker/development.Dockerfile b/docker/development.Dockerfile
index 33e47d69..37bd5110 100644
--- a/docker/development.Dockerfile
+++ b/docker/development.Dockerfile
@@ -1,10 +1,28 @@
-FROM dockcross/linux-x64
+FROM ubuntu:12.04
-# Required for OpenSSL 1.0.2+
-RUN echo "deb http://ftp.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backport.list
RUN apt-get update
+RUN apt-get install -y build-essential
+RUN apt-get install -y python-software-properties
+RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
+RUN apt-get update
+
+RUN apt-get install -y gcc-4.9
+RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50
+RUN apt-get install -y g++-4.9
+RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 50
-RUN apt-get install -y -t jessie-backports openssl
-RUN apt-get install -y -t jessie-backports libssl-dev
RUN apt-get install -y zlib1g-dev
-RUN apt-get install -y libsnappy-dev
\ No newline at end of file
+RUN apt-get install -y liblist-compare-perl
+RUN apt-get install -y wget
+RUN wget https://openssl.org/source/openssl-1.0.2k.tar.gz -P /opt
+RUN tar -C /opt -xvzf /opt/openssl-1.0.2k.tar.gz
+RUN cd /opt/openssl-1.0.2k && sh ./config --prefix=/usr --openssldir=/usr zlib-dynamic
+RUN make -C /opt/openssl-1.0.2k depend
+RUN make -C /opt/openssl-1.0.2k -j4
+RUN make -C /opt/openssl-1.0.2k install
+
+RUN apt-get install -y libsnappy-dev
+
+RUN wget http://www.cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz -P /opt
+RUN tar -C /opt -xvzf /opt/cmake-3.3.2-Linux-x86_64.tar.gz
+RUN cp -r /opt/cmake-3.3.2-Linux-x86_64/* /usr
\ No newline at end of file