-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
158 lines (131 loc) · 5.67 KB
/
Copy pathDockerfile
File metadata and controls
158 lines (131 loc) · 5.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# syntax=docker/dockerfile:1.7
# ============================================================================
# LocalTranscriber Dockerfile
# Supports: CPU-only (default) and CUDA GPU acceleration
# ============================================================================
# Build args:
# VARIANT: "cpu" (default) or "cuda" for GPU support
# DOTNET_VERSION: .NET SDK version (default: 10.0)
# ============================================================================
ARG DOTNET_VERSION=10.0
ARG VARIANT=cpu
# ----------------------------------------------------------------------------
# Base: .NET SDK for building
# ----------------------------------------------------------------------------
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS build-base
WORKDIR /src
# Install nbgv for versioning
RUN dotnet tool install -g nbgv
ENV PATH="$PATH:/root/.dotnet/tools"
# Copy solution and project files for layer caching
COPY *.sln ./
COPY Directory.Build.props ./
COPY version.json ./
COPY global.json ./
COPY src/*/*.csproj ./src/
COPY tests/*/*.csproj ./tests/
# Restructure project files
RUN for file in src/*.csproj; do \
dir=$(basename "$file" .csproj); \
mkdir -p "src/$dir"; \
mv "$file" "src/$dir/"; \
done \
&& for file in tests/*.csproj; do \
[ -f "$file" ] || continue; \
dir=$(basename "$file" .csproj); \
mkdir -p "tests/$dir"; \
mv "$file" "tests/$dir/"; \
done
# Restore dependencies
RUN dotnet restore
# Copy everything
COPY . .
# ----------------------------------------------------------------------------
# Build stage
# ----------------------------------------------------------------------------
FROM build-base AS build
ARG CONFIGURATION=Release
RUN dotnet build -c $CONFIGURATION --no-restore
# ----------------------------------------------------------------------------
# Publish CLI
# ----------------------------------------------------------------------------
FROM build AS publish-cli
ARG CONFIGURATION=Release
WORKDIR /src/src/LocalTranscriber.Cli
RUN dotnet publish -c $CONFIGURATION -o /app/cli --no-build
# ----------------------------------------------------------------------------
# Publish Web
# ----------------------------------------------------------------------------
FROM build AS publish-web
ARG CONFIGURATION=Release
WORKDIR /src/src/LocalTranscriber.Web
RUN dotnet publish -c $CONFIGURATION -o /app/web --no-build
# ----------------------------------------------------------------------------
# Runtime: CPU variant
# ----------------------------------------------------------------------------
FROM mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION} AS runtime-cpu
# Install audio dependencies for NAudio on Linux
RUN apt-get update && apt-get install -y --no-install-recommends \
libasound2t64 \
libpulse0 \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# ----------------------------------------------------------------------------
# Runtime: CUDA variant (GPU acceleration)
# ----------------------------------------------------------------------------
FROM mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION} AS runtime-cuda
# Install CUDA runtime + audio dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libasound2t64 \
libpulse0 \
ffmpeg \
wget \
gnupg \
&& rm -rf /var/lib/apt/lists/*
# Add NVIDIA CUDA repo and install runtime (adjust version as needed)
RUN wget -qO - https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/3bf863cc.pub | gpg --dearmor -o /usr/share/keyrings/cuda-archive-keyring.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/ /" > /etc/apt/sources.list.d/cuda.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends cuda-cudart-13-1 libcublas-13-1 \
&& rm -rf /var/lib/apt/lists/*
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
# ----------------------------------------------------------------------------
# Publish Client (Blazor WASM - static site)
# ----------------------------------------------------------------------------
FROM build AS publish-client
ARG CONFIGURATION=Release
WORKDIR /src/src/LocalTranscriber.Web.Client
RUN dotnet publish -c $CONFIGURATION -o /app/client --no-build
# ----------------------------------------------------------------------------
# Final: Client (static site served by nginx)
# ----------------------------------------------------------------------------
FROM nginx:alpine AS client
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=publish-client /app/client/wwwroot /usr/share/nginx/html
EXPOSE 80
# ----------------------------------------------------------------------------
# Final: CLI
# ----------------------------------------------------------------------------
FROM runtime-${VARIANT} AS cli
WORKDIR /app
COPY --from=publish-cli /app/cli .
# Create models directory
RUN mkdir -p /app/models /app/output
VOLUME ["/app/models", "/app/output"]
ENTRYPOINT ["dotnet", "LocalTranscriber.Cli.dll"]
# ----------------------------------------------------------------------------
# Final: Web
# ----------------------------------------------------------------------------
FROM runtime-${VARIANT} AS web
WORKDIR /app
COPY --from=publish-web /app/web .
# Create models directory
RUN mkdir -p /app/models /app/output
VOLUME ["/app/models", "/app/output"]
ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080
ENTRYPOINT ["dotnet", "LocalTranscriber.Web.dll"]
# ----------------------------------------------------------------------------
# Default target
# ----------------------------------------------------------------------------
FROM web AS final