Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
71 changes: 71 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build and Publish Multi-Arch Image

on:
workflow_dispatch:
inputs:
ref:
description: 'Branch, tag, or commit SHA to build'
required: true
default: 'main'
type: string

env:
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}

# Set up QEMU for multi-platform support (required for arm64)
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Login against a Docker registry (except on PR)
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=sha

# Build and push Docker image with Buildx
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
# Define the platforms for multi-arch
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Use GitHub cache to speed up subsequent builds
cache-from: type=gha
cache-to: type=gha,mode=max
21 changes: 21 additions & 0 deletions DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Docker

1. Build the docker image:
```shell
docker build -t davx5-mcp -f docker/Dockerfile .
```
2. Start the container:
```shell
docker run -p 3000 -v davx5-mcp-data:/app/data davx5-mcp
```

# Docker Compose

1. Build the docker image:
```shell
docker compose -f docker/compose.yml build
```
2. Start the container:
```shell
docker compose -f docker/compose.yml up
```
25 changes: 25 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Stage 1: Cache Gradle dependencies
FROM gradle:latest AS cache
RUN mkdir -p /home/gradle/cache_home
ENV GRADLE_USER_HOME=/home/gradle/cache_home
COPY build.gradle.* gradle.properties /home/gradle/app/
COPY gradle /home/gradle/app/gradle
WORKDIR /home/gradle/app
RUN gradle dependencies --no-daemon

# Stage 2: Build Application
FROM gradle:latest AS build
COPY --from=cache /home/gradle/cache_home /home/gradle/.gradle
COPY --chown=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
# Build the fat JAR, Gradle also supports shadow
# and boot JAR by default.
RUN gradle fatJar --no-daemon

# Stage 3: Create the Runtime Image
FROM amazoncorretto:21-alpine AS runtime
EXPOSE 3000
RUN mkdir /app
WORKDIR /app
COPY --from=build /home/gradle/src/server/build/libs/*.jar /app/server.jar
ENTRYPOINT ["java","-jar","/app/server.jar"]
9 changes: 9 additions & 0 deletions docker/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
davx5-mcp:
build:
context: ..
dockerfile: docker/Dockerfile
ports:
- 3000:3000
volumes:
- ./data:/app/data
2 changes: 1 addition & 1 deletion server/src/main/kotlin/at/bitfire/labs/davmcp/McpServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class McpServer @Inject constructor(

fun start(port: Int) {
println("Running MCP server")
embeddedServer(CIO, host = "127.0.0.1", port = port) {
embeddedServer(CIO, host = "0.0.0.0", port = port) {
install(SSE)
install(ContentNegotiation) {
json(McpJson)
Expand Down
Loading