Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 23 additions & 31 deletions build-custom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ set -ex

### builds custom image for makeomatic purposes
# usage "./build-custom.sh tag=v0.15.9"
goplat=( linux )
goarc=( amd64 )
goplat=( $TARGETOS )
goarc=( $TARGETARCH )
dbtags=( mongodb )
releasepath="./docker/tinode/releases"
repository="gcr.io/peak-orbit-214114"

export GOPATH=`go env GOPATH`

Expand All @@ -18,6 +16,8 @@ done

version=${tag#?}
push=${push:-true}
releasepath=${releasepath:-"./docker/tinode/releases"}
repository=${repository:-"gcr.io/peak-orbit-214114"}

if [ -z "$version" ]; then
echo "Must provide tag as 'tag=v1.2.3'"
Expand All @@ -33,9 +33,6 @@ git submodule update --init --recursive
rm -fR ${releasepath}/${version}
mkdir -p ${releasepath}/${version}

if [[ ! -x "$GOPATH/bin/gox" ]]; then
go get github.com/mitchellh/gox
fi

for plat in "${goplat[@]}"
do
Expand All @@ -46,10 +43,10 @@ do
rm -f $GOPATH/bin/keygen

# Build
$GOPATH/bin/gox -osarch="${plat}/${arc}" \
env GOOS=${plat} GOARCH=${arc} go build -o $GOPATH/bin/keygen \
-ldflags "-s -w -extldflags \"-fno-PIC -static\"" \
-tags 'osusergo netgo static_build' \
-output $GOPATH/bin/keygen ./keygen > /dev/null
./keygen > /dev/null

for dbtag in "${dbtags[@]}"
do
Expand All @@ -61,15 +58,15 @@ do
rm -f $GOPATH/bin/init-db

# Build tinode server and database initializer for RethinkDb and MySQL.
$GOPATH/bin/gox -osarch="${plat}/${arc}" \
env GOOS=${plat} GOARCH=${arc} CGO_ENABLED=1 go build -o $GOPATH/bin/tinode -race \
-ldflags "-s -w -extldflags \"-fno-PIC -static\" -X main.buildstamp=${version}" \
-tags "${dbtag} osusergo netgo static_build" \
-output $GOPATH/bin/tinode ./server > /dev/null
./server > /dev/null

$GOPATH/bin/gox -osarch="${plat}/${arc}" \
env GOOS=${plat} GOARCH=${arc} go build \
-ldflags "-s -w -extldflags \"-fno-PIC -static\"" \
-tags "${dbtag} osusergo netgo static_build" \
-output $GOPATH/bin/init-db ./tinode-db > /dev/null
-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.
Expand Down Expand Up @@ -100,37 +97,32 @@ do
cp ./tinode-db/credentials.sh ${tmppath}

# Build archive. All platforms but Windows use tar for archiving. Windows uses zip.
plat2=$plat
# Rename 'darwin' tp 'mac'
if [ "$plat" = "darwin" ]; then
plat2=mac
fi
# Copy binaries
cp $GOPATH/bin/tinode ${tmppath}
cp $GOPATH/bin/init-db ${tmppath}
cp $GOPATH/bin/keygen ${tmppath}

# Remove possibly existing archive.
rm -f ${releasepath}/${version}/tinode-${dbtag}."${plat2}-${arc}".tar.gz
rm -f ${releasepath}/${version}/tinode-${dbtag}."${plat}-${arc}".tar.gz
# Generate a new one
tar -C ${tmppath} -zcf ${releasepath}/${version}/tinode-${dbtag}."${plat2}-${arc}".tar.gz .
tar -C ${tmppath} -zcf ${releasepath}/${version}/tinode-${dbtag}."${plat}-${arc}".tar.gz .

rm -fR ${tmppath}
done
done
done

for dbtag in "${dbtags[@]}"
do
rmitags="${repository}/tinode-${dbtag}:${version}"
# for dbtag in "${dbtags[@]}"
# do
# rmitags="${repository}/tinode-${dbtag}:${version}"

if [ x"$push" = x"true" ]; then
docker rmi ${rmitags} -f
fi
# if [ x"$push" = x"true" ]; then
# docker rmi ${rmitags} -f
# fi

docker build --build-arg VERSION=$version --build-arg TARGET_DB=${dbtag} --tag ${rmitags} docker/tinode
# docker build --build-arg VERSION=$version --build-arg TARGET_DB=${dbtag} --tag ${rmitags} docker/tinode

if [ x"$push" = x"true" ]; then
docker push $rmitags
fi
done
# if [ x"$push" = x"true" ]; then
# docker push $rmitags
# fi
# done
37 changes: 25 additions & 12 deletions docker/tinode/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# syntax=docker/dockerfile:1

FROM golang:1.21-alpine as build

ARG TARGETARCH
ARG TARGETOS
ARG VERSION

WORKDIR /src
COPY . .

RUN apk --update --upgrade add bash git gcc musl-dev \
&& ./build-custom.sh tag=v${VERSION} push=false releasepath=/src/releases

# Docker file builds an image with a tinode chat server.
#
# In order to run the image you have to link it to a running database container. For example, to
Expand All @@ -9,12 +23,15 @@
# --env AUTH_TOKEN_KEY=base64+encoded+32+bytes \
# tinode-server

FROM alpine:3.17
FROM alpine:3.19

ARG TARGETARCH
ARG TARGETOS
ARG VERSION=0.21
ENV VERSION=$VERSION
ARG BINVERS=$VERSION

ENV VERSION=$VERSION

LABEL maintainer="Tinode Team <[email protected]>"
LABEL name="TinodeChatServer"
LABEL version=$VERSION
Expand Down Expand Up @@ -127,22 +144,18 @@ RUN apk update && \
WORKDIR /opt/tinode

# Get the desired Tinode build.
ADD ./releases/$VERSION .
COPY --from=build /src/releases/$VERSION .

# Unpack the Tinode archive.
RUN tar -xzf tinode-$TARGET_DB.linux-amd64.tar.gz \
&& rm tinode-$TARGET_DB.linux-amd64.tar.gz
RUN tar -xzf tinode-$TARGET_DB.${TARGETOS}-${TARGETARCH}.tar.gz \
&& rm tinode-$TARGET_DB.${TARGETOS}-${TARGETARCH}.tar.gz \
&& mkdir /botdata

# Copy config template to the container.
COPY config.template .
COPY entrypoint.sh .

# Create directory for chatbot data.
RUN mkdir /botdata
COPY --from=build /src/docker/tinode/config.template /src/docker/tinode/entrypoint.sh ./

# Make scripts runnable
RUN chmod +x entrypoint.sh
RUN chmod +x credentials.sh
RUN chmod +x entrypoint.sh credentials.sh

# Generate config from template and run the server.
ENTRYPOINT ./entrypoint.sh
Expand Down
91 changes: 67 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,34 +1,77 @@
module github.com/tinode/chat

go 1.16
go 1.21

require (
cloud.google.com/go v0.102.0 // indirect
cloud.google.com/go/firestore v1.6.1 // indirect
firebase.google.com/go v3.13.0+incompatible
github.com/aws/aws-sdk-go v1.33.0
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/go-sql-driver/mysql v1.6.0
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/aws/aws-sdk-go v1.49.23
github.com/go-sql-driver/mysql v1.7.1
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.5.8
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/handlers v1.5.1
github.com/gorilla/websocket v1.5.0
github.com/google/go-cmp v0.6.0
github.com/gorilla/handlers v1.5.2
github.com/gorilla/websocket v1.5.1
github.com/jmoiron/sqlx v1.3.5
github.com/nyaruka/phonenumbers v1.0.75
github.com/prometheus/client_golang v1.12.2
github.com/prometheus/common v0.34.0
github.com/nyaruka/phonenumbers v1.3.0
github.com/prometheus/client_golang v1.18.0
github.com/prometheus/common v0.46.0
github.com/tinode/jsonco v1.0.0
github.com/tinode/snowflake v1.0.0
go.mongodb.org/mongo-driver v1.9.1
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
golang.org/x/net v0.0.0-20220526153639-5463443f8c37
golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401
golang.org/x/text v0.3.7
google.golang.org/api v0.81.0
google.golang.org/genproto v0.0.0-20220526192754-51939a95c655 // indirect
google.golang.org/grpc v1.46.2
google.golang.org/protobuf v1.28.0
gopkg.in/rethinkdb/rethinkdb-go.v6 v6.2.1
go.mongodb.org/mongo-driver v1.13.1
golang.org/x/crypto v0.18.0
golang.org/x/net v0.20.0
golang.org/x/oauth2 v0.16.0
golang.org/x/text v0.14.0
google.golang.org/api v0.156.0
google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.32.0
gopkg.in/rethinkdb/rethinkdb-go.v6 v6.2.2
)

require (
cloud.google.com/go v0.112.0 // indirect
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/firestore v1.14.0 // indirect
cloud.google.com/go/iam v1.1.5 // indirect
cloud.google.com/go/longrunning v0.5.4 // indirect
cloud.google.com/go/storage v1.36.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.22.0 // indirect
go.opentelemetry.io/otel/metric v1.22.0 // indirect
go.opentelemetry.io/otel/trace v1.22.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240116215550-a9fa1716bcac // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect
gopkg.in/cenkalti/backoff.v2 v2.2.1 // indirect
)
Loading