From a5f6c600357d4000b4a904e36cac1256ca3ac01d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C4=BCja=20Pav=C4=BCikhin?= Date: Tue, 1 Aug 2023 22:36:27 +0000 Subject: [PATCH] Add building in fcking docker environment --- .gitignore | 1 + Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ Makefile | 6 ++++++ 3 files changed, 43 insertions(+) create mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index 58426dd..b132b72 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ telegabber sessions/ session.dat session.dat.new +release/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6fea570 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +FROM golang:1.19-bookworm AS base + +RUN apt-get update +run apt-get install -y libssl-dev cmake build-essential gperf libz-dev make git + +FROM base AS tdlib + +ARG TD_COMMIT +ARG MAKEOPTS +RUN git clone https://github.com/tdlib/td /src/ +RUN git -C /src/ checkout "${TD_COMMIT}" +RUN mkdir build +WORKDIR /build/ +RUN cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/compiled/ /src/ +RUN cmake --build . ${MAKEOPTS} +RUN make install + +FROM base AS cache +ARG VERSION +COPY --from=tdlib /compiled/ /usr/local/ +COPY ./ /src +RUN git -C /src checkout "${VERSION}" +WORKDIR /src +RUN go get + +FROM cache AS build +ARG MAKEOPTS +WORKDIR /src +RUN make ${MAKEOPTS} + +FROM scratch AS telegabber +COPY --from=build /src/telegabber /usr/local/bin/ +ENTRYPOINT ["/usr/local/bin/telegabber"] + +FROM scratch AS binaries +COPY --from=telegabber /usr/local/bin/telegabber / diff --git a/Makefile b/Makefile index 048987d..5869f9e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ .PHONY: all test COMMIT := $(shell git rev-parse --short HEAD) +TD_COMMIT := "8517026415e75a8eec567774072cbbbbb52376c1" +VERSION := "v1.7.1" +MAKEOPTS := "-j4" all: go build -ldflags "-X main.commit=${COMMIT}" -o telegabber @@ -10,3 +13,6 @@ test: lint: $(GOPATH)/bin/golint ./... + +build_indocker: + docker build --build-arg "TD_COMMIT=${TD_COMMIT}" --build-arg "VERSION=${VERSION}" --build-arg "MAKEOPTS=${MAKEOPTS}" --output=release --target binaries .