Skip to content

Commit 342ccbb

Browse files
committed
fix: docker and release
1 parent 4a146d1 commit 342ccbb

4 files changed

Lines changed: 145 additions & 0 deletions

File tree

.github/workflows/docker.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Docker Image CI
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
env:
8+
DOCKER_IMAGE_NAME: missuo/deeplx-bot
9+
GHCR_IMAGE_NAME: ${{ github.repository }}
10+
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
11+
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
12+
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
GHCR_USERNAME: ${{ github.repository_owner }}
14+
15+
jobs:
16+
docker_build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up QEMU
25+
uses: docker/setup-qemu-action@v2
26+
with:
27+
platforms: all
28+
29+
- name: Set up docker buildx
30+
id: buildx
31+
uses: docker/setup-buildx-action@v2
32+
with:
33+
version: latest
34+
35+
- name: Login to DockerHub
36+
uses: docker/login-action@v2
37+
with:
38+
registry: docker.io
39+
username: ${{ env.DOCKER_USERNAME }}
40+
password: ${{ env.DOCKER_PASSWORD }}
41+
42+
- name: Login to GHCR
43+
uses: docker/login-action@v2
44+
with:
45+
registry: ghcr.io
46+
username: ${{ env.GHCR_USERNAME }}
47+
password: ${{ env.GHCR_TOKEN }}
48+
49+
- name: Docker meta
50+
id: meta
51+
uses: docker/metadata-action@v4
52+
with:
53+
images: |
54+
docker.io/${{ env.DOCKER_IMAGE_NAME }}
55+
ghcr.io/${{ env.GHCR_IMAGE_NAME }}
56+
tags: |
57+
type=ref,event=tag
58+
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
59+
type=pep440,pattern={{raw}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
60+
61+
- name: Build and push
62+
uses: docker/build-push-action@v3
63+
with:
64+
context: .
65+
platforms: linux/amd64,linux/arm64
66+
push: true
67+
tags: ${{ steps.meta.outputs.tags }}
68+
labels: ${{ steps.meta.outputs.labels }}
69+
cache-from: type=gha
70+
cache-to: type=gha,mode=max

.github/workflows/release.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build:
9+
name: Build
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
goos: [linux, windows, darwin]
14+
goarch: [amd64, arm64]
15+
steps:
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: '1.22'
20+
21+
- name: Check out code
22+
uses: actions/checkout@v2
23+
24+
- name: Build
25+
env:
26+
GOOS: ${{ matrix.goos }}
27+
GOARCH: ${{ matrix.goarch }}
28+
run: |
29+
go build -v -o deeplx-bot-${{ matrix.goos }}-${{ matrix.goarch }}
30+
31+
- name: Upload Artifacts
32+
uses: actions/upload-artifact@v2
33+
with:
34+
name: deeplx-bot-${{ matrix.goos }}-${{ matrix.goarch }}
35+
path: deeplx-bot-${{ matrix.goos }}-${{ matrix.goarch }}
36+
37+
- name: Upload Artifact to Release
38+
uses: actions/upload-release-asset@v1
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
with:
42+
upload_url: ${{ github.event.release.upload_url }}
43+
asset_path: ./deeplx-bot-${{ matrix.goos }}-${{ matrix.goarch }}
44+
asset_name: deeplx-bot-${{ matrix.goos }}-${{ matrix.goarch }}
45+
asset_content_type: application/octet-stream

compose.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
services:
2+
deeplx-bot:
3+
image: missuo/deeplx-bot:latest
4+
container_name: telegram-translator-bot
5+
environment:
6+
- BOT_TOKEN=your_bot_token_here
7+
- TARGET_LANG=ZH
8+
- API_URL=http://127.0.0.1:1188/translate
9+
- IGNORE_LANGS=EN
10+
- ALLOWED_GROUPS=-1001652593847
11+
- ALLOWED_USERS=890315416
12+
restart: always
13+
14+
# deeplx:
15+
# image: ghcr.io/owo-network/deeplx:latest
16+
# restart: always
17+
# ports:
18+
# - "1188:1188"

dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM golang:1.22 AS builder
2+
WORKDIR /go/src/github.com/OwO-Network/deeplx-bot
3+
COPY bot.go ./
4+
COPY go.mod ./
5+
COPY go.sum ./
6+
RUN go get -d -v ./
7+
RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o deeplx-bot .
8+
9+
FROM alpine:latest
10+
WORKDIR /app
11+
COPY --from=builder /go/src/github.com/OwO-Network/deeplx-bot/deeplx-bot /app/deeplx-bot
12+
CMD ["/app/deeplx-bot"]

0 commit comments

Comments
 (0)