-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sample project showing using a custom base image
- Loading branch information
Showing
9 changed files
with
125 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Custom Base Image Example | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
env: | ||
GITHUB_USERNAME: baronfel | ||
BASE_IMAGE: "ghcr.io/baronfel/dotnet-runtime-skia-base-image:8.0" | ||
|
||
jobs: | ||
create-base-image: | ||
permissions: | ||
contents: read | ||
packages: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Login to ghcr.io | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Get the code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build the base image | ||
working-directory: src/custom-base-image | ||
run: | | ||
docker build -t ${{ env.BASE_IMAGE }} -f Dockerfile . | ||
docker push ${{ env.BASE_IMAGE }} | ||
use-base-image: | ||
needs: create-base-image | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Login to ghcr.io | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Get .NET | ||
uses: actions/setup-dotnet@v4 | ||
|
||
- name: Build the app | ||
run: | | ||
dotnet publish -t:PublishContainer -p ContainerBaseImage="${{ env.BASE_IMAGE }}" |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM mcr.microsoft.com/dotnet/runtime:8.0 as base | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
libfreetype6 \ | ||
libfontconfig1 \ | ||
&& rm -rf /var/lib/apt/lists/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
Console.WriteLine("Hello, World!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Using a custom base image container | ||
|
||
This sample demonstrates how to take control of the base image used by the SDK tooling to build your application. | ||
|
||
It includes | ||
|
||
* A Dockerfile with some customizations (in this case, installing a package into the runtime environment) | ||
* A Console app that needs that package in order to execute | ||
|
||
To build and run the sample, follow these steps: | ||
* build the base image and push it to a registry | ||
* `docker build -f Dockerfile -t <my-registry>/<my-image-name>:<my-tag> .` | ||
* `docker push <my-registry>/<my-image-name>:<my-tag>` | ||
* publish the console application as a container, specifying your base image | ||
* `dotnet publish -t:PublishContainer -p ContainerBaseImage=<my-registry>/<my-image-name>:<my-tag>` | ||
|
||
> [!IMPORTANT] | ||
> Pushing images to a registry may require authentication, both on the push and pull side. Make sure you have the necessary credentials to access the registry you are using. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier> | ||
<RootNamespace>custom_base_image</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<EnableSdkContainerSupport>true</EnableSdkContainerSupport> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "custom-base-image", "custom-base-image.csproj", "{572DAF66-27C5-4736-AD1A-790BEB45F45F}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{572DAF66-27C5-4736-AD1A-790BEB45F45F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{572DAF66-27C5-4736-AD1A-790BEB45F45F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{572DAF66-27C5-4736-AD1A-790BEB45F45F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{572DAF66-27C5-4736-AD1A-790BEB45F45F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {192A0D2A-7A6B-40E7-BA67-2957C25F8160} | ||
EndGlobalSection | ||
EndGlobal |