Skip to content

Commit

Permalink
build: update Dockerfile and project file references
Browse files Browse the repository at this point in the history
- Ignore the `.dockerignore` file in the git diff
- Update the base image in the `Dockerfile` from `dotnet/runtime:6.0-alpine` to `dotnet/runtime:8.0-alpine`
- Adjust the build configuration in the `Dockerfile` to use the `BUILD_CONFIGURATION` argument
- Update the `dotnet restore` command in the `Dockerfile` to remove the directory path
- Update the build command in the `Dockerfile` to use the `BUILD_CONFIGURATION` argument
- Adjust the publish command in the `Dockerfile` to use the `BUILD_CONFIGURATION` argument and disable the app host usage
- Remove the user creation and ownership changes in the `Dockerfile`
- Update the project file `YoutubeLiveChatToDiscord.csproj` to include a reference to `Microsoft.VisualStudio.Azure.Containers.Tools.Targets` version 1.19.5

Signed-off-by: 陳鈞 <[email protected]>
  • Loading branch information
jim60105 committed Dec 2, 2023
1 parent 32f0bc0 commit 47dae03
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
README.md
**/helm-chart
**/.github
.dockerignore
.gitignore
23 changes: 10 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
#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.

FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine AS base
FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine AS base
WORKDIR /app
RUN apk add --no-cache --virtual build-deps musl-dev gcc g++ python3-dev &&\
apk add --no-cache py3-pip tzdata &&\
Expand All @@ -12,24 +12,21 @@ ENV TZ=Asia/Taipei
# https://github.com/dotnet/runtime/issues/34126#issuecomment-1104981659
ENV DOTNET_SYSTEM_IO_DISABLEFILELOCKING=true

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["YoutubeLiveChatToDiscord.csproj", "."]
RUN dotnet restore "./YoutubeLiveChatToDiscord.csproj"
RUN dotnet restore "YoutubeLiveChatToDiscord.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "YoutubeLiveChatToDiscord.csproj" -c Release -o /app/build
RUN dotnet build "YoutubeLiveChatToDiscord.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
RUN dotnet publish "YoutubeLiveChatToDiscord.csproj" -c Release -o /app/publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "YoutubeLiveChatToDiscord.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

RUN addgroup -g 1000 docker && \
adduser -u 1000 -G docker -h /home/docker -s /bin/sh -D docker \
&& chown -R 1000:1000 .
USER docker

RUN mkdir -p /app && chown -R app:app /app
USER app
ENTRYPOINT ["dotnet", "YoutubeLiveChatToDiscord.dll"]
1 change: 1 addition & 0 deletions YoutubeLiveChatToDiscord.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Discord.Net.Webhook" Version="3.13.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="YoutubeDLSharp" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
</ItemGroup>
Expand Down

0 comments on commit 47dae03

Please sign in to comment.