Add Docker support and CI workflow for build and push
Build and Push Docker Image / build-and-push (push) Successful in 1m25s

Added .dockerignore and Dockerfile for containerization. Introduced GitHub Actions workflow to build and push images to Gitea registry. Updated project file with Docker properties and Azure Containers Tools package. Enhanced launchSettings.json with Docker profile and improved environment settings.
This commit is contained in:
Arne Moerman
2026-05-03 10:34:46 +02:00
parent 294c197d62
commit 795d4606d7
5 changed files with 119 additions and 22 deletions
+30
View File
@@ -0,0 +1,30 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
+36
View File
@@ -0,0 +1,36 @@
name: Build and Push Docker Image
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate datetime tag
id: vars
run: echo "tag=$(date +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT
- name: Log in to Gitea Registry
uses: docker/login-action@v3
with:
registry: git.arnemoerman.be
username: arne
password: ${{ secrets.PAT_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./For Real Consulting
file: ./For Real Consulting/Dockerfile
push: true
tags: |
git.arnemoerman.be/arne/for-real-consulting:latest
git.arnemoerman.be/arne/for-real-consulting:${{ steps.vars.outputs.tag }}
+17
View File
@@ -0,0 +1,17 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY ["For Real Consulting/For Real Consulting.csproj", "For Real Consulting/"]
RUN dotnet restore "For Real Consulting/For Real Consulting.csproj"
COPY . .
WORKDIR "/src/For Real Consulting"
RUN dotnet publish "For Real Consulting.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
WORKDIR /app
COPY --from=build /app/publish .
EXPOSE 8080
ENV ASPNETCORE_URLS=http://+:8080
ENTRYPOINT ["dotnet", "For_Real_Consulting.dll"]
@@ -8,6 +8,8 @@
<RootNamespace>For_Real_Consulting</RootNamespace>
<AssemblyName>$(AssemblyName.Replace(' ', '_'))</AssemblyName>
<BlazorDisableThrowNavigationException>true</BlazorDisableThrowNavigationException>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..</DockerfileContext>
</PropertyGroup>
<ItemGroup>
@@ -17,6 +19,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.6" PrivateAssets="all" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.6" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
</ItemGroup>
<ItemGroup>
@@ -1,25 +1,36 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://for-real-consulting.dev.localhost:5211",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://for-real-consulting.dev.localhost:7106;http://for-real-consulting.dev.localhost:5211",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
"dotnetRunMessages": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://for-real-consulting.dev.localhost:5211"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://for-real-consulting.dev.localhost:7106;http://for-real-consulting.dev.localhost:5211"
},
"Container (Dockerfile)": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "8081",
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true,
"useSSL": true
}
}
},
"$schema": "https://json.schemastore.org/launchsettings.json"
}