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

Commit 458ab2a

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

5 files changed

Lines changed: 159 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: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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+
images: ${{ env.REGISTRY_IMAGE }}
65+
platforms: ${{ matrix.platform }}
66+
labels: ${{ steps.meta.outputs.labels }}
67+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
68+
69+
- name: Export digest
70+
run: |
71+
mkdir -p ${{ runner.temp }}/digests
72+
digest="${{ steps.build.outputs.digest }}"
73+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
74+
75+
- name: Upload digest
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: digests-${{ env.PLATFORM_PAIR }}
79+
path: ${{ runner.temp }}/digests/*
80+
if-no-files-found: error
81+
retention-days: 1
82+
83+
merge:
84+
runs-on: ubuntu-latest
85+
needs:
86+
- build
87+
steps:
88+
- name: Download digests
89+
uses: actions/download-artifact@v4
90+
with:
91+
path: ${{ runner.temp }}/digests
92+
pattern: digests-*
93+
merge-multiple: true
94+
95+
- name: Login to Docker Hub
96+
uses: docker/login-action@v3
97+
with:
98+
registry: ghcr.io
99+
username: ${{ github.repository_owner }}
100+
password: ${{ secrets.GITHUB_TOKEN }}
101+
102+
- name: Set up Docker Buildx
103+
uses: docker/setup-buildx-action@v3
104+
105+
- name: Docker meta
106+
id: meta
107+
uses: docker/metadata-action@v5
108+
with:
109+
images: ${{ env.REGISTRY_IMAGE }}
110+
tags: |
111+
type=ref,event=branch
112+
type=ref,event=pr
113+
type=semver,pattern={{version}}
114+
type=semver,pattern={{major}}.{{minor}}
115+
116+
- name: Create manifest list and push
117+
working-directory: ${{ runner.temp }}/digests
118+
run: |
119+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
120+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
121+
122+
- name: Inspect image
123+
run: |
124+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ 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)