Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*

!.git/
!Lagrange.Codec/
!Lagrange.Core/
!Lagrange.Milky/
!Lagrange.Milky.Implementation.Api.Generator/
!Lagrange.Proto/
!Lagrange.Proto.Generator/

*/bin/
*/obj/
8 changes: 5 additions & 3 deletions .github/workflows/milky-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ on:
- .github/workflows/milky-build.yaml
- Lagrange.Codec/**
- Lagrange.Core/**
- Lagrange.Milky/**
- Lagrange.Milky.Implementation.Api.Generator/**
- Lagrange.Proto/**
- Lagrange.Proto.Generator/**
- Lagrange.Milky/**
pull_request:
branches: [ main ]
paths:
- .github/workflows/milky-build.yaml
- Lagrange.Codec/**
- Lagrange.Core/**
- Lagrange.Milky/**
- Lagrange.Milky.Implementation.Api.Generator/**
- Lagrange.Proto/**
- Lagrange.Proto.Generator/**
- Lagrange.Milky/**
workflow_dispatch:

jobs:
Expand All @@ -36,7 +38,7 @@ jobs:
- os: ubuntu-latest
rid: linux-x64
binary-extension: ''

env:
RUNTIME_IDENTIFIER: ${{ matrix.rid }}

Expand Down
132 changes: 132 additions & 0 deletions .github/workflows/milky-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Build Lagrange.Milky image

on:
push:
branches: [ main ]
paths:
- .github/workflows/milky-docker.yaml
- Lagrange.Codec/**
- Lagrange.Core/**
- Lagrange.Milky/**
- Lagrange.Milky.Implementation.Api.Generator/**
- Lagrange.Proto/**
- Lagrange.Proto.Generator/**
pull_request:
branches: [ main ]
paths:
- .github/workflows/milky-docker.yaml
- Lagrange.Codec/**
- Lagrange.Core/**
- Lagrange.Milky/**
- Lagrange.Milky.Implementation.Api.Generator/**
- Lagrange.Proto/**
- Lagrange.Proto.Generator/**
workflow_dispatch:

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: ubuntu-24.04
- platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v6

- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
echo "REGISTRY_IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER@L}/lagrange.milky" >> $GITHUB_ENV

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
file: Lagrange.Milky/Resources/Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ env.REGISTRY_IMAGE }}
outputs: type=image,push-by-digest=true,name-canonical=true,push=true

- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"

- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Prepare
run: |
echo "REGISTRY_IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER@L}/lagrange.milky" >> $GITHUB_ENV

- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)

- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
3 changes: 2 additions & 1 deletion Lagrange.Milky/Lagrange.Milky.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug'">
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
Expand Down Expand Up @@ -33,4 +34,4 @@
<ItemGroup>
<EmbeddedResource Include="Resources\appsettings.jsonc" />
</ItemGroup>
</Project>
</Project>
20 changes: 20 additions & 0 deletions Lagrange.Milky/Resources/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine-aot AS build

WORKDIR /app/src

COPY --link Lagrange.Codec/*.csproj Lagrange.Codec/
COPY --link Lagrange.Core/*.csproj Lagrange.Core/
COPY --link Lagrange.Milky/*.csproj Lagrange.Milky/
COPY --link Lagrange.Milky.Implementation.Api.Generator/*.csproj Lagrange.Milky.Implementation.Api.Generator/
COPY --link Lagrange.Proto/*.csproj Lagrange.Proto/
COPY --link Lagrange.Proto.Generator/*.csproj Lagrange.Proto.Generator/
RUN dotnet restore Lagrange.Milky

COPY --link . .
RUN dotnet publish Lagrange.Milky -c Release -p:DebugType=none -p:StaticExecutable=true -o /app/bin


FROM scratch

COPY --from=build /app/bin/ .
ENTRYPOINT ["./Lagrange.Milky"]
Loading