Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 29 additions & 30 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ jobs:
build-nightly-image:
if: github.repository == 'AstrBotDevs/AstrBot' && github.event_name == 'schedule'
runs-on: ubuntu-latest
strategy:
matrix:
include:
- type: standard
file: Dockerfile
tag_suffix: ""
- type: minimal
file: Dockerfile.minimal
tag_suffix: "-minimal"
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
GHCR_OWNER: astrbotdevs
Expand Down Expand Up @@ -44,17 +53,6 @@ jobs:
if: github.event_name == 'schedule' && steps.check-commits.outputs.has_commits == 'false'
run: exit 0

- name: Build Dashboard
run: |
cd dashboard
npm install
npm run build
mkdir -p dist/assets
echo $(git rev-parse HEAD) > dist/assets/version
cd ..
mkdir -p data
cp -r dashboard/dist data/

- name: Determine test image tags
id: test-meta
run: |
Expand Down Expand Up @@ -86,12 +84,12 @@ jobs:
- name: Build nightly image tags list
id: test-tags
run: |
TAGS="${{ env.DOCKER_HUB_USERNAME }}/astrbot:nightly-latest
${{ env.DOCKER_HUB_USERNAME }}/astrbot:nightly-${{ steps.test-meta.outputs.build_date }}-${{ steps.test-meta.outputs.short_sha }}"
TAGS="${{ env.DOCKER_HUB_USERNAME }}/astrbot:nightly-latest${{ matrix.tag_suffix }}
${{ env.DOCKER_HUB_USERNAME }}/astrbot:nightly-${{ steps.test-meta.outputs.build_date }}-${{ steps.test-meta.outputs.short_sha }}${{ matrix.tag_suffix }}"
if [ "${{ env.HAS_GHCR_TOKEN }}" = "true" ]; then
TAGS="$TAGS
ghcr.io/${{ env.GHCR_OWNER }}/astrbot:nightly-latest
ghcr.io/${{ env.GHCR_OWNER }}/astrbot:nightly-${{ steps.test-meta.outputs.build_date }}-${{ steps.test-meta.outputs.short_sha }}"
ghcr.io/${{ env.GHCR_OWNER }}/astrbot:nightly-latest${{ matrix.tag_suffix }}
ghcr.io/${{ env.GHCR_OWNER }}/astrbot:nightly-${{ steps.test-meta.outputs.build_date }}-${{ steps.test-meta.outputs.short_sha }}${{ matrix.tag_suffix }}"
fi
echo "tags<<EOF" >> $GITHUB_OUTPUT
echo "$TAGS" >> $GITHUB_OUTPUT
Expand All @@ -101,6 +99,7 @@ jobs:
uses: docker/build-push-action@v7.0.0
with:
context: .
file: ${{ matrix.file }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.test-tags.outputs.tags }}
Expand All @@ -116,6 +115,16 @@ jobs:
GHCR_OWNER: astrbotdevs
HAS_GHCR_TOKEN: ${{ secrets.GHCR_GITHUB_TOKEN != '' }}

strategy:
matrix:
include:
- type: standard
file: Dockerfile
tag_suffix: ""
- type: minimal
file: Dockerfile.minimal
tag_suffix: "-minimal"

steps:
- name: Checkout
uses: actions/checkout@v6
Expand Down Expand Up @@ -151,17 +160,6 @@ jobs:
fi
echo "version=$version" >> $GITHUB_OUTPUT

- name: Build Dashboard
run: |
cd dashboard
npm install
npm run build
mkdir -p dist/assets
echo $(git rev-parse HEAD) > dist/assets/version
cd ..
mkdir -p data
cp -r dashboard/dist data/

- name: Set QEMU
uses: docker/setup-qemu-action@v4.0.0

Expand All @@ -188,11 +186,12 @@ jobs:
context: .
platforms: linux/amd64,linux/arm64
push: true
file: ${{ matrix.file }}
tags: |
${{ steps.release-meta.outputs.is_prerelease == 'false' && format('{0}/astrbot:latest', env.DOCKER_HUB_USERNAME) || '' }}
${{ steps.release-meta.outputs.is_prerelease == 'false' && env.HAS_GHCR_TOKEN == 'true' && format('ghcr.io/{0}/astrbot:latest', env.GHCR_OWNER) || '' }}
${{ format('{0}/astrbot:{1}', env.DOCKER_HUB_USERNAME, steps.release-meta.outputs.version) }}
${{ env.HAS_GHCR_TOKEN == 'true' && format('ghcr.io/{0}/astrbot:{1}', env.GHCR_OWNER, steps.release-meta.outputs.version) || '' }}
${{ steps.release-meta.outputs.is_prerelease == 'false' && format('{0}/astrbot:latest{1}', env.DOCKER_HUB_USERNAME, matrix.tag_suffix) || '' }}
${{ steps.release-meta.outputs.is_prerelease == 'false' && env.HAS_GHCR_TOKEN == 'true' && format('ghcr.io/{0}/astrbot:latest{1}', env.GHCR_OWNER, matrix.tag_suffix) || '' }}
${{ format('{0}/astrbot:{1}{2}', env.DOCKER_HUB_USERNAME, steps.release-meta.outputs.version, matrix.tag_suffix) }}
${{ env.HAS_GHCR_TOKEN == 'true' && format('ghcr.io/{0}/astrbot:{1}{2}', env.GHCR_OWNER, steps.release-meta.outputs.version, matrix.tag_suffix) || '' }}

- name: Post build notifications
run: echo "Release Docker image has been built and pushed successfully"
54 changes: 54 additions & 0 deletions Dockerfile.minimal
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Minimal Dockerfile for AstrBot
# Multi-stage: Build with uv; Run without node.js

# Build stage
FROM python:3.12-slim AS builder

WORKDIR /build

# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
build-essential \
python3-dev \
libffi-dev \
libssl-dev \
ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uv/bin/uv

# Copy requirements
COPY requirements.txt .

# Install dependencies using uv
RUN /uv/bin/uv pip install --system --no-cache -r requirements.txt && \
/uv/bin/uv pip install --system --no-cache socksio pilk
Comment thread
404MaximWang marked this conversation as resolved.
Outdated

# Runtime stage
FROM python:3.12-slim

WORKDIR /AstrBot

# Install runtime dependencies (only essential ones)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
bash \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
Comment thread
404MaximWang marked this conversation as resolved.
Outdated

# Copy Python packages from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
Comment thread
404MaximWang marked this conversation as resolved.
Outdated

# Copy application code
COPY . /AstrBot/

# Cleanup Python cache
RUN find . -type f -name '*.pyc' -delete && \
find . -type d -name '__pycache__' -delete
Comment thread
404MaximWang marked this conversation as resolved.
Outdated

EXPOSE 6185

CMD [ "python", "main.py" ]