Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 7bb0c9c

Browse files
committed
build: Use a custom build of SQLite in the docker container
Instead of using the Alpine linux packaged SQLite, we now build our own SQLite library for the DBHub.io daemons to use. This lets us match the SQLite version, and SQLite extensions, which used on our production infrastructure.
1 parent d1f469c commit 7bb0c9c

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

docker/Dockerfile

+25-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LABEL maintainer="Justin Clift <[email protected]>"
77
RUN \
88
apk update && \
99
apk upgrade && \
10-
apk add --no-cache ca-certificates 'curl>7.61.0' git go libc-dev memcached minio openrc postgresql sqlite-dev yarn && \
10+
apk add --no-cache ca-certificates 'curl>7.61.0' file git go libc-dev make memcached minio openrc openssl openssl-dev postgresql yarn && \
1111
apk add rabbitmq-server --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ && \
1212
rc-update add memcached default && \
1313
rc-update add minio default && \
@@ -75,19 +75,39 @@ RUN echo "echo 127.0.0.1 docker-dev.dbhub.io docker-dev >> /etc/hosts" >> /usr/l
7575
echo "done" >> /usr/local/bin/start.sh && \
7676
chmod +x /usr/local/bin/start.sh
7777

78+
# Compile our own customised version of SQLite
79+
RUN echo "Downloading SQLite source code" && \
80+
mkdir /sqlite && \
81+
cd /sqlite && \
82+
TARBALL=$(curl -s https://sqlite.org/download.html | awk '/<!--/,/-->/ {print}' | grep 'sqlite-autoconf' | cut -d ',' -f 3) && \
83+
SHA3=$(curl -s https://sqlite.org/download.html | awk '/<!--/,/-->/ {print}' | grep 'sqlite-autoconf' | cut -d ',' -f 5) && \
84+
curl -LsS -o sqlite.tar.gz https://sqlite.org/${TARBALL} && \
85+
VERIFY=$(openssl dgst -sha3-256 sqlite.tar.gz | cut -d ' ' -f 2) && \
86+
if [ "$SHA3" != "$VERIFY" ]; then exit 1 ; fi && \
87+
if [ ! -f sqlite.tar.gz ]; then echo "Downloading the SQLite source code did not work" ; exit 3 ; fi && \
88+
echo "Compiling local SQLite" && \
89+
tar xfz sqlite.tar.gz && \
90+
cd sqlite-autoconf-* || exit 4 && \
91+
CPPFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_MAX_VARIABLE_NUMBER=250000 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_STAT4=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_SOUNDEX=1 -DSQLITE_ENABLE_MATH_FUNCTIONS=1 -DSQLITE_MAX_ATTACHED=125 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 -DSQLITE_ENABLE_SNAPSHOT=1" ./configure --prefix=/sqlite --enable-dynamic-extensions=no && \
92+
make -j9 && \
93+
make install && \
94+
cd .. && \
95+
rm -rf sqlite-autoconf-* && \
96+
echo "/sqlite/lib:/lib:/usr/local/lib:/usr/lib" > /etc/ld-musl-x86_64.path
97+
7898
# Create script to compile DBHub.io daemons
7999
RUN echo "cd ${DBHUB_SOURCE}" >> /usr/local/bin/compile.sh && \
80100
echo "yarn" >> /usr/local/bin/compile.sh && \
81101
echo "yarn run babel ${DBHUB_SOURCE}/webui/jsx --out-dir ${DBHUB_SOURCE}/webui/js --presets babel-preset-react-app/prod" >> /usr/local/bin/compile.sh && \
82102
echo "yarn run webpack -c ${DBHUB_SOURCE}/webui/webpack.config.js" >> /usr/local/bin/compile.sh && \
83103
echo "cd ${DBHUB_SOURCE}/api" >> /usr/local/bin/compile.sh && \
84-
echo "go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-api ." >> /usr/local/bin/compile.sh && \
104+
echo "PKG_CONFIG_PATH=/sqlite/lib/pkgconfig go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-api ." >> /usr/local/bin/compile.sh && \
85105
echo "cd ${DBHUB_SOURCE}/db4s" >> /usr/local/bin/compile.sh && \
86-
echo "go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-db4s ." >> /usr/local/bin/compile.sh && \
106+
echo "PKG_CONFIG_PATH=/sqlite/lib/pkgconfig go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-db4s ." >> /usr/local/bin/compile.sh && \
87107
echo "cd ${DBHUB_SOURCE}/live" >> /usr/local/bin/compile.sh && \
88-
echo "go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-live ." >> /usr/local/bin/compile.sh && \
108+
echo "PKG_CONFIG_PATH=/sqlite/lib/pkgconfig go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-live ." >> /usr/local/bin/compile.sh && \
89109
echo "cd ${DBHUB_SOURCE}/webui" >> /usr/local/bin/compile.sh && \
90-
echo "go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-webui ." >> /usr/local/bin/compile.sh && \
110+
echo "PKG_CONFIG_PATH=/sqlite/lib/pkgconfig go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-webui ." >> /usr/local/bin/compile.sh && \
91111
echo "/usr/local/bin/restart.sh" >> /usr/local/bin/compile.sh && \
92112
chmod +x /usr/local/bin/compile.sh
93113

0 commit comments

Comments
 (0)