From 8a8128c60ac937c27341705887c0cc2c6b003209 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Tue, 6 Aug 2019 14:31:19 +0900 Subject: [PATCH] Add armv64 to the dockerfile generator --- .circleci/config.yml | 34 +++++++++++++------ .../linuxarm64v8.Dockerfile | 22 ++++++++++++ .../src/docker-compose-generator.csproj | 3 +- 3 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 docker-compose-generator/linuxarm64v8.Dockerfile diff --git a/.circleci/config.yml b/.circleci/config.yml index 0d8412e..9089c79 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: # Define in CircleCi Project Variables: $DOCKERHUB_REPO, $DOCKERHUB_USER, $DOCKERHUB_PASS # Publish jobs require those variables - publish_docker_linuxamd64: + amd64: machine: docker_layer_caching: true steps: @@ -14,7 +14,7 @@ jobs: sudo docker build --pull -t $DOCKERHUB_REPO:latest-amd64 -f linuxamd64.Dockerfile . sudo docker push $DOCKERHUB_REPO:latest-amd64 - publish_docker_linuxarm32v7: + arm32v7: machine: docker_layer_caching: true steps: @@ -27,8 +27,20 @@ jobs: sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS sudo docker build --pull -t $DOCKERHUB_REPO:latest-arm32v7 -f linuxarm32v7.Dockerfile . sudo docker push $DOCKERHUB_REPO:latest-arm32v7 - - publish_docker_multiarch: + arm64v8: + machine: + docker_layer_caching: true + steps: + - checkout + - run: + command: | + sudo docker run --rm --privileged multiarch/qemu-user-static:register --reset + # + cd docker-compose-generator + sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS + sudo docker build --pull -t $DOCKERHUB_REPO:latest-arm64v8 -f linuxarm64v8.Dockerfile . + sudo docker push $DOCKERHUB_REPO:latest-arm64v8 + multiarch: machine: enabled: true image: circleci/classic:201808-01 @@ -41,27 +53,29 @@ jobs: # sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS # - sudo docker manifest create --amend $DOCKERHUB_REPO:latest $DOCKERHUB_REPO:latest-amd64 $DOCKERHUB_REPO:latest-arm32v7 + sudo docker manifest create --amend $DOCKERHUB_REPO:latest $DOCKERHUB_REPO:latest-amd64 $DOCKERHUB_REPO:latest-arm32v7 $DOCKERHUB_REPO:latest-arm64v8 sudo docker manifest annotate $DOCKERHUB_REPO:latest $DOCKERHUB_REPO:latest-amd64 --os linux --arch amd64 sudo docker manifest annotate $DOCKERHUB_REPO:latest $DOCKERHUB_REPO:latest-arm32v7 --os linux --arch arm --variant v7 + sudo docker manifest annotate $DOCKERHUB_REPO:latest $DOCKERHUB_REPO:latest-arm64v8 --os linux --arch arm64 --variant v8 sudo docker manifest push $DOCKERHUB_REPO:latest -p workflows: version: 2 publish: jobs: - - publish_docker_linuxamd64: + - amd64: filters: branches: only: dcg-latest - - publish_docker_linuxarm32v7: + - arm32v7: filters: branches: only: dcg-latest - - publish_docker_multiarch: + - multiarch: requires: - - publish_docker_linuxamd64 - - publish_docker_linuxarm32v7 + - amd64 + - arm32v7 + - arm64v8 filters: branches: only: dcg-latest diff --git a/docker-compose-generator/linuxarm64v8.Dockerfile b/docker-compose-generator/linuxarm64v8.Dockerfile new file mode 100644 index 0000000..c0faf90 --- /dev/null +++ b/docker-compose-generator/linuxarm64v8.Dockerfile @@ -0,0 +1,22 @@ +# This is a manifest image, will pull the image with the same arch as the builder machine +FROM mcr.microsoft.com/dotnet/core/sdk:3.0.100-preview7 AS builder +WORKDIR /source +COPY src/docker-compose-generator.csproj docker-compose-generator.csproj +# Cache some dependencies +RUN dotnet restore /p:TargetFrameworkOverride=netcoreapp3.0 +COPY src/. . +RUN dotnet publish --output /app/ --configuration Release /p:TargetFrameworkOverride=netcoreapp3.0 + +# Force the builder machine to take make an arm runtime image. This is fine as long as the builder does not run any program +FROM mcr.microsoft.com/dotnet/core/runtime:3.0.0-preview7-buster-slim-arm64v8 +WORKDIR /datadir + +WORKDIR /app +ENV APP_DATADIR=/datadir +VOLUME /datadir + +ENV INSIDE_CONTAINER=1 + +COPY --from=builder "/app" . + +ENTRYPOINT ["dotnet", "docker-compose-generator.dll"] diff --git a/docker-compose-generator/src/docker-compose-generator.csproj b/docker-compose-generator/src/docker-compose-generator.csproj index 2ecf0a4..1f5dbf6 100644 --- a/docker-compose-generator/src/docker-compose-generator.csproj +++ b/docker-compose-generator/src/docker-compose-generator.csproj @@ -2,7 +2,8 @@ Exe - netcoreapp2.1 + netcoreapp2.1 + $(TargetFrameworkOverride) DockerGenerator