-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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, used on our production infrastructure.
- Loading branch information
1 parent
d1f469c
commit 2df2801
Showing
1 changed file
with
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ LABEL maintainer="Justin Clift <[email protected]>" | |
RUN \ | ||
apk update && \ | ||
apk upgrade && \ | ||
apk add --no-cache ca-certificates 'curl>7.61.0' git go libc-dev memcached minio openrc postgresql sqlite-dev yarn && \ | ||
apk add --no-cache ca-certificates 'curl>7.61.0' file git go libc-dev make memcached minio openrc openssl openssl-dev postgresql yarn && \ | ||
apk add rabbitmq-server --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ && \ | ||
rc-update add memcached default && \ | ||
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 | |
echo "done" >> /usr/local/bin/start.sh && \ | ||
chmod +x /usr/local/bin/start.sh | ||
|
||
# Compile our own customised version of SQLite | ||
RUN echo "Downloading SQLite source code" && \ | ||
mkdir /sqlite && \ | ||
cd /sqlite && \ | ||
TARBALL=$(curl -s https://sqlite.org/download.html | awk '/<!--/,/-->/ {print}' | grep 'sqlite-autoconf' | cut -d ',' -f 3) && \ | ||
SHA3=$(curl -s https://sqlite.org/download.html | awk '/<!--/,/-->/ {print}' | grep 'sqlite-autoconf' | cut -d ',' -f 5) && \ | ||
curl -LsS -o sqlite.tar.gz https://sqlite.org/${TARBALL} && \ | ||
VERIFY=$(openssl dgst -sha3-256 sqlite.tar.gz | cut -d ' ' -f 2) && \ | ||
if [ "$SHA3" != "$VERIFY" ]; then exit 1 ; fi && \ | ||
if [ ! -f sqlite.tar.gz ]; then echo "Downloading the SQLite source code did not work" ; exit 3 ; fi && \ | ||
echo "Compiling local SQLite" && \ | ||
tar xfz sqlite.tar.gz && \ | ||
cd sqlite-autoconf-* || exit 4 && \ | ||
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 && \ | ||
make -j9 && \ | ||
make install && \ | ||
cd .. && \ | ||
rm -rf sqlite-autoconf-* && \ | ||
echo "/sqlite/lib:/lib:/usr/local/lib:/usr/lib" > /etc/ld-musl-x86_64.path | ||
|
||
# Create script to compile DBHub.io daemons | ||
RUN echo "cd ${DBHUB_SOURCE}" >> /usr/local/bin/compile.sh && \ | ||
echo "yarn" >> /usr/local/bin/compile.sh && \ | ||
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 && \ | ||
echo "yarn run webpack -c ${DBHUB_SOURCE}/webui/webpack.config.js" >> /usr/local/bin/compile.sh && \ | ||
echo "cd ${DBHUB_SOURCE}/api" >> /usr/local/bin/compile.sh && \ | ||
echo "go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-api ." >> /usr/local/bin/compile.sh && \ | ||
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 && \ | ||
echo "cd ${DBHUB_SOURCE}/db4s" >> /usr/local/bin/compile.sh && \ | ||
echo "go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-db4s ." >> /usr/local/bin/compile.sh && \ | ||
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 && \ | ||
echo "cd ${DBHUB_SOURCE}/live" >> /usr/local/bin/compile.sh && \ | ||
echo "go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-live ." >> /usr/local/bin/compile.sh && \ | ||
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 && \ | ||
echo "cd ${DBHUB_SOURCE}/webui" >> /usr/local/bin/compile.sh && \ | ||
echo "go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-webui ." >> /usr/local/bin/compile.sh && \ | ||
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 && \ | ||
echo "/usr/local/bin/restart.sh" >> /usr/local/bin/compile.sh && \ | ||
chmod +x /usr/local/bin/compile.sh | ||
|
||
|
2df2801
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MKleusberg You might need to rebuild your local Docker container (eg
yarn docker:build
) after pulling in this commit. 😉