Created
March 10, 2026 09:51
-
-
Save AaronSadlerUK/683d64e0af1c3462c2fc1206a3b561eb to your computer and use it in GitHub Desktop.
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
| # Git | |
| .git | |
| .gitignore | |
| .gitattributes | |
| */.github | |
| # Build outputs | |
| **/bin/ | |
| **/obj/ | |
| **/out/ | |
| **/publish/ | |
| # Visual Studio / Rider | |
| .vs/ | |
| .vscode/ | |
| .idea/ | |
| *.suo | |
| *.user | |
| *.userosscache | |
| *.sln.docstates | |
| *.userprefs | |
| .idea/ | |
| # NuGet | |
| *.nupkg | |
| *.snupkg | |
| packages/ | |
| .nuget/ | |
| # Test results | |
| [Tt]est[Rr]esult*/ | |
| [Bb]uild[Ll]og.* | |
| *.trx | |
| *.coverage | |
| # Umbraco specific | |
| **/App_Data/ | |
| **/umbraco/Data/ | |
| **/umbraco/Logs/ | |
| **/wwwroot/media/ | |
| umbraco.config | |
| # Node modules (if you have front-end build) | |
| **/node_modules/ | |
| **/npm-debug.log | |
| **/yarn-error.log | |
| # OS files | |
| .DS_Store | |
| Thumbs.db | |
| *.swp | |
| *.swo | |
| *~ | |
| # Docker | |
| Dockerfile | |
| .dockerignore | |
| docker-compose*.yml | |
| *.md | |
| # CI/CD | |
| .github/ | |
| .gitlab-ci.yml | |
| azure-pipelines.yml | |
| # Logs | |
| *.log | |
| logs/ | |
| # Environment files | |
| .env | |
| .env.* | |
| !.env.example |
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
| "HealthChecks": { | |
| "DisabledChecks": [ | |
| { | |
| "Id": "EB66BB3B-1BCD-4314-9531-9DA2C1D6D9A7" | |
| } | |
| ] | |
| } |
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
| using Umbraco.Cms.Core.Composing; | |
| using Umbraco.Cms.Core.DependencyInjection; | |
| using Umbraco.Cms.Infrastructure.Runtime.RuntimeModeValidators; | |
| using Umbraco.Extensions; | |
| public class DockerChecksRemover : IComposer | |
| { | |
| public void Compose(IUmbracoBuilder builder) | |
| => builder.RuntimeModeValidators().Remove<UseHttpsValidator>(); | |
| } |
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
| FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base | |
| WORKDIR /app | |
| EXPOSE 8080 | |
| FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build | |
| ARG BUILD_CONFIGURATION=Release | |
| WORKDIR /src | |
| COPY . ./ | |
| RUN dotnet restore "WEB_PROJECT_FOLDER/WEB_PROJECT_NAME.csproj" --locked-mode | |
| RUN dotnet build "WEB_PROJECT_FOLDER/WEB_PROJECT_NAME.csproj" -c $BUILD_CONFIGURATION --no-restore | |
| FROM build AS publish | |
| RUN dotnet publish "WEB_PROJECT_FOLDER/WEB_PROJECT_NAME.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false --no-build | |
| FROM base AS final | |
| RUN groupadd -g 1000 appuser && useradd -u 1000 -g 1000 -m appuser | |
| WORKDIR /app | |
| COPY --chown=1000:1000 --from=publish /app/publish . | |
| USER 1000:1000 | |
| ENTRYPOINT ["dotnet", "WEB_PROJECT_NAME.dll", "--console-logger-format=json"] |
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
| name: Build and Push Docker Image | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: GITHUB_ACCOUNT_NAME/DOCKER_IMAGE_NAME | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| submodules: 'true' | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Generate timestamp | |
| id: timestamp | |
| run: echo "tag=$(date +'%H%M%S%d%m%Y')" >> $GITHUB_OUTPUT | |
| - name: Build and push | |
| working-directory: ./ | |
| run: | | |
| docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.timestamp.outputs.tag }} . | |
| docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.timestamp.outputs.tag }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
| docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.timestamp.outputs.tag }} | |
| docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
| echo "Published: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.timestamp.outputs.tag }}" | |
| - name: Trigger webhook | |
| run: curl -fS -X POST ${{secrets.WEBHOOK_ENDPOINT}} |
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
| var builder = WebApplication.CreateBuilder(args); | |
| builder.Services.Configure<ForwardedHeadersOptions>(options => | |
| { | |
| options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; | |
| options.RequireHeaderSymmetry = false; | |
| options.KnownNetworks.Clear(); | |
| options.KnownProxies.Clear(); | |
| }); | |
| builder.Services.AddHealthChecks(); | |
| ConfigureBuilder(builder); | |
| var app = builder.Build(); | |
| app.UseForwardedHeaders(); | |
| await app.BootUmbracoAsync(); | |
| app.MapHealthChecks("/health"); |
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
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| services.Configure<ForwardedHeadersOptions>(options => | |
| { | |
| options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; | |
| options.RequireHeaderSymmetry = false; | |
| options.KnownNetworks.Clear(); | |
| options.KnownProxies.Clear(); | |
| }); | |
| services.AddHealthChecks(); | |
| services.AddUmbraco(_env, _config) | |
| .AddBackOffice() | |
| .AddWebsite() | |
| .AddDeliveryApi() | |
| .AddComposers() | |
| .Build(); | |
| } | |
| public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | |
| { | |
| app.UseForwardedHeaders(); | |
| app.UseUmbraco() | |
| .WithMiddleware(u => | |
| { | |
| u.UseBackOffice(); | |
| u.UseWebsite(); | |
| }) | |
| .WithEndpoints(u => | |
| { | |
| u.UseInstallerEndpoints(); | |
| u.UseBackOfficeEndpoints(); | |
| u.UseWebsiteEndpoints(); | |
| u.EndpointRouteBuilder.MapHealthChecks("/health"); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment