File tree Expand file tree Collapse file tree 2 files changed +73
-0
lines changed Expand file tree Collapse file tree 2 files changed +73
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Build and Push Public Image
2
+
3
+ on :
4
+ push :
5
+ branches : [ main ]
6
+ workflow_dispatch :
7
+ inputs :
8
+ version_tag :
9
+ description : ' Optional version tag (e.g. v1.0.0)'
10
+ required : false
11
+ type : string
12
+
13
+ jobs :
14
+ build-and-push :
15
+ runs-on : ubuntu-latest
16
+ permissions :
17
+ contents : read
18
+ packages : write
19
+
20
+ steps :
21
+ - uses : actions/checkout@v4
22
+
23
+ - name : Log in to GitHub Container Registry
24
+ uses : docker/login-action@v3
25
+ with :
26
+ registry : ghcr.io
27
+ username : ${{ github.actor }}
28
+ password : ${{ secrets.GITHUB_TOKEN }}
29
+
30
+ - name : Set image names
31
+ id : vars
32
+ run : |
33
+ IMAGE_BASE=ghcr.io/${{ github.repository_owner }}/k8s-restart
34
+ echo "IMAGE_LATEST=$IMAGE_BASE:latest" >> $GITHUB_OUTPUT
35
+ if [[ -n "${{ github.event.inputs.version_tag }}" ]]; then
36
+ echo "IMAGE_VERSION=$IMAGE_BASE:${{ github.event.inputs.version_tag }}" >> $GITHUB_OUTPUT
37
+ fi
38
+
39
+ - name : Build once and tag
40
+ run : |
41
+ docker build -t ${{ steps.vars.outputs.IMAGE_LATEST }} .
42
+ if [ -n "${{ steps.vars.outputs.IMAGE_VERSION }}" ]; then
43
+ docker tag ${{ steps.vars.outputs.IMAGE_LATEST }} ${{ steps.vars.outputs.IMAGE_VERSION }}
44
+ fi
45
+
46
+ - name : Push all tags
47
+ run : |
48
+ docker push ${{ steps.vars.outputs.IMAGE_LATEST }}
49
+ if [ -n "${{ steps.vars.outputs.IMAGE_VERSION }}" ]; then
50
+ docker push ${{ steps.vars.outputs.IMAGE_VERSION }}
51
+ fi
Original file line number Diff line number Diff line change
1
+ # 🛠 Build stage
2
+ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
3
+ WORKDIR /src
4
+
5
+ # Copy and restore project
6
+ COPY K8sControlApi.csproj ./
7
+ RUN dotnet restore
8
+
9
+ # Copy the rest of the app
10
+ COPY . ./
11
+ RUN dotnet publish -c Release -o /app/publish
12
+
13
+ # 🚀 Runtime stage
14
+ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
15
+ WORKDIR /app
16
+ COPY --from=build /app/publish .
17
+
18
+ # Expose HTTP port
19
+ EXPOSE 80
20
+
21
+ # Entry point
22
+ ENTRYPOINT ["dotnet", "K8sControlApi.dll"]
You can’t perform that action at this time.
0 commit comments