fixed build scripts for running on apple silicone, refreshed base docker images

This commit is contained in:
or-else
2021-11-17 18:04:17 -08:00
parent e4208c97d0
commit 5ad40d9039
6 changed files with 68 additions and 79 deletions
+50 -69
View File
@@ -40,24 +40,62 @@ pushd ${GOSRC}/chat > /dev/null
rm -fR ./releases/${version}
mkdir ./releases/${version}
# Tar on Mac is inflexible about directories. Let's just copy release files to
# one directory.
rm -fR ./releases/tmp
mkdir -p ./releases/tmp/templ
# Copy templates and database initialization files
cp ./server/tinode.conf ./releases/tmp
cp ./server/templ/*.templ ./releases/tmp/templ
cp ./tinode-db/data.json ./releases/tmp
cp ./tinode-db/*.jpg ./releases/tmp
cp ./tinode-db/credentials.sh ./releases/tmp
# Create directories for and copy TinodeWeb files.
if [[ -d ./server/static ]]
then
mkdir -p ./releases/tmp/static/img
mkdir ./releases/tmp/static/css
mkdir ./releases/tmp/static/audio
mkdir ./releases/tmp/static/src
mkdir ./releases/tmp/static/umd
cp ./server/static/img/*.png ./releases/tmp/static/img
cp ./server/static/img/*.svg ./releases/tmp/static/img
cp ./server/static/audio/*.mp3 ./releases/tmp/static/audio
cp ./server/static/css/*.css ./releases/tmp/static/css
cp ./server/static/index.html ./releases/tmp/static
cp ./server/static/index-dev.html ./releases/tmp/static
cp ./server/static/version.js ./releases/tmp/static
cp ./server/static/umd/*.js ./releases/tmp/static/umd
cp ./server/static/manifest.json ./releases/tmp/static
cp ./server/static/service-worker.js ./releases/tmp/static
# Create empty FCM client-side config.
touch ./releases/tmp/static/firebase-init.js
else
echo "TinodeWeb not found, skipping"
fi
for (( i=0; i<${buildCount}; i++ ));
do
plat="${goplat[$i]}"
arc="${goarc[$i]}"
# Remove possibly existing keygen.
rm -f ./releases/tmp/keygen*
# Keygen is database-independent
# Remove previous build
rm -f $GOPATH/bin/keygen
# Build
env GOOS="${plat}" GOARCH="${arc}" go build -ldflags "-s -w" -o $GOPATH/bin/keygen ./keygen > /dev/null
env GOOS="${plat}" GOARCH="${arc}" go build -ldflags "-s -w" -o ./releases/tmp ./keygen > /dev/null
for dbtag in "${dbtags[@]}"
do
echo "Building ${dbtag}-${plat}/${arc}..."
# Remove previous builds
rm -f $GOPATH/bin/tinode
rm -f $GOPATH/bin/init-db
# Remove possibly existing binaries from earlier builds.
rm -f ./releases/tmp/tinode*
rm -f ./releases/tmp/init-db*
# Build tinode server and database initializer for RethinkDb and MySQL.
# For 'alldbs' tag, we compile in all available DB adapters.
if [ "$dbtag" = "alldbs" ]; then
@@ -65,56 +103,15 @@ do
else
buildtag=$dbtag
fi
env GOOS="${plat}" GOARCH="${arc}" go build \
-ldflags "-s -w -X main.buildstamp=`git describe --tags`" -tags "${buildtag}" \
-o $GOPATH/bin/tinode ./server > /dev/null
-o ./releases/tmp/tinode ./server > /dev/null
env GOOS="${plat}" GOARCH="${arc}" go build \
-ldflags "-s -w" -tags "${buildtag}" -o $GOPATH/bin/init-db ./tinode-db > /dev/null
# Tar on Mac is inflexible about directories. Let's just copy release files to
# one directory.
rm -fR ./releases/tmp
mkdir -p ./releases/tmp/templ
# Copy templates and database initialization files
cp ./server/tinode.conf ./releases/tmp
cp ./server/templ/*.templ ./releases/tmp/templ
cp ./tinode-db/data.json ./releases/tmp
cp ./tinode-db/*.jpg ./releases/tmp
cp ./tinode-db/credentials.sh ./releases/tmp
# Create directories for and copy TinodeWeb files.
if [[ -d ./server/static ]]
then
mkdir -p ./releases/tmp/static/img
mkdir ./releases/tmp/static/css
mkdir ./releases/tmp/static/audio
mkdir ./releases/tmp/static/src
mkdir ./releases/tmp/static/umd
cp ./server/static/img/*.png ./releases/tmp/static/img
cp ./server/static/img/*.svg ./releases/tmp/static/img
cp ./server/static/audio/*.mp3 ./releases/tmp/static/audio
cp ./server/static/css/*.css ./releases/tmp/static/css
cp ./server/static/index.html ./releases/tmp/static
cp ./server/static/index-dev.html ./releases/tmp/static
cp ./server/static/version.js ./releases/tmp/static
cp ./server/static/umd/*.js ./releases/tmp/static/umd
cp ./server/static/manifest.json ./releases/tmp/static
cp ./server/static/service-worker.js ./releases/tmp/static
# Create empty FCM client-side config.
echo > ./releases/tmp/static/firebase-init.js
else
echo "TinodeWeb not found, skipping"
fi
-ldflags "-s -w" -tags "${buildtag}" -o ./releases/tmp/init-db ./tinode-db > /dev/null
# Build archive. All platforms but Windows use tar for archiving. Windows uses zip.
if [ "$plat" = "windows" ]; then
# Copy binaries
cp $GOPATH/bin/tinode.exe ./releases/tmp
cp $GOPATH/bin/init-db.exe ./releases/tmp
cp $GOPATH/bin/keygen.exe ./releases/tmp
# Remove possibly existing archive.
rm -f ./releases/${version}/tinode-${dbtag}."${plat}-${arc}".zip
# Generate a new one
@@ -127,31 +124,15 @@ do
if [ "$plat" = "darwin" ]; then
plat2=mac
fi
# Copy binaries
cp $GOPATH/bin/tinode ./releases/tmp
cp $GOPATH/bin/init-db ./releases/tmp
cp $GOPATH/bin/keygen ./releases/tmp
# Remove possibly existing archive.
rm -f ./releases/${version}/tinode-${dbtag}."${plat2}-${arc}".tar.gz
# Generate a new one
tar -C ${GOSRC}/chat/releases/tmp -zcf ./releases/${version}/tinode-${dbtag}."${plat2}-${arc}".tar.gz .
tar -C ./releases/tmp -zcf ./releases/${version}/tinode-${dbtag}."${plat2}-${arc}".tar.gz .
fi
done
done
# Need to rebuild the linux-rethink binary without stripping debug info.
echo "Building the binary for web.tinode.co"
rm -f $GOPATH/bin/tinode
rm -f $GOPATH/bin/init-db
gox -osarch=linux/amd64 \
-ldflags "-X main.buildstamp=`git describe --tags`" \
-tags rethinkdb -output $GOPATH/bin/tinode ./server > /dev/null
gox -osarch=linux/amd64 \
-tags rethinkdb -output $GOPATH/bin/init-db ./tinode-db > /dev/null
# Build chatbot release
echo "Building python code..."
@@ -178,7 +159,7 @@ rm -fR ./releases/tmp
mkdir -p ./releases/tmp
cp ${GOSRC}/chat/tn-cli/*.py ./releases/tmp
cp ${GOSRC}/chat/tn-cli/requirements.txt ./releases/tmp
cp ${GOSRC}/chat/tn-cli/*.txt ./releases/tmp
tar -C ${GOSRC}/chat/releases/tmp -zcf ./releases/${version}/tn-cli.tar.gz .
pushd ./releases/tmp > /dev/null
+12 -4
View File
@@ -1,6 +1,8 @@
#!/bin/bash
# Build Tinode docker images
# Build Tinode docker linux/amd64 images.
# You may have to install buildx https://docs.docker.com/buildx/working-with-buildx/
# if your build host and target architectures are different (e.g. building on a Mac with Apple silicon).
for line in $@; do
eval "$line"
@@ -21,6 +23,12 @@ if [[ ${ver[2]} != *"-"* ]]; then
FULLRELEASE=1
fi
# Use buildx if the current platform is not x86.
buildcmd='build'
if [ `uname -m` != 'x86_64' ]; then
buildcmd='buildx build --platform=linux/amd64'
fi
dbtags=( mysql mongodb rethinkdb alldbs )
# Build an images for various DB backends
@@ -41,7 +49,7 @@ do
buildtags="${buildtags} --tag ${name}:latest --tag ${name}:${ver[0]}.${ver[1]}"
fi
docker rmi ${rmitags}
docker build --build-arg VERSION=$tag --build-arg TARGET_DB=${dbtag} ${buildtags} docker/tinode
docker ${buildcmd} --build-arg VERSION=$tag --build-arg TARGET_DB=${dbtag} ${buildtags} docker/tinode
done
# Build chatbot image
@@ -52,7 +60,7 @@ if [ -n "$FULLRELEASE" ]; then
buildtags="${buildtags} --tag tinode/chatbot:latest --tag tinode/chatbot:${ver[0]}.${ver[1]}"
fi
docker rmi ${rmitags}
docker build --build-arg VERSION=$tag ${buildtags} docker/chatbot
docker ${buildcmd} --build-arg VERSION=$tag ${buildtags} docker/chatbot
# Build exporter image
buildtags="--tag tinode/exporter:${ver[0]}.${ver[1]}.${ver[2]}"
@@ -62,4 +70,4 @@ if [ -n "$FULLRELEASE" ]; then
buildtags="${buildtags} --tag tinode/exporter:latest --tag tinode/exporter:${ver[0]}.${ver[1]}"
fi
docker rmi ${rmitags}
docker build --build-arg VERSION=$tag ${buildtags} docker/exporter
docker ${buildcmd} --build-arg VERSION=$tag ${buildtags} docker/exporter
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/bash
# Publish Tinode docker images
# Publish Tinode docker images to hub.docker.com
function containerName() {
if [ "$1" == "alldbs" ]; then
+2 -2
View File
@@ -1,8 +1,8 @@
# Dockerfile builds an image with a chatbot (Tino) for Tinode.
FROM python:3.8-slim
FROM python:3.10-slim
ARG VERSION=0.16
ARG VERSION=0.18
ARG LOGIN_AS=
ARG TINODE_HOST=tinode-srv:16060
ENV VERSION=$VERSION
+1 -1
View File
@@ -1,4 +1,4 @@
FROM alpine:3.12
FROM alpine:3.14
ARG VERSION=0.16.4
ENV VERSION=$VERSION
+2 -2
View File
@@ -9,9 +9,9 @@
# --env AUTH_TOKEN_KEY=base64+encoded+32+bytes \
# tinode-server
FROM alpine:3.13
FROM alpine:3.14
ARG VERSION=0.17
ARG VERSION=0.18
ENV VERSION=$VERSION
ARG BINVERS=$VERSION