Added docker
Some checks failed
Develop Build / build (push) Failing after 52s

This commit is contained in:
Roland Fieger
2025-10-28 12:32:15 +01:00
parent b35ec0902b
commit e4e7e637c5
5 changed files with 73 additions and 4 deletions

View File

@@ -25,7 +25,7 @@ jobs:
- name: Add Nuget Credentials
# run: dotnet nuget update source gitea --username sxhundred --password ${{ secrets.READ_NUGET_PAT }} --store-password-in-clear-text --configfile nuget.config
run: dotnet nuget update source gitea --username sxhundred --password ${{ secrets.READ_NUGET_PAT }} --store-password-in-clear-text --configfile nuget.config
run: dotnet nuget update source gitea --username ${{ secrets.READ_NUGET_USER }} --password ${{ secrets.READ_NUGET_PAT }} --store-password-in-clear-text --configfile nuget.config
- name: Install GitVersion
@@ -53,4 +53,26 @@ jobs:
path: SimplePackage/bin/Debug/*.*nupkg
- name: Publish Develop SimplePackage
run: dotnet nuget push SimplePackage/bin/Debug/*.nupkg --api-key ${{ secrets.READ_NUGET_PAT }} --no-symbols
run: dotnet nuget push SimplePackage/bin/Debug/*.nupkg --api-key ${{ secrets.READ_NUGET_PAT }} --no-symbols
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: Address of your docker registry in gitea
username: ${{ secrets.READ_NUGET_USER
password: ${{ secrets.READ_NUGET_PAT
- name: Build Docker Image
run: |
docker build --build-arg BuildVersion=${{ env.GitVersion_SemVer }} \
--build-arg PACKAGETEST_FEED_URL=http://192.168.2.83:3100/api/packages/sxhundred/nuget/index.json \
--build-arg READ_NUGET_USER=${{ secrets.READ_NUGET_USER }} \
--build-arg READ_NUGET_PAT=${{ secrets.READ_NUGET_PAT }} \
-t myimage:latest .
- name: Push Docker Image
run: |
echo ${{ secrets.READ_NUGET_PAT }} | docker login -u ${{ secrets.READ_NUGET_USER }} --password-stdin
docker tag myimage:latest ${{ secrets.READ_NUGET_USER }}/myimage:develop
docker push ${{ secrets.READ_NUGET_USER }}/myimage:develop

2
.gitignore vendored
View File

@@ -12,3 +12,5 @@
# Built Visual Studio Code Extensions
*.vsix
SimplePackage/obj/Debug/netstandard2.1/SimplePackage.AssemblyInfo.cs
SimplePackage/obj/Debug/netstandard2.1/SimplePackage.AssemblyInfoInputs.cache

45
SimplePackage/dockerfile Normal file
View File

@@ -0,0 +1,45 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build
ARG BuildVersion
ARG PACKAGETEST_FEED_URL
ARG READ_NUGET_PAT
ARG READ_NUGET_USER
ARG BuildUniqueID
LABEL build.uniqueid="${BuildUniqueID:-1}"
RUN wget -qO- https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | bash
# Optional: Sometimes the http client hangs because of a .NEt issue. Setting this in dockerfile helps
ENV DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
# Environment variable to enable seesion token cache. More on this here: https://github.com/Microsoft/artifacts-credprovider#help
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true
# Environment variable for adding endpoint credentials. More on this here: https://github.com/Microsoft/artifacts-credprovider#help
# Add "FEED_URL" AND "PAT" using --build-arg in docker build step. "endpointCredentials" field is an array, you can add multiple endpoint configurations.
# Make sure that you *do not* hard code the "PAT" here. That is a sensitive information and must not be checked in.
# ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS {\"endpointCredentials\": [{\"endpoint\":\"${FEED_URL}\", \"username\":\"ArtifactsDocker\", \"password\":\"${PAT}\"}, {\"endpoint\":\"${GITHUB_FEED_URL}\", \"username\":\"${GITHUB_USER}\", \"password\":\"${GITHUB_PAT}\"}]}
# RUN dotnet nuget add source ${FEED_URL} --name "myfeed" --username "whatever" --password="${PAT}" --store-password-in-clear-text --valid-authentication-types "basic"
RUN dotnet nuget add source ${PACKAGETEST_FEED_URL} --name "myfeed_gitea" --username "${READ_NUGET_USER}}" --password="${READ_NUGET_PAT}}" --store-password-in-clear-text --valid-authentication-types "basic"
WORKDIR /src
COPY . .
RUN dotnet restore "SimplePackage/SimplePackage.csproj" --runtime linux-x64
WORKDIR "/SimplePackage"
RUN dotnet build "SimplePackage.csproj" --no-restore -c Release -o /app /property:Version=${BuildVersion:-1.0.0-dev} --self-contained --runtime linux-x64
FROM build AS publish
ENV TZ=Europe/Berlin
ENV LANG de_DE.UTF-8
ENV LANGUAGE de_DE:de
ENV LC_ALL de_DE.UTF-8
ARG BuildVersion
RUN dotnet publish "SimplePackage.csproj" --no-restore -c Release -o /app /property:Version=${BuildVersion:-1.0.0-dev} --self-contained --runtime linux-x64
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-jammy-chiseled-extra AS final
ENV TZ=Europe/Berlin
ENV LANG de_DE.UTF-8
ENV LANGUAGE de_DE:de
ENV LC_ALL de_DE.UTF-8
ENV ASPNETCORE_HTTP_PORTS=8080
ENV ASPNETCORE_URLS=http://*:8080
EXPOSE 8080
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["./SimplePackage"]

View File

@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("SimplePackage")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f16bbb021a5935fe13422389a641345c09e66992")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b35ec0902bf235cd43e9eb57ed261d1efc9bf3c8")]
[assembly: System.Reflection.AssemblyProductAttribute("SimplePackage")]
[assembly: System.Reflection.AssemblyTitleAttribute("SimplePackage")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@@ -1 +1 @@
90d52f61004d6770342ebc33c9b6a0b973947a35df2b7ee0b4481d085abc3e49
e57fc372a4954336783480088d449e920ca66a75bdc78bf1b7bbd9100da8c525