Skip to content

Commit e4fa1f0

Browse files
authored
feat(docker): init (#238)
1 parent ea2a508 commit e4fa1f0

File tree

3 files changed

+146
-0
lines changed

3 files changed

+146
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "application version for OpenViking"
8+
required: true
9+
type: string
10+
push:
11+
branches: [ "main" ]
12+
tags: [ "v*.*.*" ]
13+
pull_request:
14+
branches: [ "main" ]
15+
16+
env:
17+
REGISTRY: ghcr.io
18+
IMAGE_NAME: ${{ github.repository }}
19+
20+
jobs:
21+
build-and-push-image:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
attestations: write
27+
id-token: write
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v6
32+
with:
33+
submodules: recursive
34+
35+
- name: Log in to the Container registry
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ${{ env.REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Extract metadata (tags, labels) for Docker
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
47+
48+
- name: Set up QEMU
49+
uses: docker/setup-qemu-action@v3
50+
51+
- name: Set up Docker Buildx
52+
uses: docker/setup-buildx-action@v3
53+
54+
- name: Build and push Docker image
55+
id: push
56+
uses: docker/build-push-action@v5
57+
with:
58+
context: .
59+
platforms: linux/amd64,linux/arm64
60+
push: ${{ github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' }}
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
build-args: |
64+
# fallback to 0.0.0 if no version is provided
65+
OPENVIKING_VERSION=${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.version) || (github.ref_type == 'tag' && github.ref_name) || '0.0.0' }}

Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# syntax=docker/dockerfile:1.9
2+
3+
# Stage 1: provide Go toolchain (required by setup.py -> build_agfs -> make build)
4+
FROM golang:1.26-trixie AS go-toolchain
5+
6+
# Stage 2: build Python environment with uv (builds AGFS + C++ extension from source)
7+
FROM ghcr.io/astral-sh/uv:python3.13-trixie-slim AS py-builder
8+
9+
# Reuse Go toolchain from stage 1 so setup.py can compile agfs-server in-place.
10+
COPY --from=go-toolchain /usr/local/go /usr/local/go
11+
ENV PATH="/usr/local/go/bin:${PATH}"
12+
ARG OPENVIKING_VERSION=0.0.0
13+
ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OPENVIKING=${OPENVIKING_VERSION}
14+
15+
RUN apt-get update && apt-get install -y --no-install-recommends \
16+
build-essential \
17+
cmake \
18+
git \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
ENV UV_COMPILE_BYTECODE=1
22+
ENV UV_LINK_MODE=copy
23+
ENV UV_NO_DEV=1
24+
WORKDIR /app
25+
26+
# Copy source required for setup.py build_agfs() and CMake extension build.
27+
COPY pyproject.toml uv.lock setup.py README.md ./
28+
COPY openviking/ openviking/
29+
COPY openviking_cli/ openviking_cli/
30+
COPY src/ src/
31+
COPY third_party/ third_party/
32+
33+
# Install project and dependencies (triggers setup.py build_agfs + build_extension).
34+
RUN --mount=type=cache,target=/root/.cache/uv \
35+
uv sync --no-editable
36+
37+
# Stage 3: runtime
38+
FROM python:3.13-slim-trixie
39+
40+
RUN apt-get update && apt-get install -y --no-install-recommends \
41+
ca-certificates \
42+
curl \
43+
libstdc++6 \
44+
&& rm -rf /var/lib/apt/lists/*
45+
46+
WORKDIR /app
47+
48+
COPY --from=py-builder /app/.venv /app/.venv
49+
ENV PATH="/app/.venv/bin:$PATH"
50+
ENV OPENVIKING_CONFIG_FILE="/app/ov.conf"
51+
52+
EXPOSE 1933
53+
54+
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
55+
CMD curl -fsS http://127.0.0.1:1933/health || exit 1
56+
57+
# Default runs server; override command to run CLI, e.g.:
58+
# docker run --rm <image> -v "$HOME/.openviking/ovcli.conf:/root/.openviking/ovcli.conf" openviking --help
59+
CMD ["openviking-server"]

docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: "3.8"
2+
3+
services:
4+
openviking:
5+
image: ghcr.io/volcengine/openviking:main
6+
container_name: openviking
7+
ports:
8+
- "1933:1933"
9+
volumes:
10+
# Mount the configuration and data directory to persist state
11+
- /var/lib/openviking/ov.conf:/app/ov.conf
12+
- /var/lib/openviking/data:/app/data
13+
healthcheck:
14+
test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:1933/health || exit 1"]
15+
interval: 30s
16+
timeout: 5s
17+
retries: 3
18+
start_period: 30s
19+
restart: unless-stopped
20+
# If you need to override the default command (which runs openviking-server),
21+
# you can do so here. For example, to run the CLI:
22+
# command: ["openviking", "--help"]

0 commit comments

Comments
 (0)