Skip to content

Commit b2fb5b3

Browse files
sebaplazaSebastian Plazam1guelpf
authored
feat: add docker image (#46)
* feat: add docker image * chore: clean dockerfile remove useless build deps * chore(ci): add docker image build action * Update README.md Co-authored-by: Sebastian Plaza <[email protected]> Co-authored-by: Miguel Piedrafita <[email protected]>
1 parent 2dc2c2e commit b2fb5b3

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

.github/workflows/release.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,26 @@ jobs:
3838
github_token: ${{ secrets.GITHUB_TOKEN }}
3939
goversion: "https://dl.google.com/go/go1.19.3.linux-amd64.tar.gz"
4040
asset_name: "${{ env.REPOSITORY_NAME }}-${{ env.OS_NAME }}-${{ matrix.goarch }}"
41+
42+
build-and-push-image:
43+
runs-on: ubuntu-latest
44+
permissions:
45+
contents: read
46+
packages: write
47+
steps:
48+
- uses: actions/checkout@v3
49+
- name: Log in to the Container registry
50+
uses: docker/login-action@v2
51+
with:
52+
registry: ghcr.io
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
- name: Build and push
56+
uses: docker/build-push-action@v3
57+
with:
58+
context: .
59+
platforms: linux/amd64,linux/arm64
60+
push: true
61+
tags: |
62+
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
63+
ghcr.io/${{ github.repository }}:latest

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM golang:1-alpine as builder
2+
RUN apk update && apk add make
3+
WORKDIR /build
4+
ADD . .
5+
RUN make build
6+
7+
FROM alpine
8+
COPY --from=builder /build/chatgpt-telegram /bin/chatgpt-telegram
9+
RUN chmod +x /bin/chatgpt-telegram
10+
11+
ENTRYPOINT ["/bin/chatgpt-telegram"]

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,31 @@ After you download the file, extract it into a folder and open the `env.example`
2525
2626
Finally, open the terminal in your computer (if you're on windows, look for `PowerShell`), navigate to the path you extracted the above file (you can use `cd dirname` to navigate to a directory, ask ChatGPT if you need more assistance 😉) and run `./chatgpt-telegram`.
2727

28+
### Running with Docker
29+
30+
If you're trying to run this on a server with an existing Docker setup, you might want to use our Docker image instead.
31+
32+
```sh
33+
docker pull ghcr.io/m1guelpf/chatgpt-telegram
34+
```
35+
36+
Here's how you'd set things up with `docker-compose`:
37+
38+
```yaml
39+
services:
40+
chatgpt-telegram:
41+
image: ghcr.io/m1guelpf/chatgpt-telegram
42+
container_name: chatgpt-telegram
43+
volumes:
44+
# your ".config" local folder must include a "chatgpt.json" file
45+
- .config/:/root/.config
46+
environment:
47+
- TELEGRAM_ID=
48+
- TELEGRAM_TOKEN=
49+
```
50+
51+
> **Note** The docker setup is optimized for the Browserless authentication mechanism, described below. Make sure you update the `.config/chatgpt.json` file in this repo with your session token before running.
52+
2853
## Authentication
2954

3055
By default, the program will launch a browser for you to sign into your account, and close it once you're signed in. If this setup doesn't work for you (there are issues with the browser starting, you want to run this in a computer with no screen, etc.), you can manually extract your session from your browser instead.

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func main() {
3939

4040
err = godotenv.Load()
4141
if err != nil {
42-
log.Fatalf("Couldn't load .env file: %v", err)
42+
log.Printf("Couldn't load .env file: %v. Using shell exposed env variables...", err)
4343
}
4444

4545
editInterval := 1 * time.Second

0 commit comments

Comments
 (0)