-
Notifications
You must be signed in to change notification settings - Fork 14
feat: add multi-stage Dockerfile for building and running app #230
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,339 @@ | ||
| # https://github.com/dotnet/runtime/blob/main/.dockerignore | ||
|
|
||
| ### VisualStudio ### | ||
|
|
||
| # Tool Runtime Dir | ||
| **/.dotnet/ | ||
| **/.packages/ | ||
| **/.tools/ | ||
|
|
||
| # User-specific files | ||
| **/*.suo | ||
| **/*.user | ||
| **/*.userosscache | ||
| **/*.sln.docstates | ||
|
|
||
| # Build results | ||
| **/artifacts/ | ||
| **/.idea/ | ||
| **/[Dd]ebug/ | ||
| **/[Dd]ebugPublic/ | ||
| **/[Rr]elease/ | ||
| **/[Rr]eleases/ | ||
| **/bld/ | ||
| **/[Bb]in/ | ||
| **/[Oo]bj/ | ||
| **/msbuild.log | ||
| **/msbuild.err | ||
| **/msbuild.wrn | ||
| **/msbuild.binlog | ||
| **/.deps/ | ||
| **/.dirstamp | ||
| **/.libs/ | ||
| **/*.lo | ||
| **/*.o | ||
|
|
||
| # Cross building rootfs | ||
| **/cross/rootfs/ | ||
| **/cross/android-rootfs/ | ||
|
|
||
| # Visual Studio | ||
| **/.vs/ | ||
|
|
||
| # Ionide | ||
| **/.ionide/ | ||
|
|
||
| # MSTest test Results | ||
| **/[Tt]est[Rr]esult*/ | ||
| **/[Bb]uild[Ll]og.* | ||
|
|
||
| #NUNIT | ||
| **/*.VisualState.xml | ||
| **/TestResult.xml | ||
|
|
||
| # Build Results of an ATL Project | ||
| **/[Dd]ebugPS/ | ||
| **/[Rr]eleasePS/ | ||
| **/dlldata.c | ||
|
|
||
| **/*_i.c | ||
| **/*_p.c | ||
| **/*.ilk | ||
| **/*.meta | ||
| **/*.obj | ||
| **/*.pch | ||
| **/*.pdb | ||
| !**/_.pdb | ||
| **/*.pgc | ||
| **/*.pgd | ||
| **/*.rsp | ||
| **/*.sbr | ||
| **/*.tlb | ||
| **/*.tli | ||
| **/*.tlh | ||
| **/*.tmp | ||
| **/*.tmp_proj | ||
| **/*.log | ||
| **/*.vspscc | ||
| **/*.vssscc | ||
| **/.builds | ||
| **/*.pidb | ||
| **/*.svclog | ||
| **/*.scc | ||
|
|
||
| # Chutzpah Test files | ||
| **/_Chutzpah* | ||
|
|
||
| # Visual C++ cache files | ||
| **/ipch/ | ||
| **/*.aps | ||
| **/*.ncb | ||
| **/*.opendb | ||
| **/*.opensdf | ||
| **/*.sdf | ||
| **/*.cachefile | ||
| **/*.VC.db | ||
|
|
||
| # Visual Studio profiler | ||
| **/*.psess | ||
| **/*.vsp | ||
| **/*.vspx | ||
|
|
||
| # TFS 2012 Local Workspace | ||
| **/$tf/ | ||
|
|
||
| # Guidance Automation Toolkit | ||
| **/*.gpState | ||
|
|
||
| # ReSharper is a .NET coding add-in | ||
| **/_ReSharper*/ | ||
| **/*.[Rr]e[Ss]harper | ||
| **/*.DotSettings.user | ||
|
|
||
| # JustCode is a .NET coding addin-in | ||
| **/.JustCode | ||
|
|
||
| # TeamCity is a build add-in | ||
| **/_TeamCity* | ||
|
|
||
| # DotCover is a Code Coverage Tool | ||
| **/*.dotCover | ||
|
|
||
| # NCrunch | ||
| **/_NCrunch_* | ||
| **/.*crunch*.local.xml | ||
|
|
||
| # MightyMoose | ||
| **/*.mm.* | ||
| **/AutoTest.Net/ | ||
|
|
||
| # Web workbench (sass) | ||
| **/.sass-cache/ | ||
|
|
||
| # Installshield output folder | ||
| **/[Ee]xpress/ | ||
|
|
||
| # DocProject is a documentation generator add-in | ||
| **/DocProject/buildhelp/ | ||
| **/DocProject/Help/*.HxT | ||
| **/DocProject/Help/*.HxC | ||
| **/DocProject/Help/*.hhc | ||
| **/DocProject/Help/*.hhk | ||
| **/DocProject/Help/*.hhp | ||
| **/DocProject/Help/Html2 | ||
| **/DocProject/Help/html | ||
|
|
||
| # Publish Web Output | ||
| **/*.[Pp]ublish.xml | ||
| **/*.azurePubxml | ||
| **/*.pubxml | ||
| **/*.publishproj | ||
|
|
||
| # NuGet Packages | ||
| **/*.nupkg | ||
| **/*.nuget.g.props | ||
| **/*.nuget.g.targets | ||
| **/*.nuget.cache | ||
| **/**/packages/* | ||
| **/project.lock.json | ||
| **/project.assets.json | ||
| **/*.nuget.dgspec.json | ||
|
|
||
| # Windows Azure Build Output | ||
| **/csx/ | ||
| **/*.build.csdef | ||
|
|
||
| # Windows Store app package directory | ||
| **/AppPackages/ | ||
|
|
||
| # Others | ||
| **/*.Cache | ||
| **/ClientBin/ | ||
| **/[Ss]tyle[Cc]op.* | ||
| **/~$* | ||
| **/*.dbmdl | ||
| **/*.dbproj.schemaview | ||
| **/*.pfx | ||
| **/*.publishsettings | ||
| **/node_modules/ | ||
| **/*.metaproj | ||
| **/*.metaproj.tmp | ||
| **/bin.localpkg/ | ||
|
|
||
| # RIA/Silverlight projects | ||
| **/Generated_Code/ | ||
|
|
||
| # Backup & report files from converting an old project file | ||
| # to a newer Visual Studio version. Backup files are not needed, | ||
| # because we have git ;-) | ||
| **/_UpgradeReport_Files/ | ||
| **/Backup*/ | ||
| **/UpgradeLog*.XML | ||
| **/UpgradeLog*.htm | ||
|
|
||
| # SQL Server files | ||
| **/*.mdf | ||
| **/*.ldf | ||
|
|
||
| # Business Intelligence projects | ||
| **/*.rdl.data | ||
| **/*.bim.layout | ||
| **/*.bim_*.settings | ||
|
|
||
| # Microsoft Fakes | ||
| **/FakesAssemblies/ | ||
|
|
||
| # C/C++ extension for Visual Studio Code | ||
| **/browse.VC.db | ||
| # Local settings folder for Visual Studio Code | ||
| **/**/.vscode/** | ||
| !**/**/.vscode/c_cpp_properties.json | ||
|
|
||
| ### MonoDevelop ### | ||
|
|
||
| **/*.pidb | ||
| **/*.userprefs | ||
|
|
||
| ### Windows ### | ||
|
|
||
| # Windows image file caches | ||
| **/Thumbs.db | ||
| **/ehthumbs.db | ||
|
|
||
| # Folder config file | ||
| **/Desktop.ini | ||
|
|
||
| # Recycle Bin used on file shares | ||
| **/$RECYCLE.BIN/ | ||
|
|
||
| # Windows Installer files | ||
| **/*.cab | ||
| **/*.msi | ||
| **/*.msm | ||
| **/*.msp | ||
|
|
||
| # Windows shortcuts | ||
| **/*.lnk | ||
|
|
||
| ### Linux ### | ||
|
|
||
| **/*~ | ||
|
|
||
| # KDE directory preferences | ||
| **/.directory | ||
|
|
||
| ### OSX ### | ||
|
|
||
| **/.DS_Store | ||
| **/.AppleDouble | ||
| **/.LSOverride | ||
|
|
||
| # Icon must end with two \r | ||
| **/Icon | ||
|
|
||
| # Thumbnails | ||
| **/._* | ||
|
|
||
| # Files that might appear on external disk | ||
| **/.Spotlight-V100 | ||
| **/.Trashes | ||
|
|
||
| # Directories potentially created on remote AFP share | ||
| **/.AppleDB | ||
| **/.AppleDesktop | ||
| **/Network Trash Folder | ||
| **/Temporary Items | ||
| **/.apdisk | ||
|
|
||
| # vim temporary files | ||
| **/[._]*.s[a-w][a-z] | ||
| **/[._]s[a-w][a-z] | ||
| **/*.un~ | ||
| **/Session.vim | ||
| **/.netrwhist | ||
| **/*~ | ||
|
|
||
| # Visual Studio Code | ||
| **/.vscode/ | ||
|
|
||
| # Private test configuration and binaries. | ||
| **/config.ps1 | ||
| **/**/IISApplications | ||
|
|
||
| # VS debug support files | ||
| **/launchSettings.json | ||
|
|
||
| # Snapcraft files | ||
| **/.snapcraft | ||
| **/*.snap | ||
| **/parts/ | ||
| **/prime/ | ||
| **/stage/ | ||
|
|
||
| # CLR prebuilt generated files | ||
| !**/src/pal/prebuilt/idl/*_i.c | ||
|
|
||
| # Valid 'debug' folder, that contains CLR debugging code | ||
| !**/src/**/debug | ||
|
|
||
| # Ignore folders created by the CLR test build | ||
| **/TestWrappers_x64_[d|D]ebug | ||
| **/TestWrappers_x64_[c|C]hecked | ||
| **/TestWrappers_x64_[r|R]elease | ||
| **/TestWrappers_x86_[d|D]ebug | ||
| **/TestWrappers_x86_[c|C]hecked | ||
| **/TestWrappers_x86_[r|R]elease | ||
| **/TestWrappers_arm_[d|D]ebug | ||
| **/TestWrappers_arm_[c|C]hecked | ||
| **/TestWrappers_arm_[r|R]elease | ||
| **/TestWrappers_arm64_[d|D]ebug | ||
| **/TestWrappers_arm64_[c|C]hecked | ||
| **/TestWrappers_arm64_[r|R]elease | ||
| **/tests/src/common/test_runtime/project.json | ||
|
|
||
| **/Vagrantfile | ||
| **/.vagrant | ||
|
|
||
| # CMake files | ||
| **/CMakeFiles/ | ||
| **/cmake_install.cmake | ||
| **/CMakeCache.txt | ||
| **/Makefile | ||
|
|
||
| # Cross compilation | ||
| **/cross/rootfs/* | ||
| **/cross/android-rootfs/* | ||
| # add x86 as it is ignored in 'Build results' | ||
| !**/cross/x86 | ||
|
|
||
| #python import files | ||
| **/*.pyc | ||
|
|
||
| # JIT32 files | ||
| **/src/jit32 | ||
|
|
||
| # performance testing sandbox | ||
| **/sandbox | ||
|
|
||
| # Allow the SQLite database to be included | ||
| !src/Dotnet.Samples.AspNetCore.WebApi/Data/players-sqlite3.db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # - Stage 1 -------------------------------------------------------------------- | ||
|
|
||
| FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||
| WORKDIR /src | ||
|
|
||
| # Copy and restore dependencies | ||
| COPY src/Dotnet.Samples.AspNetCore.WebApi/*.csproj ./Dotnet.Samples.AspNetCore.WebApi/ | ||
| RUN dotnet restore ./Dotnet.Samples.AspNetCore.WebApi | ||
|
|
||
| # Copy source and publish | ||
| COPY src/Dotnet.Samples.AspNetCore.WebApi ./Dotnet.Samples.AspNetCore.WebApi | ||
| WORKDIR /src/Dotnet.Samples.AspNetCore.WebApi | ||
| RUN dotnet publish -c Release -o /app/publish | ||
|
|
||
| # - Stage 2 -------------------------------------------------------------------- | ||
|
|
||
| FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime | ||
| WORKDIR /app | ||
|
|
||
| # Copy published output | ||
| # Note: This includes the SQLite database because it's marked as <Content> with | ||
| # <CopyToOutputDirectory> in the .csproj file. No need to copy it manually. | ||
| COPY --from=build /app/publish . | ||
|
|
||
| # Add non-root user (aspnetcore) for security hardening | ||
| RUN adduser --disabled-password --gecos '' aspnetcore \ | ||
| && chown -R aspnetcore:aspnetcore /app | ||
| USER aspnetcore | ||
|
|
||
| # Set environment variables | ||
| ENV ASPNETCORE_URLS=http://+:9000 | ||
| ENV ASPNETCORE_ENVIRONMENT=Production | ||
|
|
||
| # Default entrypoint | ||
| ENTRYPOINT ["dotnet", "Dotnet.Samples.AspNetCore.WebApi.dll"] | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.