Skip to content

Commit e900d52

Browse files
committedMar 19, 2024
add Dockerfile
1 parent 699380c commit e900d52

File tree

5 files changed

+39
-1
lines changed

5 files changed

+39
-1
lines changed
 

‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -398,4 +398,5 @@ FodyWeavers.xsd
398398
*.sln.iml
399399

400400

401-
.idea
401+
.idea
402+
huajibot.tar

‎Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine3.18 AS build-env
2+
3+
COPY . /root/build
4+
5+
ARG TARGETARCH
6+
7+
WORKDIR /root/build
8+
RUN dotnet publish src/HuaJiBot.NET.CLI \
9+
-c Release \
10+
-a $TARGETARCH \
11+
--no-self-contained \
12+
-p:PublishSingleFile=true \
13+
--framework net8.0 \
14+
-o /root/out
15+
16+
FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine3.18
17+
18+
COPY --from=build-env /root/out/HuaJiBot.NET.CLI /app/bin/HuaJiBot.NET.CLI
19+
20+
RUN mkdir /app/data \
21+
&& adduser -D user \
22+
&& chmod +x /app/bin/HuaJiBot.NET.CLI
23+
24+
WORKDIR /app/data
25+
ENTRYPOINT ["/app/bin/HuaJiBot.NET.CLI"]

‎build.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dotnet publish src/HuaJiBot.NET.CLI \
2+
-c Release \
3+
--no-self-contained \
4+
-p:PublishSingleFile=true \
5+
--framework net8.0 \
6+
-o /root/out

‎build_docker.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# docker buildx build -t huajibot --platform linux/arm64 -t huajibot_arm64 -o bin .
2+
docker buildx build -t huajibot --platform linux/amd64 --load .
3+
docker save -o huajibot.tar huajibot

‎build_docker_arm64.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# docker buildx build -t huajibot --platform linux/arm64 -t huajibot_arm64 -o bin .
2+
docker buildx build -t huajibot --platform linux/arm64 --load .
3+
docker save -o huajibot.tar huajibot

0 commit comments

Comments
 (0)
Please sign in to comment.