完善docker相关配置

This commit is contained in:
xintaofei
2026-03-29 19:23:46 +08:00
parent 85114272de
commit 1cda9aa5f5
4 changed files with 36 additions and 4 deletions

13
.dockerignore Normal file
View File

@@ -0,0 +1,13 @@
node_modules/
.next/
out/
target/
src-tauri/target/
.git/
*.md
LICENSE
.github/
docs/
.vscode/
.idea/
*.log

View File

@@ -342,6 +342,9 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up QEMU (for multi-arch builds)
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@@ -352,6 +355,12 @@ jobs:
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract version from tag - name: Extract version from tag
id: version id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
@@ -360,10 +369,13 @@ jobs:
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64
push: true push: true
tags: | tags: |
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }} ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}
ghcr.io/${{ github.repository }}:latest ghcr.io/${{ github.repository }}:latest
${{ secrets.DOCKERHUB_USERNAME }}/codeg:${{ steps.version.outputs.version }}
${{ secrets.DOCKERHUB_USERNAME }}/codeg:latest
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max

View File

@@ -4,14 +4,16 @@ RUN corepack enable
WORKDIR /app WORKDIR /app
COPY package.json pnpm-lock.yaml ./ COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile RUN pnpm install --frozen-lockfile
COPY . . COPY src/ ./src/
COPY public/ ./public/
COPY next.config.ts tsconfig.json postcss.config.mjs components.json ./
RUN pnpm build RUN pnpm build
# Stage 2: Build Rust server binary # Stage 2: Build Rust server binary
FROM rust:1.82-bookworm AS backend FROM rust:slim-bookworm AS backend
WORKDIR /app RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*
COPY src-tauri/ ./src-tauri/
WORKDIR /app/src-tauri WORKDIR /app/src-tauri
COPY src-tauri/ ./
RUN cargo build --release --bin codeg-server --no-default-features RUN cargo build --release --bin codeg-server --no-default-features
# Stage 3: Runtime # Stage 3: Runtime

View File

@@ -1,14 +1,19 @@
services: services:
codeg: codeg:
build: . build: .
# Or use a pre-built image:
# image: xintaofei/codeg:latest
ports: ports:
- "3080:3080" - "3080:3080"
volumes: volumes:
- codeg-data:/data - codeg-data:/data
# Mount your project directories (optional):
# - /path/to/projects:/projects
environment: environment:
- CODEG_TOKEN=${CODEG_TOKEN:-} - CODEG_TOKEN=${CODEG_TOKEN:-}
- CODEG_PORT=3080 - CODEG_PORT=3080
- CODEG_HOST=0.0.0.0 - CODEG_HOST=0.0.0.0
restart: unless-stopped
volumes: volumes:
codeg-data: codeg-data: