Skip to content

Commit

Permalink
add - Add Docker support
Browse files Browse the repository at this point in the history
---

This adds support for Docker containerization for Nitrocid KS.

---

Type: add
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Sep 17, 2024
1 parent 38db92d commit fd36806
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build Project (Docker)

on:
push:
branches: [ "main", "v0.1.0.x-saas", "v0.1.1.x-servicing" ]
pull_request:
branches: [ "main", "v0.1.0.x-saas", "v0.1.1.x-servicing" ]

jobs:
build:
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Build Docker image
id: push
uses: docker/build-push-action
with:
context: .
file: ./Dockerfile
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

44 changes: 44 additions & 0 deletions .github/workflows/pushdocker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Push to Docker

on:
push:
tags:
- 'v0.1.*'

jobs:
build:
runs-on: ubuntu-24.04

permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Prepare Docker (auth)
uses: docker/login-action
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action
with:
images: eofla/nitrocid
- name: Build and push Docker image
id: push
uses: docker/build-push-action
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /NKS

# Initialize the project files
COPY . ./

# Attempt to build Nitrocid KS
RUN dotnet restore
RUN dotnet publish -c Release -o out

# Run the ASP.NET image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /NKS

# Copy the output files and start Nitrocid KS
COPY --from=build-env /NKS/out .
ENTRYPOINT ["dotnet", "Nitrocid.dll"]

0 comments on commit fd36806

Please sign in to comment.