diff --git a/Dockerfile b/Dockerfile index a80553b..6ad1c65 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Use the official Go image as a parent image -FROM golang:1.21 as builder +FROM golang:1.21 AS builder # Set the working directory WORKDIR /app @@ -12,7 +12,7 @@ RUN go mod download && \ go build -o /app/webBridgeBot . # Use a smaller image to run the app -FROM debian:bookworm-slim +FROM debian:bookworm-slim AS final # Set the working directory WORKDIR /app @@ -27,11 +27,6 @@ COPY run.sh /app/run.sh RUN chmod +x /app/webBridgeBot RUN chmod +x /app/run.sh -# Update and install the necessary libraries -RUN apt-get update && apt-get install -y \ - libssl3 \ - && rm -rf /var/lib/apt/lists/* - # Expose the application's port EXPOSE 8080 diff --git a/Makefile b/Makefile index b6e3b41..f0222ee 100644 --- a/Makefile +++ b/Makefile @@ -1,44 +1,16 @@ # Makefile for cloning, building TDLib, building OpenSSL, and building a Go application (webBridgeBot) that uses TDLib # Define variables -TDLIB_GIT_REPO=https://github.com/tdlib/td.git -OPENSSL_GIT_REPO=https://github.com/openssl/openssl.git -OPENSSL_VERSION=openssl-3.0.0 TDLIB_DIR=$(CURDIR)/tdlib -OPENSSL_DIR=$(CURDIR)/openssl -BUILD_DIR=$(TDLIB_DIR)/build -TDLIB_INSTALL_DIR=$(CURDIR)/tdlib_install -OPENSSL_INSTALL_DIR=$(CURDIR)/openssl_install DOCKER_IMAGE_NAME=webbridgebot DOCKER_TAG=latest DOCKER_USERNAME=mshafiee -# Environment variables for Go build -export CGO_CFLAGS=-I$(TDLIB_INSTALL_DIR)/include -I$(OPENSSL_INSTALL_DIR)/include -export CGO_LDFLAGS=-L$(TDLIB_INSTALL_DIR)/lib -L$(OPENSSL_INSTALL_DIR)/lib -lssl -lcrypto - # Default target builds OpenSSL, TDLib, the Go application, and the Docker image -all: openssl tdlib webBridgeBot docker - -# Clone and build OpenSSL -openssl: - git clone --depth 1 --branch $(OPENSSL_VERSION) $(OPENSSL_GIT_REPO) $(OPENSSL_DIR) && \ - cd $(OPENSSL_DIR) && \ - ./config --prefix=$(OPENSSL_INSTALL_DIR) && \ - make && make install - -# Clone TDLib repository -$(TDLIB_DIR): - git clone --depth 1 $(TDLIB_GIT_REPO) $(TDLIB_DIR) - -# Build TDLib -tdlib: openssl $(TDLIB_DIR) - mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && \ - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(TDLIB_INSTALL_DIR) -DOPENSSL_ROOT_DIR=$(OPENSSL_INSTALL_DIR) .. && \ - cmake --build . --target install +all: webBridgeBot docker # Build the Go application webBridgeBot -webBridgeBot: tdlib +webBridgeBot: go build -o webBridgeBot . # Build Docker image @@ -53,11 +25,7 @@ docker: # Clean up build and cloned directories, and remove webBridgeBot binary clean: rm -rf $(BUILD_DIR) - rm -rf $(TDLIB_DIR) - rm -rf $(OPENSSL_DIR) - rm -rf $(TDLIB_INSTALL_DIR) - rm -rf $(OPENSSL_INSTALL_DIR) rm -f webBridgeBot # Phony targets -.PHONY: all clean tdlib webBridgeBot openssl docker +.PHONY: all clean webBridgeBot docker diff --git a/docker-compose.yml b/docker-compose.yml index 42ad946..63998bc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,10 @@ services: - BOT_TOKEN=${BOT_TOKEN} - BASE_URL=${BASE_URL} - PORT=${PORT} + - HASH_LENGTH=${HASH_LENGTH} + - MAX_CACHE_SIZE=${MAX_CACHE_SIZE} + - PORT=${PORT} ports: - "${PORT}:${PORT}" volumes: - - .tdlib:/app/.tdlib # Persist TDLib data between container restarts + - .cache:/app/.cache # Persist .cache data between container restarts