diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index fe67631..99d9abd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,10 @@ { "name": "C# (.NET)", - "image": "mcr.microsoft.com/devcontainers/dotnet:10.0", + "build": { + "dockerfile": "../Dockerfile", + "context": "..", + "target": "dev" + }, "features": { "ghcr.io/devcontainers/features/github-cli:1": { "installDirectlyFromGitHubRelease": true, diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c2720b3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,29 @@ +# Git version control +.git +.gitignore +.gitattributes +.github/ + +# .NET Build outputs and local caches +**/bin/ +**/obj/ +**/publish/ +.vs/ +.vscode/ + +# Environment variables and secrets +.env +*.user +*.suo + +# Docker files themselves +Dockerfile +.dockerignore +docker-compose* +.devcontainer/ + +# OS specific files +.DS_Store +Thumbs.db + +CloneDevOpsTemplateTest/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..09bc963 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# Development stage, selected by devcontainer.json +FROM mcr.microsoft.com/devcontainers/dotnet:10.0 AS dev +WORKDIR /app + +# Production publish stage +FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS publish +ARG BUILD_CONFIGURATION=Release +WORKDIR /src + +COPY CloneDevOpsTemplate . +RUN dotnet restore CloneDevOpsTemplate.csproj +RUN dotnet publish CloneDevOpsTemplate.csproj \ + -c $BUILD_CONFIGURATION \ + -o /app/publish \ + /p:UseAppHost=false + +# Production runtime stage +FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine AS production +WORKDIR /app +EXPOSE 8080 +USER app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "CloneDevOpsTemplate.dll"]