-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
65 lines (51 loc) · 2.08 KB
/
Dockerfile
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
### Debug image
### Setup the same as base image but used dotnet/runtime
FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine AS debug
WORKDIR /app
RUN apk add --no-cache tzdata python3 && \
apk add --no-cache --virtual build-deps musl-dev gcc g++ python3-dev py3-pip && \
python3 -m venv /venv && \
source /venv/bin/activate && \
pip install --no-cache-dir yt-dlp && \
pip uninstall -y setuptools pip && \
apk del build-deps
ENV PATH="/venv/bin:$PATH"
ENV TZ=Asia/Taipei
# Disable file locking on Unix
# https://github.com/dotnet/runtime/issues/34126#issuecomment-1104981659
ENV DOTNET_SYSTEM_IO_DISABLEFILELOCKING=true
### Base image for yt-dlp
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine AS base
WORKDIR /app
RUN apk add --no-cache tzdata python3 && \
apk add --no-cache --virtual build-deps musl-dev gcc g++ python3-dev py3-pip && \
python3 -m venv /venv && \
source /venv/bin/activate && \
pip install --no-cache-dir yt-dlp && \
pip uninstall -y setuptools pip && \
apk del build-deps
ENV PATH="/venv/bin:$PATH"
ENV TZ=Asia/Taipei
# Disable file locking on Unix
# https://github.com/dotnet/runtime/issues/34126#issuecomment-1104981659
ENV DOTNET_SYSTEM_IO_DISABLEFILELOCKING=true
### Build .NET
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
ARG BUILD_CONFIGURATION=Release
ARG TARGETARCH
WORKDIR /src
COPY ["YoutubeLiveChatToDiscord.csproj", "."]
RUN dotnet restore -a $TARGETARCH "YoutubeLiveChatToDiscord.csproj"
FROM build AS publish
COPY . .
ARG BUILD_CONFIGURATION=Release
ARG TARGETARCH
RUN dotnet publish "YoutubeLiveChatToDiscord.csproj" -a $TARGETARCH -c $BUILD_CONFIGURATION -o /app/publish --self-contained true
### Final image
FROM base AS final
ENV PATH="/app:$PATH"
RUN mkdir -p /app && chown -R $APP_UID:$APP_UID /app && chmod u+rwx /app
COPY --from=publish --chown=$APP_UID:$APP_UID /app/publish/YoutubeLiveChatToDiscord /app/YoutubeLiveChatToDiscord
COPY --from=publish --chown=$APP_UID:$APP_UID /app/publish/appsettings.json /app/appsettings.json
USER $APP_UID
ENTRYPOINT ["/app/YoutubeLiveChatToDiscord"]