我可以在gitlab ci上构建ARM32 docker映像吗?

时间:2020-03-21 19:40:34

标签: docker gitlab gitlab-ci

我正在尝试使用Gitlab CI和容器注册表设置自动构建并部署到Raspberry PI。这是我的Dockerfile(它是.net核心应用程序):

FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim-arm32v7 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster-arm32v7 AS build

WORKDIR /src
COPY ["ConsoleApp/ConsoleApp.csproj", "ConsoleApp/"]
RUN dotnet restore "ConsoleApp/ConsoleApp.csproj"
COPY . .
WORKDIR "/src/ConsoleApp"
RUN dotnet build "ConsoleApp.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "ConsoleApp.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ConsoleApp.dll"]

.gitlab-ci.yml

image: docker:19.03.1
services:
  - docker:19.03.1-dind

stages:
  - build
  - test
  - release
  - deploy

variables:
  DOCKER_HOST: tcp://docker:2376
  DOCKER_TLS_CERTDIR: "/certs"
  CONTAINER_CONSOLEAPP_ARM32: $CI_REGISTRY_IMAGE:consoleapparm32

before_script:
  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY

build_consoleapp_arm32:
  stage: build
  script:
    - docker build -f ./ConsoleApp/DockerfileARM -t $CONTAINER_CONSOLEAPP_ARM32 .
    - docker push $CONTAINER_CONSOLEAPP_ARM32

如果我直接在Raspberry上运行它,则构建此Dockerfile可以很好地工作。如果我尝试在Gitlab CI上使用完全相同的命令来构建完全相同的文件,则会收到一些奇怪的错误,例如:

standard_init_linux.go:211:exec用户进程导致“没有这样的文件或目录”

不兼容的体系结构是否有问题?有任何解决方法吗?

0 个答案:

没有答案