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

Commit d96c8a8

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

5 files changed

Lines changed: 162 additions & 2 deletions

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

Lagrange.Milky/Lagrange.Milky.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<PublishAot>true</PublishAot>
8+
<InvariantGlobalization>true</InvariantGlobalization>
89
</PropertyGroup>
910
<PropertyGroup Condition=" '$(Configuration)' == 'Debug'">
1011
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
@@ -33,4 +34,4 @@
3334
<ItemGroup>
3435
<EmbeddedResource Include="Resources\appsettings.jsonc" />
3536
</ItemGroup>
36-
</Project>
37+
</Project>
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 -p:StaticExecutable=true -o /app/bin
15+
16+
17+
FROM scratch
18+
19+
COPY --from=build /app/bin/ .
20+
ENTRYPOINT ["./Lagrange.Milky"]

0 commit comments

Comments
 (0)