-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.ubi
71 lines (51 loc) · 1.79 KB
/
Dockerfile.ubi
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
# syntax=docker/dockerfile:1
### Python
FROM registry.access.redhat.com/ubi9/ubi-minimal AS python
ENV PYTHON_VERSION=3.11
ENV PYTHONUNBUFFERED=1
ENV PYTHONIOENCODING=UTF-8
ARG PIP_DISABLE_PIP_VERSION_CHECK=1
ARG PIP_NO_CACHE_DIR=1
RUN microdnf -y install python3.11 python3.11-pip && \
microdnf -y clean all
RUN python3.11 -m venv /venv && \
source /venv/bin/activate && \
pip3.11 install --no-cache-dir yt-dlp && \
pip3.11 uninstall -y setuptools pip && \
microdnf -y remove python3.11-pip && \
microdnf -y clean all
ENV PATH="/venv/bin:$PATH"
### Base image
FROM python AS base
WORKDIR /app
RUN microdnf -y install libicu tzdata && \
microdnf -y clean all
ENV TZ=Asia/Taipei
# Disable file locking on Unix
# https://github.com/dotnet/runtime/issues/34126#issuecomment-1104981659
ENV DOTNET_SYSTEM_IO_DISABLEFILELOCKING=true
### Debug image
FROM base AS debug
# Install .NET 8 SDK
RUN microdnf -y install dotnet-sdk-8.0
### Build .NET
FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/dotnet-80 AS build
USER 0
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 1001:1001 /app && chmod u+rwx /app
COPY --from=publish --chown=1001:1001 /app/publish/YoutubeLiveChatToDiscord /app/YoutubeLiveChatToDiscord
COPY --from=publish --chown=1001:1001 /app/publish/appsettings.json /app/appsettings.json
USER 1001
ENTRYPOINT ["/app/YoutubeLiveChatToDiscord"]