Skip to content
This repository was archived by the owner on May 27, 2026. It is now read-only.

Commit 66061fc

Browse files
committed
[Milky] Dockerize
1 parent 05365b4 commit 66061fc

5 files changed

Lines changed: 160 additions & 1 deletion

File tree

.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*
2+
3+
!.git/
4+
!Lagrange.Codec/
5+
!Lagrange.Core/
6+
!Lagrange.Milky/
7+
!Lagrange.Milky.Implementation.Api.Generator/
8+
!Lagrange.Proto/
9+
!Lagrange.Proto.Generator/
10+
11+
*/bin/
12+
*/obj/

.github/workflows/milky-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- os: ubuntu-latest
3737
rid: linux-x64
3838
binary-extension: ''
39-
39+
4040
env:
4141
RUNTIME_IDENTIFIER: ${{ matrix.rid }}
4242

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Build Lagrange.Milky image
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- .github/workflows/milky-docker.yaml
8+
- Lagrange.Codec/**
9+
- Lagrange.Core/**
10+
- Lagrange.Proto/**
11+
- Lagrange.Proto.Generator/**
12+
- Lagrange.Milky/**
13+
pull_request:
14+
branches: [ main ]
15+
paths:
16+
- .github/workflows/milky-docker.yaml
17+
- Lagrange.Codec/**
18+
- Lagrange.Core/**
19+
- Lagrange.Proto/**
20+
- Lagrange.Proto.Generator/**
21+
- Lagrange.Milky/**
22+
workflow_dispatch:
23+
24+
env:
25+
REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/lagrange.milky
26+
27+
jobs:
28+
build:
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
include:
33+
- platform: linux/amd64
34+
runner: ubuntu-24.04
35+
- platform: linux/arm64
36+
runner: ubuntu-24.04-arm
37+
runs-on: ${{ matrix.runner }}
38+
steps:
39+
- name: Prepare
40+
run: |
41+
platform=${{ matrix.platform }}
42+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
43+
44+
- name: Docker meta
45+
id: meta
46+
uses: docker/metadata-action@v5
47+
with:
48+
images: ${{ env.REGISTRY_IMAGE }}
49+
50+
- name: Login to Docker Hub
51+
uses: docker/login-action@v3
52+
with:
53+
registry: ghcr.io
54+
username: ${{ github.repository_owner }}
55+
password: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- name: Set up Docker Buildx
58+
uses: docker/setup-buildx-action@v3
59+
60+
- name: Build and push by digest
61+
id: build
62+
uses: docker/build-push-action@v6
63+
with:
64+
file: Lagrange.Milky/Resources/Dockerfile
65+
platforms: ${{ matrix.platform }}
66+
labels: ${{ steps.meta.outputs.labels }}
67+
tags: ${{ steps.meta.outputs.images }}
68+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
69+
70+
- name: Export digest
71+
run: |
72+
mkdir -p ${{ runner.temp }}/digests
73+
digest="${{ steps.build.outputs.digest }}"
74+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
75+
76+
- name: Upload digest
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: digests-${{ env.PLATFORM_PAIR }}
80+
path: ${{ runner.temp }}/digests/*
81+
if-no-files-found: error
82+
retention-days: 1
83+
84+
merge:
85+
runs-on: ubuntu-latest
86+
needs:
87+
- build
88+
steps:
89+
- name: Download digests
90+
uses: actions/download-artifact@v4
91+
with:
92+
path: ${{ runner.temp }}/digests
93+
pattern: digests-*
94+
merge-multiple: true
95+
96+
- name: Login to Docker Hub
97+
uses: docker/login-action@v3
98+
with:
99+
registry: ghcr.io
100+
username: ${{ github.repository_owner }}
101+
password: ${{ secrets.GITHUB_TOKEN }}
102+
103+
- name: Set up Docker Buildx
104+
uses: docker/setup-buildx-action@v3
105+
106+
- name: Docker meta
107+
id: meta
108+
uses: docker/metadata-action@v5
109+
with:
110+
images: ${{ env.REGISTRY_IMAGE }}
111+
tags: |
112+
type=ref,event=branch
113+
type=ref,event=pr
114+
type=semver,pattern={{version}}
115+
type=semver,pattern={{major}}.{{minor}}
116+
117+
- name: Create manifest list and push
118+
working-directory: ${{ runner.temp }}/digests
119+
run: |
120+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
121+
$(printf '${{ steps.meta.outputs.images }}@sha256:%s ' *)
122+
123+
- name: Inspect image
124+
run: |
125+
docker buildx imagetools inspect ${{ steps.meta.outputs.images }}:${{ steps.meta.outputs.version }}

Lagrange.Milky/Lagrange.Milky.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<PublishAot>true</PublishAot>
8+
<InvariantGlobalization>true</InvariantGlobalization>
9+
<StaticExecutable>true</StaticExecutable>
810
</PropertyGroup>
911
<PropertyGroup Condition=" '$(Configuration)' == 'Debug'">
1012
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine-aot AS build
2+
3+
WORKDIR /app/src
4+
5+
COPY --link Lagrange.Codec/*.csproj Lagrange.Codec/
6+
COPY --link Lagrange.Core/*.csproj Lagrange.Core/
7+
COPY --link Lagrange.Milky/*.csproj Lagrange.Milky/
8+
COPY --link Lagrange.Milky.Implementation.Api.Generator/*.csproj Lagrange.Milky.Implementation.Api.Generator/
9+
COPY --link Lagrange.Proto/*.csproj Lagrange.Proto/
10+
COPY --link Lagrange.Proto.Generator/*.csproj Lagrange.Proto.Generator/
11+
RUN dotnet restore Lagrange.Milky
12+
13+
COPY --link . .
14+
RUN dotnet publish Lagrange.Milky -c Release -p:DebugType=none -o /app/bin
15+
16+
17+
FROM scratch
18+
19+
COPY --from=build /app/bin/ .
20+
ENTRYPOINT ["./Lagrange.Milky"]

0 commit comments

Comments
 (0)