2 Commits
Author SHA1 Message Date
David Claeys c0448dc4a5 make 8.0 alpine 22 branch
Build docker container / build (release) Successful in 1m32s
2025-11-26 17:19:32 +01:00
David Claeys ff0e8a0c7f make 8.0 branch
Build docker container / build (release) Successful in 1m36s
2025-11-26 16:24:10 +01:00
3 changed files with 26 additions and 137 deletions

No files matched your search

+14 -114
View File
@@ -1,120 +1,24 @@
name: 'Build docker container'
on:
workflow_dispatch:
inputs:
branch:
description: "Select branch to build"
required: true
type: choice
options:
- 10.0-alpine-24
- 10.0-alpine-23
- 9.0-alpine-24
- 9.0-alpine-23
- 9.0-alpine-22
- 9.0-alpine-21
- 8.0-alpine-22
- 8.0-alpine-21
release:
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ github.workspace }}
working-directory: ${{ GITHUB_WORKSPACE }}
steps:
- name: Checkout
uses: actions/checkout@v3
#- name: Set build variables for docker build
# id: variables-test
# uses: https://git.claeyscloud.com/david/gitea-actions/conditional-variables@main
# with:
# context: |
# branch=${{ inputs.branch }}
# rules: |
# - conditions:
# - branch == 9.0-alpine-24
# - branch == 9.0-alpine-23
# set:
# DOTNET_SDK_VERSION=9.0
# DOTNET_RUNTIME_VERSION=9.0.18
# - conditions:
# - branch == 9.0-alpine-24
# set:
# ALPINE_VERSION=24
#- name: Dump contexts
# env:
# GITEA_CONTEXT: ${{ toJson(gitea) }}
# JOB_CONTEXT: ${{ toJson(job) }}
# RUNNER_CONTEXT: ${{ toJson(runner) }}
# STRATEGY_CONTEXT: ${{ toJson(strategy) }}
# MATRIX_CONTEXT: ${{ toJson(matrix) }}
# run: |
# echo "=== ENVIRONMENT VARIABLES ==="
# echo '${{ toJson(steps.variables-test.outputs) }}'
# # echo "$GITEA_CONTEXT"
# # echo "$JOB_CONTEXT"
# # echo "$RUNNER_CONTEXT"
# # echo "$STRATEGY_CONTEXT"
# # echo "$MATRIX_CONTEXT"
- name: Set build variables for docker build
id: variables
- name: Install Docker
run: |
case "${{ inputs.branch }}" in
10.0-alpine-24)
echo "DOTNET_SDK_VERSION=10.0" >> $GITHUB_OUTPUT
echo "DOTNET_RUNTIME_VERSION=10.0.12" >> $GITHUB_OUTPUT
echo "ALPINE_VERSION=3.24" >> $GITHUB_OUTPUT
echo "IS_LATEST=true" >> $GITHUB_OUTPUT
;;
10.0-alpine-23)
echo "DOTNET_SDK_VERSION=10.0" >> $GITHUB_OUTPUT
echo "DOTNET_RUNTIME_VERSION=10.0.12" >> $GITHUB_OUTPUT
echo "ALPINE_VERSION=3.23" >> $GITHUB_OUTPUT
echo "IS_LATEST=false" >> $GITHUB_OUTPUT
;;
9.0-alpine-24)
echo "DOTNET_SDK_VERSION=9.0" >> $GITHUB_OUTPUT
echo "DOTNET_RUNTIME_VERSION=9.0.19" >> $GITHUB_OUTPUT
echo "ALPINE_VERSION=3.24" >> $GITHUB_OUTPUT
echo "IS_LATEST=false" >> $GITHUB_OUTPUT
;;
9.0-alpine-23)
echo "DOTNET_SDK_VERSION=9.0" >> $GITHUB_OUTPUT
echo "DOTNET_RUNTIME_VERSION=9.0.19" >> $GITHUB_OUTPUT
echo "ALPINE_VERSION=3.23" >> $GITHUB_OUTPUT
echo "IS_LATEST=false" >> $GITHUB_OUTPUT
;;
9.0-alpine-22)
echo "DOTNET_SDK_VERSION=9.0" >> $GITHUB_OUTPUT
echo "DOTNET_RUNTIME_VERSION=9.0" >> $GITHUB_OUTPUT
echo "ALPINE_VERSION=3.22" >> $GITHUB_OUTPUT
echo "IS_LATEST=false" >> $GITHUB_OUTPUT
;;
9.0-alpine-21)
echo "DOTNET_SDK_VERSION=9.0" >> $GITHUB_OUTPUT
echo "DOTNET_RUNTIME_VERSION=9.0" >> $GITHUB_OUTPUT
echo "ALPINE_VERSION=3.21" >> $GITHUB_OUTPUT
echo "IS_LATEST=false" >> $GITHUB_OUTPUT
;;
8.0-alpine-22)
echo "DOTNET_SDK_VERSION=8.0" >> $GITHUB_OUTPUT
echo "DOTNET_RUNTIME_VERSION=8.0" >> $GITHUB_OUTPUT
echo "ALPINE_VERSION=3.22" >> $GITHUB_OUTPUT
echo "IS_LATEST=false" >> $GITHUB_OUTPUT
;;
8.0-alpine-21)
echo "DOTNET_SDK_VERSION=8.0" >> $GITHUB_OUTPUT
echo "DOTNET_RUNTIME_VERSION=8.0" >> $GITHUB_OUTPUT
echo "ALPINE_VERSION=3.21" >> $GITHUB_OUTPUT
echo "IS_LATEST=false" >> $GITHUB_OUTPUT
;;
*)
echo "Unsupported branch"
exit 1
;;
esac
- name: Setup docker
uses: https://git.claeyscloud.com/david/gitea-actions/setup-docker@main
echo "Checking docker installation"
if command -v docker &> /dev/null; then
echo "Docker installation found"
else
echo "Docker installation not found. Docker will be installed"
curl -fsSL https://get.docker.com | sh
fi
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
- name: Docker login
@@ -128,13 +32,13 @@ jobs:
uses: docker/metadata-action@v5
with:
labels: |
org.opencontainers.image.documentation=https://git.claeyscloud.com/david/net-base/README.md
org.opencontainers.image.documentation=https://git.claeyscloud.com/david/epg-info-docker/src/branch/main/README.md
images: |
git.claeyscloud.com/david/net-base
tags: |
type=raw,value=${{ inputs.branch }}
type=raw,value=latest,enable=${{ steps.variables.outputs.IS_LATEST == 'true' }}
type=semver,pattern={{raw}}
type=sha
type=semver,pattern={{version}}
- name: Generate random password for certificate
id: password
run:
@@ -142,11 +46,7 @@ jobs:
- name: Build and push
uses: https://github.com/docker/build-push-action@v5
with:
build-args: |
CERT_PASSWORD=${{ steps.password.outputs.secret }}
DOTNET_SDK_VERSION=${{ steps.variables.outputs.DOTNET_SDK_VERSION }}
DOTNET_RUNTIME_VERSION=${{ steps.variables.outputs.DOTNET_RUNTIME_VERSION }}
ALPINE_VERSION=${{ steps.variables.outputs.ALPINE_VERSION }}
build-args: CERT_PASSWORD=${{ steps.password.outputs.secret }}
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
+4 -4
View File
@@ -1,9 +1,9 @@
ARG CERT_PASSWORD
ARG DOTNET_SDK_VERSION=10.0.100
ARG DOTNET_RUNTIME_VERSION=10.0.0
ARG DOTNET_SDK_VERSION=8.0.416
ARG DOTNET_RUNTIME_VERSION=8.0.22
ARG ALPINE_VERSION=3.22
ARG CONFIG_DIRECTORY_ARG=/config
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_SDK_VERSION}-alpine${ALPINE_VERSION} AS build-env
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_SDK_VERSION}-alpine${ALPINE_VERSION}-amd64 AS build-env
ARG CONFIG_DIRECTORY_ARG
ENV CONFIG_DIRECTORY=$CONFIG_DIRECTORY_ARG
ARG CERT_PASSWORD
@@ -13,7 +13,7 @@ RUN mkdir $CONFIG_DIRECTORY \
&& rm -rf /var/cache/apk/* \
&& dotnet dev-certs https --export-path /config/aspnetapp.pem --password "$CERT_PASSWORD" --format PEM
FROM mcr.microsoft.com/dotnet/aspnet:${DOTNET_RUNTIME_VERSION}-alpine${ALPINE_VERSION}
FROM mcr.microsoft.com/dotnet/aspnet:${DOTNET_RUNTIME_VERSION}-alpine${ALPINE_VERSION}-amd64
ARG CONFIG_DIRECTORY_ARG
ENV CONFIG_DIRECTORY=$CONFIG_DIRECTORY_ARG
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
+8 -19
View File
@@ -22,7 +22,7 @@ The following is just an example of how your Dockerfile could look like.
```sh
# Password for the certificate
# this image contains the entire .NET SDK and is ideal for creation the build
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine-amd64 AS build-env
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine-amd64 AS build-env
WORKDIR /App
COPY . ./
# Restore dependencies for your application
@@ -46,7 +46,7 @@ ENTRYPOINT ["dotnet", "test.dll"]
|-----------------------------------------------------|-------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|
| ASPNETCORE_Kestrel__Certificates__Default__Path | The path containing the server certificate | /usr/local/share/ca-certificates/aspnetapp.crt |
| ASPNETCORE_Kestrel__Certificates__Default__KeyPath | The path containing the key for the server certificate | /usr/local/share/ca-certificates/aspnetapp.key |
| ASPNETCORE_Kestrel__Certificates__Default__Password | The password for required for the server key | N/A (generated at build time through CERT_PASSWORD argument) |
| ASPNETCORE_Kestrel__Certificates__Default__Password | The password for required for the server key | N/A (generated at build time) |
| CERTIFICATES_DIRECTORY | The directory where the certificate files are stored for the web server | /usr/local/share/ca-certificates |
| ASPNETCORE_URLS | Specifies at which urls and ports the Kestrel server should listen | http://+:80;https://+:443 |
| DOTNET_CLI_TELEMETRY_OPTOUT | Disables telemetry | 1 |
@@ -66,8 +66,8 @@ docker build --build-arg CERT_PASSWORD=supersecretpassword . -t net-base
| Argument | Description | Default |
|-----------------------------------------------------|-------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|
| CERT_PASSWORD | The password for the generated certificate | N/A **(required)** |
| DOTNET_SDK_VERSION | The [SDK](https://mcr.microsoft.com/en-us/artifact/mar/dotnet/sdk/tags) version used to generate the development certificate | 10.0.100 |
| DOTNET_RUNTIME_VERSION | The [runtime](https://mcr.microsoft.com/en-us/artifact/mar/dotnet/aspnet/tags) version used as a base | 10.0.0 |
| DOTNET_SDK_VERSION | The [SDK](https://mcr.microsoft.com/en-us/artifact/mar/dotnet/sdk/tags) version used to generate the development certificate | 8.0.416 |
| DOTNET_RUNTIME_VERSION | The [runtime](https://mcr.microsoft.com/en-us/artifact/mar/dotnet/aspnet/tags) version used as a base | 8.0.22 |
| ALPINE_VERSION | The version of [alpine linux](https://www.alpinelinux.org/) used as a base| 3.22 |
## Security implications
@@ -90,22 +90,11 @@ Depending on your use-case you event might consider to use docker networking in
### Included certificate
The included certificate is generated through the _dotnet dev-certs_ command. This is a very convenient and suitable way to generate development certificates using the .NET SDK.
The included certificate is generated through the _dotnet dev-certs_ command. This is a very convenient and suitable way to generate development certificates through the dotnet SDK.
The build pipeline generates a random certificate password using `openssl rand -base64 12` and passes it to the Docker build through the CERT_PASSWORD build argument. The password is therefore different for each pipeline build.
Because the password is embedded in the resulting image configuration, it can be retrieved by inspecting the image.
This is acceptable for development purposes but it is not suitable for production use.
You can generate your own password and certificates in the following way :
```sh
# generate a random secure password
openssl rand -base64 12
# use the .net cli to generate your own certificates with your chosen password
dotnet dev-certs https --export-path /config/aspnetapp.pem --password "YOUR PASSWORD" --format PEM
```
Afterwards, configure your own certificate with the **ASPNETCORE_Kestrel__Certificates__** variables.
The password used to generate the certificate is randomly generated through the `openssl rand -base64 12` at build time.
The build agent used for the build is hosted on my own infrastructure but I don't have any access to it (neither do I intend to do so).<br/>
However if you feel uncomfortable with this fact, feel free to build the image yourself.
### Versioning