diff --git a/Dockerfile b/Dockerfile index 2919519..cc47752 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,23 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0 +# Build stage +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build WORKDIR /src -# copy solution and project files +# Copy solution and project files COPY ["PayrollEngine.PayrollConsole.sln", "./"] COPY ["PayrollConsole/PayrollEngine.PayrollConsole.csproj", "PayrollConsole/"] COPY ["Commands/PayrollEngine.PayrollConsole.Commands.csproj", "Commands/"] - -# copy Directory.Build.props COPY ["Directory.Build.props", "./"] +# Restore dependencies (cached layer) RUN dotnet restore "PayrollEngine.PayrollConsole.sln" -# copy everything else +# Copy remaining source files and publish COPY . . WORKDIR "/src/PayrollConsole" -RUN dotnet publish "PayrollEngine.PayrollConsole.csproj" -c Release -o /app/publish +RUN dotnet publish "PayrollEngine.PayrollConsole.csproj" -c Release -o /app/publish --no-restore -# final stage -FROM mcr.microsoft.com/dotnet/runtime:9.0 +# Runtime stage +FROM mcr.microsoft.com/dotnet/aspnet:9.0 WORKDIR /app -COPY --from=0 /app/publish . -ENTRYPOINT ["dotnet", "PayrollEngine.PayrollConsole.dll"] \ No newline at end of file +COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "PayrollEngine.PayrollConsole.dll"] diff --git a/README.md b/README.md index 95d6ae0..40f55c4 100644 --- a/README.md +++ b/README.md @@ -204,17 +204,15 @@ The payroll console stores its logs in the application folder `logs`. ## Docker Support Build the Docker image: ```bash -docker build -t payroll-console . +docker build --no-cache -t payroll-console . ``` -Run the Docker Payroll Console: +Run the container to deploy the examples/local files with the environment variable (if appsettings.json is not used): ```bash -docker run -it --rm payroll-console Setup.pecmd -``` - -Delete the Docker image: -```bash -docker stop payroll-console +docker run -it --rm \ + -e PayrollApiConnection="baseUrl=http://;port=;..." \ + -v "$(pwd)/PayrollEngine/examples":/examples \ + payroll-console /examples/Setup.All.pecmd ``` ## Solution projects