diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fc9ed9e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +FROM golang:alpine as builder + +RUN apk add --no-cache \ + gperf \ + alpine-sdk \ + openssl-dev \ + git \ + cmake \ + zlib-dev \ + linux-headers + +WORKDIR /tmp/_build_tdlib/ + +RUN git clone https://github.com/tdlib/td.git /tmp/_build_tdlib/ + +RUN mkdir build +WORKDIR /tmp/_build_tdlib/build/ + +RUN cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr/local .. +RUN make -j13 +RUN cmake --build . --target install +RUN make install + +ARG COMMIT=latest + +WORKDIR /app/ + +RUN GOBIN=/app/ go install git.siteop.biz/chtwrs/gocw2@$COMMIT + +FROM alpine:latest + +RUN apk add --no-cache \ + libstdc++ + +WORKDIR /app/ + +# Copy the Pre-built binary file from the previous stage +COPY --from=builder /app/gocw2 . +# Command to run the executable +CMD ["./gocw2"] diff --git a/generate.go b/generate.go new file mode 100644 index 0000000..8b92de7 --- /dev/null +++ b/generate.go @@ -0,0 +1,3 @@ +package main + +//go:generate bash ./version.sh diff --git a/main.go b/main.go index 0248d66..0374f6d 100644 --- a/main.go +++ b/main.go @@ -32,7 +32,6 @@ var ( history = flag.Bool("history", false, "initialize chat history") historyChatID64 = flag.Int64("chat_id", 0, "chat to historize") historySenderUserID64 = flag.Int64("sender_user_id", 0, "sender_user_id to historize") - githash = "unknown" cfg Config diff --git a/version.go b/version.go new file mode 100644 index 0000000..a3cbbcb --- /dev/null +++ b/version.go @@ -0,0 +1,5 @@ +// Code generated by version.sh (@generated) DO NOT EDIT. +package main +var githash = "35542b5" +var buildstamp = "2021-10-27_01:27:20" +var commits = "274" diff --git a/version.sh b/version.sh new file mode 100644 index 0000000..4cadf37 --- /dev/null +++ b/version.sh @@ -0,0 +1,12 @@ +# Get the version. +githash=`git rev-parse --short HEAD` +buildstamp=`date -u '+%Y-%m-%d_%H:%M:%S'` +commits=`git rev-list --count master` +# Write out the package. +cat << EOF > version.go +// Code generated by version.sh (@generated) DO NOT EDIT. +package main +var githash = "$githash" +var buildstamp = "$buildstamp" +var commits = "$commits" +EOF