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
66 changes: 66 additions & 0 deletions .github/workflows/docker-publish-inferpage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build and Publish InferPage Docker Images

on:
push:
branches: [main]

jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4

- name: Set up QEMU (for linux/arm64 cross-build)
uses: docker/setup-qemu-action@v3

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

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push CPU image (linux/amd64 + linux/arm64)
uses: docker/build-push-action@v6
with:
context: ./src
file: ./src/Dockerfile.inferpage
target: runtime-cpu
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/main-inferpage:cpu
ghcr.io/${{ github.repository_owner }}/main-inferpage:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and push CUDA image (linux/amd64)
uses: docker/build-push-action@v6
with:
context: ./src
file: ./src/Dockerfile.inferpage
target: runtime-cuda
platforms: linux/amd64
push: true
tags: ghcr.io/${{ github.repository_owner }}/main-inferpage:cuda
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and push Ollama-bundled image (linux/amd64 + linux/arm64)
uses: docker/build-push-action@v6
with:
context: ./src
file: ./src/Dockerfile.inferpage
target: runtime-ollama-bundled
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository_owner }}/main-inferpage:ollama
cache-from: type=gha
cache-to: type=gha,mode=max
33 changes: 33 additions & 0 deletions scripts/docker-compose.inferpage-ollama.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
services:

ollama:
image: ollama/ollama:latest
container_name: ollama
restart: unless-stopped
ports:
- "11434:11434"
volumes:
- ollama-models:/root/.ollama
# Uncomment to enable NVIDIA GPU pass-through:
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: all
# capabilities: [gpu]

inferpage:
image: ghcr.io/${GITHUB_OWNER}/main-inferpage:ollama
container_name: inferpage
restart: unless-stopped
ports:
- "5555:5555"
environment:
MaIN__OllamaBaseUrl: http://ollama:11434
MaIN__BackendType: 7
depends_on:
- ollama

volumes:
ollama-models:
10 changes: 10 additions & 0 deletions src/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**/bin/
**/obj/
**/.vs/
**/.idea/
**/*.user
**/*.suo
MaIN.Core.UnitTests/
MaIN.Core.IntegrationTests/
MaIN.Core.E2ETests/
**/appsettings.*.local.json
111 changes: 111 additions & 0 deletions src/Dockerfile.inferpage
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS restore
WORKDIR /src

COPY MaIN.Domain/MaIN.Domain.csproj MaIN.Domain/
COPY MaIN.Infrastructure/MaIN.Infrastructure.csproj MaIN.Infrastructure/
COPY MaIN.Services/MaIN.Services.csproj MaIN.Services/
COPY MaIN.Core/MaIN.Core.csproj MaIN.Core/
COPY MaIN.InferPage/MaIN.InferPage.csproj MaIN.InferPage/

RUN dotnet restore MaIN.InferPage/MaIN.InferPage.csproj

FROM restore AS publish

COPY MaIN.Domain/ MaIN.Domain/
COPY MaIN.Infrastructure/ MaIN.Infrastructure/
COPY MaIN.Services/ MaIN.Services/
COPY MaIN.Core/ MaIN.Core/
COPY MaIN.InferPage/ MaIN.InferPage/

RUN dotnet publish MaIN.InferPage/MaIN.InferPage.csproj \
--framework net10.0 \
--configuration Release \
--no-restore \
--output /app/out

FROM nvidia/cuda:12.9.1-runtime-ubuntu24.04 AS runtime-cuda

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
libicu74 \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*

COPY --from=mcr.microsoft.com/dotnet/aspnet:10.0 /usr/share/dotnet /usr/share/dotnet
RUN ln -sf /usr/share/dotnet/dotnet /usr/local/bin/dotnet

WORKDIR /app

ENV DOTNET_ROOT=/usr/share/dotnet
ENV ASPNETCORE_URLS=http://+:5555
ENV ASPNETCORE_ENVIRONMENT=Production
ENV MaIN__ModelsPath=/app/Models
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
ENV LD_LIBRARY_PATH=/usr/lib/wsl/lib

VOLUME /app/Models
EXPOSE 5555

COPY --from=publish /app/out .

RUN find /app/runtimes/linux-x64/native -maxdepth 2 -mindepth 1 -type d \
| tee /etc/ld.so.conf.d/llamasharp.conf \
&& ldconfig

ENTRYPOINT ["dotnet", "MaIN.InferPage.dll"]

FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime-cpu

RUN apt-get update && apt-get install -y --no-install-recommends libgomp1 \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

ENV ASPNETCORE_URLS=http://+:5555
ENV ASPNETCORE_ENVIRONMENT=Production
ENV MaIN__ModelsPath=/app/Models

VOLUME /app/Models
EXPOSE 5555

COPY --from=publish /app/out .

ENTRYPOINT ["dotnet", "MaIN.InferPage.dll"]

FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime-ollama

WORKDIR /app

ENV ASPNETCORE_URLS=http://+:5555
ENV ASPNETCORE_ENVIRONMENT=Production
ENV MaIN__OllamaBaseUrl=http://host.docker.internal:11434
ENV MaIN__BackendType=7

EXPOSE 5555

COPY --from=publish /app/out .

ENTRYPOINT ["dotnet", "MaIN.InferPage.dll"]

FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime-ollama-bundled

COPY --from=ollama/ollama:latest /usr/bin/ollama /usr/bin/ollama

WORKDIR /app

ENV ASPNETCORE_URLS=http://+:5555
ENV ASPNETCORE_ENVIRONMENT=Production
ENV MaIN__OllamaBaseUrl=http://localhost:11434
ENV MaIN__BackendType=7

VOLUME /root/.ollama
EXPOSE 5555
EXPOSE 11434

COPY --from=publish /app/out .
COPY entrypoint-ollama.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
2 changes: 1 addition & 1 deletion src/MaIN.Core/.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package>
<metadata>
<id>MaIN.NET</id>
<version>0.10.5</version>
<version>0.10.9</version>
<authors>Wisedev</authors>
<owners>Wisedev</owners>
<icon>favicon.png</icon>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using MaIN.Domain.Models.Abstract;
using MaIN.Core.Hub.Contexts;
using MaIN.Domain.Models.Abstract;
using MaIN.Infrastructure.Models;

namespace MaIN.Core.Hub.Contexts.Interfaces.ModelContext;

Expand Down Expand Up @@ -51,6 +53,8 @@ public interface IModelContext
/// returning the context instance implementing <see cref="IModelContext"/> for method chaining.</returns>
Task<IModelContext> DownloadAsync(string modelId, CancellationToken cancellationToken = default);

Task<IModelContext> DownloadAsync(string modelId, IProgress<DownloadProgress>? progress, CancellationToken cancellationToken = default);

/// <summary>
/// Ensures a known local model is downloaded before use. If the model is already present on disk the call
/// returns immediately; if not, the model is downloaded. Cloud models are silently skipped.
Expand All @@ -62,6 +66,8 @@ public interface IModelContext
/// <see cref="IModelContext"/> for method chaining.</returns>
Task<IModelContext> EnsureDownloadedAsync(string modelId, CancellationToken cancellationToken = default);

Task<IModelContext> EnsureDownloadedAsync(string modelId, IProgress<DownloadProgress>? progress, CancellationToken cancellationToken = default);

/// <summary>
/// Ensures a known local model is downloaded before use using a strongly-typed model reference.
/// If the model is already present on disk the call returns immediately; if not, the model is downloaded.
Expand Down
Loading
Loading