Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Commit 6f0df6b

Browse files
committed
feature: docker and deploy
1 parent 6c6f298 commit 6f0df6b

File tree

6 files changed

+92
-39
lines changed

6 files changed

+92
-39
lines changed

.github/workflows/docker.yml

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,16 @@
1-
name: Build and Push Docker image
1+
name: flow
22

33
on:
44
push:
5-
branches:
6-
# - main
7-
- qeithjqeiothioqehbtjkqehjkle
85

9-
jobs:
10-
build:
11-
runs-on: ubuntu-latest
12-
13-
steps:
14-
- name: Checkout code
15-
uses: actions/checkout@v3
6+
concurrency:
7+
group: ${{ github.ref }}
8+
cancel-in-progress: true
169

17-
- name: Log in to GitHub Packages
18-
uses: docker/login-action@v2
19-
with:
20-
registry: ghcr.io
21-
username: ${{ github.actor }}
22-
password: ${{ secrets.GITHUB_TOKEN }}
23-
24-
- name: Set up Docker Buildx
25-
uses: docker/setup-buildx-action@v2
10+
jobs:
11+
publish:
12+
uses: ./.github/workflows/template-publish.yml
2613

27-
- name: Build and push Docker image
28-
uses: docker/build-push-action@v3
29-
with:
30-
context: .
31-
file: Dockerfile
32-
push: true
33-
tags: ghcr.io/${{ github.repository }}/asyncbot:latest
14+
deploy:
15+
needs: [publish]
16+
uses: ./.github/workflows/template-deploy.yml
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: deploy
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
deploy:
8+
runs-on: [self-hosted, async-bot]
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Login Docker
15+
uses: docker/login-action@v3
16+
with:
17+
registry: ghcr.io
18+
username: ${{ github.actor }}
19+
password: ${{ github.token }}
20+
21+
- name: Deploy
22+
run: |
23+
export COMPOSE_PROJECT_NAME=async-bot
24+
docker compose pull
25+
docker compose up -d
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: publish
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Log in to GitHub Packages
15+
uses: docker/login-action@v2
16+
with:
17+
registry: ghcr.io
18+
username: ${{ github.actor }}
19+
password: ${{ secrets.GITHUB_TOKEN }}
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v2
23+
24+
- name: Build and push Docker image
25+
uses: docker/build-push-action@v3
26+
with:
27+
context: .
28+
file: Dockerfile
29+
push: true
30+
tags: ghcr.io/${{ github.repository }}/async-bot:latest

Dockerfile

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1-
FROM ubuntu:latest
1+
FROM python:3.13-alpine AS builder
2+
3+
RUN apk add build-base patchelf ccache
4+
RUN pip install poetry nuitka zstandard
5+
6+
WORKDIR /app
7+
8+
COPY pyproject.toml poetry.lock ./
9+
10+
RUN poetry config virtualenvs.in-project true && \
11+
poetry config virtualenvs.create true && \
12+
poetry config virtualenvs.path .venv && \
13+
poetry install
14+
15+
FROM python:3.13-alpine AS final
16+
17+
WORKDIR /app
18+
19+
COPY --from=builder /app/.venv ./.venv
20+
21+
COPY ./src ./src
22+
COPY ./pyproject.toml ./pyproject.toml
23+
24+
CMD ["/bin/sh", "-c", "source .venv/bin/activate && nb run"]
225

3-
RUN apt-get update && apt-get install -y git

pyproject.toml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
[project]
2-
name = "AsyncBot"
3-
version = "0.1.0"
4-
description = "AsyncBot"
5-
readme = "README.md"
6-
requires-python = ">=3.9, <4.0"
7-
8-
91
[tool.nonebot]
102
adapters = [
113
{ name = "OneBot V11", module_name = "nonebot.adapters.onebot.v11" },
@@ -20,6 +12,7 @@ version = "0.0.0"
2012
description = "AsyncBot"
2113
authors = ["dsx137"]
2214
license = "AGPLv3"
15+
package-mode = false
2316

2417
[tool.poetry.dependencies]
2518
python = ">=3.9, <4.0"

src/plugins/chat/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from pydantic import BaseModel, field_validator
1+
from pydantic import BaseModel, field_validator, Field
22
from nonebot import get_plugin_config
33

44

55
class Config(BaseModel):
6-
api_key: str
6+
api_key: str = Field(..., alias="API_KEY")
77

88

99
plugin_config = get_plugin_config(Config)

0 commit comments

Comments
 (0)