DiscordChatExporter/DiscordChatExporter.Cli.dockerfile

46 lines
1.7 KiB
Text
Raw Normal View History

2023-01-05 07:20:49 -05:00
# -- Build
2023-05-10 15:02:50 -04:00
# Use the same platform for the build image as the runtime image, so that it's easier
# to produce a self-contained assembly for the right platform.
FROM mcr.microsoft.com/dotnet/sdk:7.0-runtime AS build
WORKDIR /build
2022-06-18 15:37:24 -04:00
COPY favicon.ico ./
COPY NuGet.config ./
COPY Directory.Build.props ./
COPY DiscordChatExporter.Core ./DiscordChatExporter.Core
COPY DiscordChatExporter.Cli ./DiscordChatExporter.Cli
2023-05-10 15:02:50 -04:00
# Publish a self-contained assembly so we can use a slimmer runtime image
RUN dotnet publish DiscordChatExporter.Cli \
--self-contained \
--use-current-runtime \
--configuration Release \
--output ./publish
2022-06-18 15:37:24 -04:00
2023-01-05 07:20:49 -05:00
# -- Run
2023-05-10 15:02:50 -04:00
# Use Alpine for the runtime image due to its smaller size.
# Use `runtime-deps` instead of `runtime` since we're running a self-contained assembly.
# https://github.com/dotnet/dotnet-docker/blob/main/samples/selecting-tags.md
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine
2022-06-18 15:37:24 -04:00
2023-05-10 15:02:50 -04:00
# Alpine image doesn't include timezone data, which is needed for certain date/time operations
# https://github.com/dotnet/dotnet-docker/blob/main/samples/enable-globalization.md
RUN apk add --no-cache tzdata
2023-01-05 07:20:49 -05:00
2023-05-10 15:02:50 -04:00
# Create a non-root user to run the app, so that the output files can be accessed by the host
2023-01-05 07:20:49 -05:00
# https://github.com/Tyrrrz/DiscordChatExporter/issues/851
2023-05-10 15:02:50 -04:00
RUN adduser --disabled-password --no-create-home dce
USER dce
2023-01-05 07:20:49 -05:00
COPY --from=build /build/publish /opt/dce
2022-10-16 09:34:31 -04:00
2023-05-10 15:02:50 -04:00
# Add the app directory to the PATH so that it's easier to run the app via `docker exec`
ENV PATH="$PATH:/opt/dce"
# This directory is exposed to the user for mounting purposes, so it's important
# that it stays the same for backwards compatibility.
WORKDIR /out
2022-10-16 09:34:31 -04:00
ENTRYPOINT ["DiscordChatExporter.Cli"]