diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b9049b4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM golang as builder +WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN make build + +FROM alpine:latest +RUN apk --no-cache add ca-certificates +WORKDIR /app +COPY --from=builder /app/bin/ /app/ +CMD ["/app/openwebui-telegram"] diff --git a/Makefile b/Makefile index ff2a5de..7f5d6df 100644 --- a/Makefile +++ b/Makefile @@ -11,3 +11,6 @@ tidy: serve: fmt vet env $(cat dev.env | xargs) go run cmd/*.go + +build: fmt vet + CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o bin/openwebui-telegram ./cmd diff --git a/README.md b/README.md index 6640bda..1dca03b 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,16 @@ The bot supports two commands: ## How to run +### Docker Compose + +Copy the docker-compose.yml in this repo, create your env file in `dev.env` and run: + +```bash +docker compose up +``` + +### Shell + In the fish shell, you can just do: ```fish @@ -61,6 +71,7 @@ bash: env $(cat dev.env | xargs -L 1) make serve ``` + ## Contributing Contributions are welcome. Please submit a pull request or create an issue if you have any improvements or suggestions. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..99cba62 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3" + +services: + openwebui-telegram: + # build: + # context: . + # dockerfile: Dockerfile + image: realsidsun/openwebui-telegram:latest + env_file: + - dev.env + network_mode: host + restart: unless-stopped