-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
158 lines (122 loc) · 5.48 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
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
# From the base image
ARG UID=app
ARG APP_UID=1654
ARG VERSION=EDGE
ARG RELEASE=0
ARG BUILD_CONFIGURATION=ApacheCouchDB_Release
########################################
# Base stage
########################################
FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0-slim AS base
# RUN mount cache for multi-arch: https://github.com/docker/buildx/issues/549#issuecomment-1788297892
ARG TARGETARCH
ARG TARGETVARIANT
WORKDIR /app
RUN --mount=type=cache,id=apt-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/apt \
--mount=type=cache,id=aptlists-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/lib/apt/lists \
apt-get update && apt-get install -y --no-install-recommends \
python3
ARG UID
# ffmpeg
COPY --link --chown=$UID:0 --chmod=775 --from=ghcr.io/jim60105/static-ffmpeg-upx:7.0-1 /ffmpeg /usr/bin/
COPY --link --chown=$UID:0 --chmod=775 --from=ghcr.io/jim60105/static-ffmpeg-upx:7.0-1 /ffprobe /usr/bin/
# yt-dlp
ADD --link --chown=$UID:0 --chmod=775 https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp /usr/bin/yt-dlp
########################################
# Build stage
########################################
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /source
ARG TARGETARCH
RUN --mount=source=LivestreamRecorderBackend.csproj,target=LivestreamRecorderBackend.csproj \
--mount=source=LivestreamRecorder.DB/LivestreamRecorder.DB.csproj,target=LivestreamRecorder.DB/LivestreamRecorder.DB.csproj \
dotnet restore -a $TARGETARCH "LivestreamRecorderBackend.csproj"
########################################
# Publish stage
########################################
FROM build AS publish
ARG BUILD_CONFIGURATION
ARG TARGETARCH
RUN --mount=source=.,target=.,rw \
dotnet publish "LivestreamRecorderBackend.csproj" -a $TARGETARCH -c $BUILD_CONFIGURATION -o /app
########################################
# Final stage
########################################
FROM base AS final
ARG UID
# Support arbitrary user ids (OpenShift best practice)
# https://docs.openshift.com/container-platform/4.14/openshift_images/create-images.html#use-uid_create-images
RUN chown -R $UID:0 /azure-functions-host && \
chmod -R g=u /azure-functions-host
# Create directories with correct permissions
RUN install -d -m 775 -o $UID -g 0 /home/site/wwwroot && \
install -d -m 775 -o $UID -g 0 /home/.cache && \
install -d -m 775 -o $UID -g 0 /licenses
# dumb-init
COPY --link --chown=$UID:0 --chmod=775 --from=ghcr.io/jim60105/static-ffmpeg-upx:7.0-1 /dumb-init /usr/bin/
COPY --link --chown=$UID:0 --chmod=775 --from=ghcr.io/tarampampam/curl:8.8.0 /bin/curl /bin/curl
HEALTHCHECK --interval=10s --timeout=2s --retries=3 --start-period=20s CMD [ \
"curl", "--fail", "http://127.0.0.1:8080/api/healthz" \
]
# Copy licenses (OpenShift Policy)
COPY --link --chown=$UID:0 --chmod=775 LICENSE /licenses/LICENSE
COPY --link --chown=$UID:0 --chmod=775 --from=ghcr.io/jim60105/yt-dlp:distroless /licenses/yt-dlp.LICENSE /licenses/yt-dlp.LICENSE
# Copy dist
COPY --link --chown=$UID:0 --chmod=775 --from=publish /app /home/site/wwwroot
ENV PATH="/home/site/wwwroot:/home/$UID/.local/bin:$PATH"
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
ENV FUNCTIONS_WORKER_RUNTIME=dotnet-isolated
ENV AzureFunctionsJobHost__Logging__Console__IsEnabled=true
# Set this to the connection string for the online storage account or the local emulator
# https://learn.microsoft.com/zh-tw/azure/storage/common/storage-use-azurite#http-connection-strings
ENV AzureWebJobsStorage=
# Issue: Azure Durable Function HttpStart failure: Webhooks are not configured
# https://stackoverflow.com/a/64404153/8706033
ENV WEBSITE_HOSTNAME=localhost:8080
ENV CORS_SUPPORT_CREDENTIALS=true
ENV CORS_ALLOWED_ORIGINS=["https://localhost:4200"]
ENV FrontEndUri=https://localhost:4200
ENV Registration_allowed=false
ENV Seq_ServerUrl=
ENV Seq_ApiKey=
ENV StorageService=
ENV Blob_ConnectionString=
ENV Blob_ContainerNamePublic=
ENV Blob_ContainerNamePrivate=
ENV S3_Endpoint=
ENV S3_AccessKey=
ENV S3_SecretKey=
ENV S3_Secure=
ENV S3_BucketNamePrivate=
ENV S3_BucketNamePublic=
ENV CosmosDB_Private_ConnectionString=
ENV CosmosDB_Public_ConnectionString=
ENV CouchDB_Endpoint=
ENV CouchDB_Username=
ENV CouchDB_Password=
ENV GITHUB_PROVIDER_AUTHENTICATION_ID=
ENV GITHUB_PROVIDER_AUTHENTICATION_SECRET=
ENV Twitch_ClientId=
ENV Twitch_ClientSecret=
EXPOSE 8080
ENV ASPNETCORE_URLS=http://+:8080
USER $UID:0
STOPSIGNAL SIGINT
# Use dumb-init as PID 1 to handle signals properly
ENTRYPOINT [ "dumb-init", "--", "/opt/startup/start_nonappservice.sh" ]
ARG VERSION
ARG RELEASE
LABEL name="Recorder-moe/LivestreamRecorderBackend" \
# Authors for LivestreamRecorderBackend
vendor="Recorder-moe" \
# Maintainer for this docker image
maintainer="jim60105" \
# Dockerfile source repository
url="https://github.com/Recorder-moe/LivestreamRecorderBackend" \
version=${VERSION} \
# This should be a number, incremented with each change
release=${RELEASE} \
io.k8s.display-name="LivestreamRecorderBackend" \
summary="LivestreamRecorderBackend: The backend azure function for the Recorder.moe project." \
description="Recorder.moe is an advanced live stream recording system. We utilize containerization technology to achieve horizontal scalability, enabling us to monitor and record an unlimited number of channels simultaneously. For more information about this tool, please visit the following website: https://github.com/Recorder-moe"