Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Docker Image for Arm64v8 #2380

Open
helkaroui opened this issue Mar 22, 2020 · 24 comments
Open

Build Docker Image for Arm64v8 #2380

helkaroui opened this issue Mar 22, 2020 · 24 comments
Assignees
Labels
area/build Issues relating to the build system linear

Comments

@helkaroui
Copy link

helkaroui commented Mar 22, 2020

I was trying to build docker image for an arm64v8 architecture. I got this error:
I followed these steps:

1- I edited the docker file with the proper base image and arguments:

ARG CONTAINER_RUNTIME=bionic-arm64v8
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-bionic-arm64v8 AS build
ARG RUNTIME=linux-arm

WORKDIR /build/ci

COPY ./ci ./

WORKDIR /build/src

COPY ./src/EventStore.sln ./src/*/*.csproj ./src/Directory.Build.* ./

RUN for file in $(ls *.csproj); do mkdir -p ./${file%.*}/ && mv $file ./${file%.*}/; done

RUN dotnet restore --runtime=${RUNTIME}

COPY ./src .

RUN dotnet build --configuration=Release --runtime=${RUNTIME} --no-restore --framework=netcoreapp3.1

FROM build as test
ARG RUNTIME=linux-arm
RUN echo '#!/usr/bin/env sh\n\
cp /build/src/EventStore.Core.Tests/Services/Transport/Tcp/test_certificates/ca/ca.crt /usr/local/share/ca-certificates/ca_eventstore_test.crt\n\
update-ca-certificates\n\
find /build/src -maxdepth 1 -type d -name "*.Tests" -print0 | xargs -I{} -0 -n1 bash -c '"'"'dotnet test --configuration Release --blame --settings /build/ci/ci.runsettings --logger:html --logger:trx --logger:"console;verbosity=normal" --results-directory=/build/test-results/$1 $1'"'"' - '"'"'{}'"'"'\n\
echo $(find /build/test-results -name "*.html" | xargs cat) > /build/test-results/test-results.html' \
    >> /build/test.sh && \
    chmod +x /build/test.sh
CMD ["/build/test.sh"]

FROM build as publish
ARG RUNTIME=linux-arm

RUN dotnet publish --configuration=Release --runtime=${RUNTIME} --self-contained \
     --framework=netcoreapp3.1 --output /publish /p:PublishTrimmed=true EventStore.ClusterNode

FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.1-${CONTAINER_RUNTIME} AS runtime
ARG UID=1000
ARG GID=1000

RUN apt update && \
    apt install -y \
    curl && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /opt/eventstore

RUN addgroup --gid ${GID} "eventstore" && \
    adduser \
    --disabled-password \
    --gecos "" \
    --ingroup "eventstore" \
    --no-create-home \
    --uid ${UID} \
    "eventstore"

COPY --from=publish /publish ./

RUN mkdir -p /var/lib/eventstore && \
    chown -R eventstore:eventstore /opt/eventstore /var/lib/eventstore

USER eventstore

VOLUME /var/lib/eventstore

EXPOSE 1112/tcp
EXPOSE 1113/tcp
EXPOSE 2112/tcp
EXPOSE 2113/tcp

HEALTHCHECK --interval=5s --timeout=5s --retries=24 \
    CMD curl --fail --insecure https://localhost:2113/health/live || exit 1

ENTRYPOINT ["/opt/eventstore/EventStore.ClusterNode"]
CMD ["--ext-ip", "0.0.0.0", "--int-ip", "0.0.0.0"]

2- Activated docker buildx command for cross platform compilation, then build the image:
docker buildx build --platform linux/arm64 .

I got this message:

error NETSDK1032: The RuntimeIdentifier platform 'linux-arm' and the PlatformTarget 'x64' must be compatible.

Anyone could help ?

DB-28

@avish0694 avish0694 self-assigned this Apr 20, 2020
@pgermishuys
Copy link
Contributor

The error you are receiving is because x64 is x86-x64 and you are trying to build for ARM. To be able to build Event Store you would also need to adjust the currently set platforms to include Any CPU in the csproj files.

Unfortunately, at present, the grpc tools doesn't support ARM (grpc/grpc#22263).

You can get around the grpc tools issue by building on a grpc tools supported platform and targeting the linux-arm64 runtime via dotnet build.
e.g.

dotnet build -c Release -r linux-arm64 /p:Platform="Any CPU" src/

As a side note, there are no plans to support building for ARM directly from a repo clone.

@jageall jageall added the action/close if no further feedback If no further feedback is given after a potential fix within 3 weeks the issue will be closed label Apr 24, 2020
@JacobT14
Copy link

Just want to bring this back from the dead a little bit... Currently just got a new M1 Macbook Air and it seems like maybe I should be able to work around this issue, but can't seem to figure it out. Has anyone been able to successfully run EventStore on an M1 chip?

@ylorph
Copy link
Contributor

ylorph commented Feb 17, 2021

We'll have to wait for grpc/grpc#22263 (comment) to be solved .
But they seem to be working on it

@ylorph
Copy link
Contributor

ylorph commented Feb 17, 2021

This is the milestone we need to keep an eye on :
https://github.com/grpc/grpc/milestone/56

and the reason why it take so long:
grpc/grpc#24002 (comment)

@oskardudycz
Copy link
Contributor

We released an alpha version of the ARM64 image. We're still testing it, but it looks promising!

You have to use the GitHub Container registry image: https://github.com/EventStore/EventStore/pkgs/container/eventstore/7973829.

Docker image: ghcr.io/eventstore/eventstore:20.6.1-alpha.0.69-arm64v8

Example how to run the command:

docker run --name esdb-node -it -p 2113:2113 -p 1113:1113 \
    ghcr.io/eventstore/eventstore:20.6.1-alpha.0.69-arm64v8 --insecure --run-projections=All \
    --enable-external-tcp --enable-atom-pub-over-http

You can also subscribe to PR #3076 to see the progress on the ARM64 build.

@ecwyne
Copy link

ecwyne commented Sep 27, 2021

@oskardudycz, worked for me on Apple M1 like a charm! Thanks so much!

@oskardudycz
Copy link
Contributor

@ecwyne, great! If you noticed any unexpected behaviour, we'd be grateful for the feedback.

I'll keep this ticket open until the regular ARM64 release is available 👍

@wSedlacek
Copy link

The alpha image is working great on my M1 Max! Thank you!

@AlexandreDecollas
Copy link

Very great job! Works quite well on my M1 too, thank you very much!
Is there a way I can find other versions of the image? a alpha repo or something? I'm currently searching a v5.0.9 image. If there are no repo, could you please build and share such a version?

@oskardudycz oskardudycz added area/build Issues relating to the build system and removed action/close if no further feedback If no further feedback is given after a potential fix within 3 weeks the issue will be closed labels Dec 6, 2021
@oskardudycz
Copy link
Contributor

@AlexandreDecollas, unfortunately, v5 is out of support at the end of the year, plus adding ARM support required quite of an effort, and making that work on v5 would be even harder.

@oskardudycz
Copy link
Contributor

21.10.0-alpha-arm64v8 docker image is available here: https://github.com/EventStore/EventStore/pkgs/container/eventstore/11006179?tag=21.10.0-alpha-arm64v8. It's a first build that's built directly from source code, without non-experimental binaries.

We hope to provide a non-alpha release in the following database version. I'll keep this issue open till now, but so far, so good. We're not aware of any specific ARM issues for this build. If you found any, we'd be grateful for the information.

@purefun
Copy link

purefun commented Apr 19, 2022

docker run -p 1113:1113 -p 2113:2113 ghcr.io/eventstore/eventstore:21.10.1-alpha-arm64v8 --insecure

@raarts
Copy link

raarts commented Jun 18, 2022

I see that 21.10.2 is the most recent available.

@jakzal
Copy link

jakzal commented Oct 14, 2022

Is there anything we can do to help push a non-alpha release?

I've been using the alpha version of the arm image on my M1 Mac for the past month and found no issues so far.

@jakzal
Copy link

jakzal commented Oct 17, 2022

For those who use testcontainers and need to run their tests on multiple architectures, just use the default image in your tests:

 private static final GenericContainer eventStoreDb = new GenericContainer(DockerImageName.parse("ghcr.io/eventstore/eventstore:21.10.8-alpine"))
      .withExposedPorts(2113)
      .withEnv("EVENTSTORE_INSECURE", "true");

Then, create an image name substitutor to replace it when tests are run on M1 Mac:

package com.kaffeinelabs.journal.eventstoredb.testcontainers;

import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.ImageNameSubstitutor;

public class EventStoreImageNameSubstitutor extends ImageNameSubstitutor {
  private static final String ARM_IMAGE = "ghcr.io/eventstore/eventstore:21.10.8-alpha-arm64v8";

  @Override
  public DockerImageName apply(final DockerImageName original) {
    if (isEventStoreImage(original) && isRunOnAppleSilicon()) {
      return DockerImageName.parse(ARM_IMAGE);
    }

    return original;
  }

  @Override
  protected String getDescription() {
    return "Substitutes EventStoreDB image name if run on Apple silicon.";
  }

  private static boolean isRunOnAppleSilicon() {
    return "aarch64".equals(System.getProperty("os.arch", "unknown"));
  }

  private static boolean isEventStoreImage(final DockerImageName original) {
    return "ghcr.io/eventstore/eventstore".equals(original.getUnversionedPart());
  }
}

Register the image name substitutor in src/test/resources/testcontainers.properties:

image.substitutor=com.kaffeinelabs.journal.eventstoredb.testcontainers.EventStoreImageNameSubstitutor

@arwinneil
Copy link
Member

arwinneil commented Oct 18, 2022

Hey @jakzal, one of the main things that was holding up a non-alpha release was moving the database to .NET 6 as it brings significant stability and performance improvements on ARM. This was recently done in #3595, slowly but steadily moving towards a non-alpha release! Cheers!

@jokesterfr
Copy link

It would be really handy to have a single docker tag, supporting both x86_64 and arm64 :)
Same as above, not experiencing any crash on M1 since months, seems stable so far.

@arwinneil
Copy link
Member

@jokesterfr Thanks for the feedback, glad to hear that. The plan is to have 1 single multi-architecture image once we officially support ARM64. 😄

@mohammadsaadshafiq
Copy link

Hi, I wrote an article to make it look easy.
https://medium.com/@saad.shafiq1997/how-to-locally-set-up-an-event-store-usi-9c909d7a5603

@alexeyzimarev alexeyzimarev changed the title Build Docker Image for Arm64v8 Build Docker Image for Arm64v8 Apr 28, 2023
@alexeyzimarev
Copy link
Member

DB-27

@lessless
Copy link

lessless commented Jun 8, 2023

Hey @mohammadsaadshafiq!

Thanks for the suggestion to specify the linux-arm64 runtime. I'm still getting the same error as with the linux-x86 however. Does it look familiar to you by any chance ?

Dockerfile:26
--------------------
  25 |
  26 | >>> RUN find /build/src -maxdepth 1 -type d -name "*.Tests" -print0 | xargs -I{} -0 -n1 sh -c \
  27 | >>>     'dotnet publish --runtime=${RUNTIME} --no-self-contained --configuration Release --output /build/published-tests/`basename $1` $1' - '{}'
  28 |
--------------------
ERROR: failed to solve: process "/bin/sh -c find /build/src -maxdepth 1 -type d -name \"*.Tests\" -print0 | xargs -I{} -0 -n1 sh -c     'dotnet publish --runtime=${RUNTIME} --no-self-contained --configuration Release --output /build/published-tests/`basename $1` $1' - '{}'" did not complete successfully: exit code: 123

Thats when building ESDB oss-v22.10.2 on arm64 (aarch64 according to cpuinfo)

jakzal added a commit to jakzal/kotlin-mastermind that referenced this issue Nov 9, 2023
…bstitutor for Apple silicon

This is required until the arm image is officially published.
See EventStore/EventStore#2380 (comment)
@jbpros
Copy link

jbpros commented May 31, 2024

@jokesterfr Thanks for the feedback, glad to hear that. The plan is to have 1 single multi-architecture image once we officially support ARM64. 😄

Hi,

Is that happening any time soon? Thanks!

@alexeyzimarev
Copy link
Member

Not yet. It is planned, but it's more tricky than we originally thought, and we have some things with higher priority right now.

@jbpros
Copy link

jbpros commented May 31, 2024

Alright, thanks for the quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build Issues relating to the build system linear
Projects
None yet
Development

No branches or pull requests