-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add usage samples #6
base: main
Are you sure you want to change the base?
Conversation
The sample includes a basic console application and a Dockerfile
Right now I'm using I'll try to implement something from this article to use |
So, the .NET Framework is a bit more complicated because the tool I created needs the .NET Core runtime to run. Furthermore so, the Here are two options: Option 1# escape=`
# BUILDER
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 as build
WORKDIR /src
COPY src/ ./
RUN dotnet restore ConsoleApp/ConsoleApp.csproj
RUN dotnet publish ConsoleApp/ConsoleApp.csproj -c Release -o /out
# TOOLS
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 as tools
RUN dotnet tool install EMG.Tools.EnsureUnique --tool-path C:\tools
# RUNNER
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8 AS runtime
ADD https://dotnet.microsoft.com/download/dotnet-core/scripts/v1/dotnet-install.ps1 C:\temp\
RUN powershell C:\temp\dotnet-install.ps1 -Channel LTS -Runtime dotnet -InstallDir C:\dotnet
ARG DOTNET_PATH=C:\dotnet\
ARG DOTNET_TOOLS_PATH=C:\tools\
RUN SETX DOTNET_ROOT %DOTNET_PATH%
RUN SETX PATH %PATH%;%DOTNET_PATH%;%DOTNET_TOOLS_PATH%
ENV DotNetEnsureUnique__S3__BucketName= `
DotNetEnsureUnique__S3__FilePrefix= `
DOTNET_CLI_TELEMETRY_OPTOUT=1
COPY --from=tools C:\tools\ C:\tools\
WORKDIR /app
COPY --from=build /out .
ENTRYPOINT ["dotnet-ensure-unique", "exe", "ConsoleApp.exe"] Option 1 in pills
Option 2# escape=`
# BUILDER
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 as build
WORKDIR /src
COPY src/ ./
RUN dotnet restore ConsoleApp/ConsoleApp.csproj
RUN dotnet publish ConsoleApp/ConsoleApp.csproj -c Release -o /out
# RUNNER
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8 AS runtime
ADD https://dotnet.microsoft.com/download/dotnet-core/scripts/v1/dotnet-install.ps1 C:\temp\
ARG DOTNET_PATH=C:\dotnet\
RUN powershell C:\temp\dotnet-install.ps1 -Channel LTS -InstallDir %DOTNET_PATH%
RUN SETX DOTNET_ROOT %DOTNET_PATH%
RUN SETX PATH %PATH%;%DOTNET_PATH%
ENV DotNetEnsureUnique__S3__BucketName= `
DotNetEnsureUnique__S3__FilePrefix= `
DOTNET_CLI_TELEMETRY_OPTOUT=1
RUN dotnet tool install -g EMG.Tools.EnsureUnique
WORKDIR /app
COPY --from=build /out .
ENTRYPOINT ["dotnet", "ensure-unique", "exe", "ConsoleApp.exe"] Option 2 in pills:
Personally, I'd go for Option 1, even if using |
Running the containers: The .NET Core and the .NET Framework containers can be run at the same time. Using environmental variablesPS> docker run --rm -e DotNetEnsureUnique__S3__BucketName=my-bucket-name -e DotNetEnsureUnique__S3__FilePrefix=apps/console console-sample Using parametersPS> docker run --rm console-sample --bucket my-bucket-name --prefix apps/console Local executionTo use the container locally, you can mount the This can be done by adding the following to the command: |
@McDoit @simgu I welcome your opinion on this comment |
Yeah i would go for option 1, BUT, maybe put the runtime/tools part into its own (public) image and just reference that one? |
@McDoit you don't need to quote the whole message every time 😜 (I edited your comment removing the giga-quote) We can definitely make a public image for the tool but in terms of dockerfile you wouldn't spare much. Also, it would be kind of a magic trick to use a COPY from a public image to get the binaries of the tool. |
I vote for number 1 as well |
@Kralizek Was thinking to put the tools part in a image:
and then this in the app dockerfile:
|
I'd make a difference between a conceptual sample and (like in this PR) and the operative best practices (that could be shown in a different sample). Also, docker is changing their policy and limits for pulling images from docker hub. |
Examples of using the ensure-unique tool.
Fixes #5