Skip to content

Commit

Permalink
docker构建镜像支持多cpu架构 #550
Browse files Browse the repository at this point in the history
  • Loading branch information
RayWangQvQ committed Apr 30, 2021
1 parent 9f78dc3 commit b7f49dc
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
WORKDIR /code
COPY ["src/Ray.BiliBiliTool.Console/Ray.BiliBiliTool.Console.csproj", "src/Ray.BiliBiliTool.Console/"]
COPY ["src/Ray.BiliBiliTool.DomainService/Ray.BiliBiliTool.DomainService.csproj", "src/Ray.BiliBiliTool.DomainService/"]
COPY ["src/Ray.BiliBiliTool.Config/Ray.BiliBiliTool.Config.csproj", "src/Ray.BiliBiliTool.Config/"]
Expand All @@ -22,7 +22,7 @@ COPY ["src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.PushPlusBatched/Ray.Serilog.Sinks
COPY ["src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/Ray.Serilog.Sinks.ServerChanBatched.csproj", "src/Ray.Serilog.Sinks/Ray.Serilog.Sinks.ServerChanBatched/"]
RUN dotnet restore "src/Ray.BiliBiliTool.Console/Ray.BiliBiliTool.Console.csproj"
COPY . .
WORKDIR "/src/src/Ray.BiliBiliTool.Console"
WORKDIR "/code/src/Ray.BiliBiliTool.Console"
RUN dotnet build "Ray.BiliBiliTool.Console.csproj" -c Release -o /app/build

FROM build AS publish
Expand Down
11 changes: 11 additions & 0 deletions docker/build/buildAndPushImage_multiArch.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@echo off

REM start to build
REM https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/
REM https://segmentfault.com/a/1190000021166703
REM linux/arm/v6,linux/riscv64,linux/s390x,linux/ppc64le,linux/386,,linux/arm/v7 偶发异常,待进一步测试
echo Start to build docker image with multi-arch
@echo on
docker buildx build --platform linux/amd64,linux/arm64 --push -t zai7lou/bilibili_tool ../..
@echo off
pause
2 changes: 1 addition & 1 deletion docker/buildImage.cmd → docker/build/buildImage.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
REM start to build
echo Start to build docker image
@echo on
docker build -t zai7lou/bilibili_tool ..
docker build -t zai7lou/bilibili_tool ../..
@echo off
pause
10 changes: 10 additions & 0 deletions docker/build/buildImage_amd64.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off

REM start to build
REM https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/
REM https://segmentfault.com/a/1190000021166703
echo Start to build docker image with amd64-arch
@echo on
docker buildx build --platform linux/amd64 -o type=docker -t zai7lou/bilibili_tool ../..
@echo off
pause
10 changes: 10 additions & 0 deletions docker/build/buildImage_arm64.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off

REM start to build
REM https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/
REM https://segmentfault.com/a/1190000021166703
echo Start to build docker image with arm64-arch
@echo on
docker buildx build --platform linux/arm64 -o type=docker -t zai7lou/bilibili_tool ../..
@echo off
pause

0 comments on commit b7f49dc

Please sign in to comment.