progrium / entrykit

Entrypoint tools for elegant, programmable containers
443 stars 29 forks source link

Support on Mac M1 #16

Closed analyn-cajocson closed 11 months ago

analyn-cajocson commented 3 years ago

Hi, do you have any plan on supporting the Macbook M1? I'm getting this error on my machine:

image

Here's how we used entrykit in our Docker


RUN wget https://github.com/progrium/entrykit/releases/download/v${ENTRYKIT_VERSION}/entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz \
  && tar -xvzf entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz \
  && rm entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz \
  && mv entrykit /bin/entrykit \
  && chmod +x /bin/entrykit \
  && entrykit --symlink

Thank you!

joemcmahon commented 3 years ago

This doesn’t appear to be an entrykit bug specifically, but one related to the Go runtime. What is your current ulimit setting? You might try bumping it up and see if that fixes the issue.

I do not have an M1 machine available, unfortunately, so we’ll have to try what we can to eliminate causes.

On Thu, Jun 17, 2021 at 11:09 PM Analyn Cajocson @.***> wrote:

Hi, do you have any plan on supporting the Macbook M1? I'm getting this error on my machine:

[image: image] https://user-images.githubusercontent.com/9253881/122514398-7f773280-d03e-11eb-9680-25d3ff841064.png

Here's how we used entrykit in our Docker

RUN wget https://github.com/progrium/entrykit/releases/download/v${ENTRYKIT_VERSION}/entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz \ && tar -xvzf entrykit_${ENTRYKIT_VERSION}_Linux_x8664.tgz \ && rm entrykit${ENTRYKIT_VERSION}_Linux_x86_64.tgz \ && mv entrykit /bin/entrykit \ && chmod +x /bin/entrykit \ && entrykit --symlink

Thanks you!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/progrium/entrykit/issues/16, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAO6G4YI3V6WHSIHQEJN7DTTLPIFANCNFSM465AIDIA .

analyn-cajocson commented 3 years ago

This doesn’t appear to be an entrykit bug specifically, but one related to the Go runtime. What is your current ulimit setting? You might try bumping it up and see if that fixes the issue. I do not have an M1 machine available, unfortunately, so we’ll have to try what we can to eliminate causes. On Thu, Jun 17, 2021 at 11:09 PM Analyn Cajocson @.***> wrote: Hi, do you have any plan on supporting the Macbook M1? I'm getting this error on my machine: [image: image] https://user-images.githubusercontent.com/9253881/122514398-7f773280-d03e-11eb-9680-25d3ff841064.png Here's how we used entrykit in our Docker RUN wget https://github.com/progrium/entrykit/releases/download/v${ENTRYKITVERSION}/entrykit${ENTRYKIT_VERSION}_Linux_x86_64.tgz \ && tar -xvzf entrykit_${ENTRYKIT_VERSION}_Linux_x8664.tgz \ && rm entrykit${ENTRYKIT_VERSION}_Linux_x86_64.tgz \ && mv entrykit /bin/entrykit \ && chmod +x /bin/entrykit \ && entrykit --symlink Thanks you! — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#16>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAO6G4YI3V6WHSIHQEJN7DTTLPIFANCNFSM465AIDIA .

Am I doing it right?

➜  ~ launchctl limit maxfiles
    maxfiles    65536          200000
➜  ~ ulimit -n
65536

I'm getting the same error... Btw, thank you for your fast response.

joemcmahon commented 3 years ago

That looks correct to me. I will do some research and get back to you on what we should try next. Can you build entrykit outside of Docker, or does it fail both places?

On Fri, Jun 18, 2021 at 6:31 PM Analyn Cajocson @.***> wrote:

This doesn’t appear to be an entrykit bug specifically, but one related to the Go runtime. What is your current ulimit setting? You might try bumping it up and see if that fixes the issue. I do not have an M1 machine available, unfortunately, so we’ll have to try what we can to eliminate causes. … <#m508000640305212840> On Thu, Jun 17, 2021 at 11:09 PM Analyn Cajocson @.**> wrote: Hi, do you have any plan on supporting the Macbook M1? I'm getting this error on my machine: [image: image] https://user-images.githubusercontent.com/9253881/122514398-7f773280-d03e-11eb-9680-25d3ff841064.png Here's how we used entrykit in our Docker RUN wget https://github.com/progrium/entrykit/releases/download/v${ENTRYKIT_VERSION}/entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz \ && tar -xvzf entrykit_${ENTRYKIT_VERSION}Linux_x86_64.tgz \ && rm entrykit*${ENTRYKIT_VERSION}_Linux_x86_64.tgz \ && mv entrykit /bin/entrykit \ && chmod +x /bin/entrykit \ && entrykit --symlink Thanks you! — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#16 https://github.com/progrium/entrykit/issues/16>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAO6G4YI3V6WHSIHQEJN7DTTLPIFANCNFSM465AIDIA .

Am I doing it right?

➜ ~ launchctl limit maxfiles

maxfiles 65536 200000

➜ ~ ulimit -n

65536

I'm getting the same error... Btw, thank you for your fast response.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/progrium/entrykit/issues/16#issuecomment-864337269, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAO6GYNTRLWON76RVAGXALTTPXQLANCNFSM465AIDIA .

analyn-cajocson commented 3 years ago

Hmm, let me figure out how to build entrykit outside of Docker. I will get back to you once I'm done. Thank you!

analyn-cajocson commented 3 years ago

Hello, I tried running the same command on my M1 and got an error:

➜ entrykit --symlink
zsh: command not found: entrykit

I downloaded the entrykit_0.4.0_Darwin_x86_64.tgz and run the following command first:

➜  tar -xvzf entrykit_0.4.0_Darwin_x86_64.tgz
x entrykit
➜  chmod +x entrykit
joemcmahon commented 3 years ago

Right -- it would be looking for entrykit in your PATH rather than in the current directory. Does ./entrykit --symlink run?

analyn-cajocson commented 3 years ago

Right -- it would be looking for entrykit in your PATH rather than in the current directory. Does ./entrykit --symlink run?

oww ./entrykit --symlink works

analyn-cajocson commented 3 years ago

I tried to update the command on the Dockerfile:

ENV ENTRYKIT_VERSION 0.4.0

RUN wget https://github.com/progrium/entrykit/releases/download/v${ENTRYKIT_VERSION}/entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz \
  && tar -xvzf entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz \
  && rm entrykit_${ENTRYKIT_VERSION}_Linux_x86_64.tgz \
  && mv entrykit /bin/entrykit \
  && chmod +x /bin/entrykit \
  && /bin/entrykit --symlink

And got an error: image

joemcmahon commented 3 years ago

Okay, here's what appears to be happening -- I did some searching on that exact error string: runtime: failed to create new OS thread (have 2 already; errno=22); it looks like this happens because the Docker image is trying to execute a binary not built for M1. You would hope for a better message, but that's what we get.

If you're using entrykit in your own Docker image, then the best thing to do is build entrykit itself in the Dockerfile, so that the binary is correct for your architecture. This isn't something I can tackle this evening (it's 10PM here) -- you can give it a shot if you like, and I'll carve out some time to work on it as soon as I can; worst case that will be Monday. This PR for nginx-proxy is a possible starting point for that: https://github.com/KWARC/nginx-proxy/blob/build-from-scratch/Dockerfile, and the entrykit Dockerfile probably should do the same.

And I will also see about creating a multi-architecture build as well; that may also be a possible fix. But the "build it in my Dockerfile" approach should definitely work. https://blog.jaimyn.dev/how-to-build-multi-architecture-docker-images-on-an-m1-mac/ tells how to do the multi-arch build, and I'll look at that on Monday as well.

analyn-cajocson commented 3 years ago

Hi @joemcmahon , thanks for the reference that you've sent. Let me look at it first then see what I can do.

philaser commented 2 years ago

Hi @joemcmahon, any instructions on how to build entrykit in the Dockerfile? Thanks a lot for your help

philaser commented 2 years ago

After a few hours, I have found a nice way of extending an exisiting dockerfile to build entrykit without major modifications.

FROM golang:1.7.3
COPY path/to/entrykit/repo /entrykit
RUN cd /entrykit \
    && make build \
    && mv Linux/entrykit /bin/entrykit \
    && chmod +x /bin/entrykit \
    && entrykit --symlink
Brescia717 commented 1 year ago

Any progress with this issue?

philaser commented 1 year ago

@Brescia717 unfortunately there has been no new release so you would still have to build the binaries on your M1 Mac.

I created this build step in the Dockerfile that needed to use Entrykit, essentially turning my Dockerfile into a multi-stage build

# pulls entrykit from master and builds 
FROM golang:1.17.1

RUN apt-get update && \
    apt-get install unzip -y

RUN wget https://github.com/progrium/entrykit/archive/refs/heads/master.zip \
    && echo testing the dir \
    && ls -a\
    && unzip master.zip \
    && rm master.zip \
    && cd entrykit-master/ \
    && make build \
    && mv build/Linux/entrykit /bin/entrykit

place this stage at the beginning of your Dockerfile and continue with your own Dockerfile stage:

FROM image

# This will copy the newly built Entrykit binaries to your docker file stage
COPY --from=0 /bin/entrykit /bin/entrykit
# This will run and create symlinks
RUN chmod +x /bin/entrykit \
    && entrykit --symlink
joemcmahon commented 1 year ago

@philaser, could you make a PR with this? I could just add it but I'd far rather you get the credit!

Brescia717 commented 1 year ago

@Brescia717 unfortunately there has been no new release so you would still have to build the binaries on your M1 Mac.

I created this build step in the Dockerfile that needed to use Entrykit, essentially turning my Dockerfile into a multi-stage build

# pulls entrykit from master and builds 
FROM golang:1.17.1

RUN apt-get update && \
    apt-get install unzip -y

RUN wget https://github.com/progrium/entrykit/archive/refs/heads/master.zip \
    && echo testing the dir \
    && ls -a\
    && unzip master.zip \
    && rm master.zip \
    && cd entrykit-master/ \
    && make build \
    && mv build/Linux/entrykit /bin/entrykit

place this stage at the beginning of your Dockerfile and continue with your own Dockerfile stage:

FROM image

# This will copy the newly built Entrykit binaries to your docker file stage
COPY --from=0 /bin/entrykit /bin/entrykit
# This will run and create symlinks
RUN chmod +x /bin/entrykit \
    && entrykit --symlink

Thanks for the help! Any chance you've tried using prehook? Running this in the Dockfile:

ENTRYPOINT [ \
  "prehook", "ruby -v", "--", \
  "prehook", "/myapp/backend/prehook", "--"]

yields this error:

Error response from daemon: failed to create shim task: 
OCI runtime create failed: runc create failed: 
unable to start container process: 
exec: "prehook": executable file not found in $PATH: unknown

NOTE: /myapp/backend is the directory the application is in in the docker container.

joemcmahon commented 1 year ago

@Brescia717 -- want to open the prehook problem as a separate issue? I'm going to put entrykit up on Hacktoberfest to motivate people to get a fix in if it's not fixed by then.

Edit: Never mind, got it for you.

analyn-cajocson commented 11 months ago

I think this issue was already resolved. Can we close this ticket now? 😅

joemcmahon commented 11 months ago

Yep, let's close it.