Skip to content

Commit 5c61b7c

Browse files
committed
[Milky] Add Docker support
1 parent 05365b4 commit 5c61b7c

3 files changed

Lines changed: 67 additions & 0 deletions

File tree

.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/.dockerignore
2+
**/.env
3+
**/.git
4+
**/.gitignore
5+
**/.project
6+
**/.settings
7+
**/.toolstarget
8+
**/.vs
9+
**/.vscode
10+
**/.idea
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md

Lagrange.Milky/Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM alpine:3.23 AS base
2+
USER root
3+
USER $APP_UID
4+
WORKDIR /app
5+
6+
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS build
7+
RUN apk update && apk add build-base
8+
ARG BUILD_CONFIGURATION=Release
9+
ARG GIT_SHA=Unknown
10+
ENV DOCKER=true
11+
WORKDIR /src
12+
COPY ["Lagrange.Milky/Lagrange.Milky.csproj", "Lagrange.Milky/"]
13+
COPY ["Lagrange.Codec/Lagrange.Codec.csproj", "Lagrange.Codec/"]
14+
COPY ["Lagrange.Core/Lagrange.Core.csproj", "Lagrange.Core/"]
15+
COPY ["Lagrange.Proto.Generator/Lagrange.Proto.Generator.csproj", "Lagrange.Proto.Generator/"]
16+
COPY ["Lagrange.Proto/Lagrange.Proto.csproj", "Lagrange.Proto/"]
17+
COPY ["Lagrange.Milky.Implementation.Api.Generator/Lagrange.Milky.Implementation.Api.Generator.csproj", "Lagrange.Milky.Implementation.Api.Generator/"]
18+
RUN dotnet restore "Lagrange.Milky/Lagrange.Milky.csproj"
19+
COPY . .
20+
WORKDIR "/src/Lagrange.Milky"
21+
RUN dotnet build "./Lagrange.Milky.csproj" -p:SourceRevisionId=$GIT_SHA -c $BUILD_CONFIGURATION -o /app/build
22+
23+
FROM build AS publish
24+
ARG BUILD_CONFIGURATION=Release
25+
RUN dotnet publish "./Lagrange.Milky.csproj" -p:SourceRevisionId=$GIT_SHA -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
26+
27+
FROM base AS final
28+
WORKDIR /app
29+
ENV DOCKER=true
30+
COPY --from=publish /app/publish .
31+
WORKDIR /data
32+
ENTRYPOINT ["/app/Lagrange.Milky"]

Lagrange.Milky/Lagrange.Milky.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
<Nullable>enable</Nullable>
77
<PublishAot>true</PublishAot>
88
</PropertyGroup>
9+
<PropertyGroup Condition=" '$(DOCKER)' == 'true' ">
10+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
11+
<InvariantGlobalization>true</InvariantGlobalization>
12+
</PropertyGroup>
913
<PropertyGroup Condition=" '$(Configuration)' == 'Debug'">
1014
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
1115
</PropertyGroup>
@@ -33,4 +37,10 @@
3337
<ItemGroup>
3438
<EmbeddedResource Include="Resources\appsettings.jsonc" />
3539
</ItemGroup>
40+
41+
<ItemGroup>
42+
<Content Include="..\.dockerignore">
43+
<Link>.dockerignore</Link>
44+
</Content>
45+
</ItemGroup>
3646
</Project>

0 commit comments

Comments
 (0)