Skip to content

Commit

Permalink
chore: refactor Dockerfile
Browse files Browse the repository at this point in the history
- Rename the Dockerfile stage for VS fast mode stage debugging
- Add an argument for build configuration in the .NET build stage
- Remove unnecessary comments and lines in the Dockerfile.ubi stage
- Add libicu and tzdata packages in the base stage of the Dockerfile.ubi

Signed-off-by: 陳鈞 <[email protected]>
  • Loading branch information
jim60105 committed Dec 4, 2023
1 parent 91bd811 commit c6ff7e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

### Base image for yt-dlp
FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine AS base
WORKDIR /app
RUN apk add --no-cache tzdata python3 && \
Expand All @@ -17,8 +18,11 @@ ENV TZ=Asia/Taipei
# https://github.com/dotnet/runtime/issues/34126#issuecomment-1104981659
ENV DOTNET_SYSTEM_IO_DISABLEFILELOCKING=true

### Debug image (same as base image)
### Rename for VS fast mode stage debugging
FROM base AS debug

### Build .NET
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
Expand All @@ -32,6 +36,7 @@ ARG BUILD_CONFIGURATION=Release
ARG TARGETPLATFORM
RUN dotnet publish "YoutubeLiveChatToDiscord.csproj" --no-self-contained -p:PublishTrimmed=false -c $BUILD_CONFIGURATION -o /app/publish

### Final image
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile.ubi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# syntax=docker/dockerfile:1

### Python
FROM registry.access.redhat.com/ubi9/ubi-minimal AS python

Expand All @@ -15,8 +17,7 @@ RUN python3.11 -m venv /venv && \
pip3.11 install yt-dlp && \
pip3.11 uninstall -y setuptools pip && \
microdnf -y remove python3.11-pip && \
microdnf -y clean all && \
rm -rf /var/cache/yum/*
microdnf -y clean all

ENV PATH="/venv/bin:$PATH"

Expand All @@ -26,8 +27,7 @@ FROM python AS base
WORKDIR /app

RUN microdnf -y install libicu tzdata && \
microdnf -y clean all && \
rm -rf /var/cache/yum/*
microdnf -y clean all

ENV TZ=Asia/Taipei

Expand Down

0 comments on commit c6ff7e5

Please sign in to comment.