-
-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathDockerfile
More file actions
94 lines (86 loc) · 4.39 KB
/
Dockerfile
File metadata and controls
94 lines (86 loc) · 4.39 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
ARG BUILD_VERSION=3.5.0
#FROM mcr.microsoft.com/dotnet/runtime:9.0.3-noble-amd64 AS base
FROM dhi.io/dotnet:9.0.16-debian13@sha256:4797903e46b475875f4a402aa6f42a1dcc78cfe67d217f9f5f49e358b60d47a3 AS base
ARG BUILD_VERSION
WORKDIR /app
EXPOSE 8080
#FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build
FROM dhi.io/dotnet:9.0.314-sdk-debian13@sha256:a3acd51de0af79878e26292b3053aab513c6ca4476ddb2f9f11adb9c04aa7c89 AS build
ARG BUILD_VERSION
WORKDIR /src
COPY ["Directory.Build.props", "./"]
COPY ["Web/Resgrid.Web.Tts/Resgrid.Web.Tts.csproj", "Web/Resgrid.Web.Tts/"]
COPY ["Core/Resgrid.Config/Resgrid.Config.csproj", "Core/Resgrid.Config/"]
RUN dotnet restore "Web/Resgrid.Web.Tts/Resgrid.Web.Tts.csproj"
COPY . .
WORKDIR /src/Web/Resgrid.Web.Tts
RUN dotnet publish "Resgrid.Web.Tts.csproj" -c Release -o /app/publish /p:UseAppHost=false --no-restore -p:Version=${BUILD_VERSION}
FROM build AS publish
ARG PIPER_VERSION=v1.2.0
COPY --from=base /etc/passwd /tmp/base-passwd
COPY --from=base /etc/group /tmp/base-group
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libespeak-ng1 \
ca-certificates \
curl \
xz-utils \
&& rm -rf /var/lib/apt/lists/* \
&& curl -fsSL --retry 3 --retry-delay 5 "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz" -o /tmp/ffmpeg.tar.xz \
&& tar -xf /tmp/ffmpeg.tar.xz -C /tmp \
&& mkdir -p /usr/local/bin \
&& find /tmp -name 'ffmpeg' -type f -not -path '*/lib/*' -exec cp {} /usr/local/bin/ffmpeg \; \
&& find /tmp -name 'ffprobe' -type f -not -path '*/lib/*' -exec cp {} /usr/local/bin/ffprobe \; \
&& chmod +x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe \
&& rm -rf /tmp/ffmpeg* \
&& mkdir -p /usr/local/share/piper-voices \
&& curl -fsSL --retry 3 --retry-delay 5 "https://github.com/rhasspy/piper/releases/download/${PIPER_VERSION}/piper_amd64.tar.gz" -o /tmp/piper.tar.gz \
&& tar -xzf /tmp/piper.tar.gz -C /tmp \
&& mv /tmp/piper/piper /usr/local/bin/piper \
&& chmod +x /usr/local/bin/piper \
&& find /tmp/piper -name '*.so*' -exec cp {} /usr/local/lib/ \; \
&& if [ -d /tmp/piper/espeak-ng-data ]; then cp -R /tmp/piper/espeak-ng-data /usr/share/; else ln -sf /usr/lib/x86_64-linux-gnu/espeak-ng-data /usr/share/espeak-ng-data; fi \
&& ldconfig \
&& rm -rf /tmp/piper /tmp/piper.tar.gz \
&& for f in \
"en/en_US/norman/medium/en_US-norman-medium" \
"es/es_MX/claude/high/es_MX-claude-high" \
"sv/sv_SE/nst/medium/sv_SE-nst-medium" \
"de/de_DE/thorsten/medium/de_DE-thorsten-medium" \
"fr/fr_FR/siwis/medium/fr_FR-siwis-medium" \
"it/it_IT/paola/medium/it_IT-paola-medium" \
"pl/pl_PL/gosia/medium/pl_PL-gosia-medium" \
"uk/uk_UA/ukrainian_tts/medium/uk_UA-ukrainian_tts-medium" \
"ar/ar_JO/kareem/medium/ar_JO-kareem-medium" \
; do \
name=$(basename "$f"); \
curl -fsSL --retry 3 --retry-delay 5 "https://huggingface.co/rhasspy/piper-voices/resolve/main/${f}.onnx" -o "/usr/local/share/piper-voices/${name}.onnx"; \
curl -fsSL --retry 3 --retry-delay 5 "https://huggingface.co/rhasspy/piper-voices/resolve/main/${f}.onnx.json" -o "/usr/local/share/piper-voices/${name}.onnx.json"; \
done \
&& groupadd --gid 10001 appgroup \
&& useradd --uid 10001 --gid appgroup --create-home --shell /usr/sbin/nologin appuser \
&& cp /tmp/base-passwd /tmp/app-passwd \
&& cp /tmp/base-group /tmp/app-group \
&& grep appuser /etc/passwd >> /tmp/app-passwd \
&& grep appgroup /etc/group >> /tmp/app-group \
&& mkdir -p /tmp/ttsdeps \
&& for bin in /usr/local/bin/piper /usr/local/bin/ffmpeg; do \
ldd "$bin" 2>/dev/null | awk '/=>/ {print $3}' >> /tmp/ttsdeps/libs.txt; \
done \
&& find /usr/local/lib -name '*.so*' -type f >> /tmp/ttsdeps/libs.txt \
&& sort -u /tmp/ttsdeps/libs.txt | while read lib; do [ -f "$lib" ] && cp "$lib" /tmp/ttsdeps/; done
FROM base AS final
WORKDIR /app
COPY --from=publish /usr/local/bin/piper /usr/local/bin/piper
COPY --from=publish /usr/local/share/piper-voices/ /usr/local/share/piper-voices/
COPY --from=publish /usr/share/espeak-ng-data/ /usr/share/espeak-ng-data/
COPY --from=publish /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
COPY --from=publish /usr/local/bin/ffprobe /usr/local/bin/ffprobe
COPY --from=publish /tmp/ttsdeps/ /usr/local/lib/tts/
COPY --from=publish /tmp/app-passwd /etc/passwd
COPY --from=publish /tmp/app-group /etc/group
COPY --from=publish /app/publish .
ENV LD_LIBRARY_PATH="/usr/local/lib/tts"
ENV ASPNETCORE_URLS=http://+:8080
USER appuser
ENTRYPOINT ["dotnet", "Resgrid.Web.Tts.dll"]