Skip to content

Commit 9089cbd

Browse files
committed
[Milky] Add Docker support
1 parent 05365b4 commit 9089cbd

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

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

Lagrange.Milky/Lagrange.Milky.csproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
<Nullable>enable</Nullable>
77
<PublishAot>true</PublishAot>
88
</PropertyGroup>
9+
<PropertyGroup Condition=" '$(DOCKER)' == 'true' ">
10+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
11+
<InvariantGlobalization>true</InvariantGlobalization>
12+
<DefineConstants>DOCKER</DefineConstants>
13+
</PropertyGroup>
914
<PropertyGroup Condition=" '$(Configuration)' == 'Debug'">
1015
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
1116
</PropertyGroup>
@@ -33,4 +38,10 @@
3338
<ItemGroup>
3439
<EmbeddedResource Include="Resources\appsettings.jsonc" />
3540
</ItemGroup>
41+
42+
<ItemGroup>
43+
<Content Include="..\.dockerignore">
44+
<Link>.dockerignore</Link>
45+
</Content>
46+
</ItemGroup>
3647
</Project>

0 commit comments

Comments
 (0)