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

Create Alpine/APK package for Deno #240

Open
stabai opened this issue Aug 3, 2022 · 9 comments
Open

Create Alpine/APK package for Deno #240

stabai opened this issue Aug 3, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@stabai
Copy link

stabai commented Aug 3, 2022

Using Deno inside of an Alpine docker image is currently not super easy because you need to manually install it and add it to the path. If there were an Alpine APK package for it, it could be a simple matter of adding the following to your Dockerfile:

RUN apk add deno

This would be incredibly valuable for my team since we use Deno scripts in lots of places where we'd normally use Bash scripts. Since build processes are often complex, require multiple commands, and need to run on different environments, scripts are an ideal way to run them. We absolutely loathe writing Bash scripts, and the sooner we can get Deno into an environment so we can stop defaulting to Bash, the happier we are.

@AnInternetTroll
Copy link
Contributor

Have you considered using deno's docker image? https://hub.docker.com/r/denoland/deno

@AnInternetTroll
Copy link
Contributor

Also i believe denoland/deno#3711 should be resolved first

@stabai
Copy link
Author

stabai commented Aug 3, 2022

Using the denoland/deno:alpine image may be an option, but when using this setup to build docker images, it means we also need docker-in-docker. The easiest way to do that is to start with the docker:dind image and add any additional tooling needed on top of that.

@stabai
Copy link
Author

stabai commented Aug 3, 2022

Of course, there may already be a good way to create this setup that I'm not aware of. If there is, providing it on the deno install site would also be awesome. 🙂

@AnInternetTroll
Copy link
Contributor

Using the denoland/deno:alpine image may be an option, but when using this setup to build docker images, it means we also need docker-in-docker. The easiest way to do that is to start with the docker:dind image and add any additional tooling needed on top of that.

I was thinking something more like https://github.com/denoland/deno_docker#using-your-own-base-image
Though i've never heard of dind

@stabai
Copy link
Author

stabai commented Aug 3, 2022

Whoops, I was not aware of that repository! This is definitely a good example to follow (though an APK would still be a welcomed simplification).

@stabai
Copy link
Author

stabai commented Aug 3, 2022

In case anyone else runs into this: The methodology on that page works great when using a base image with ubuntu, but I'm not able to get it to work on alpine. Running deno in the container results in errors about missing dependencies.

My dockerfile:

FROM denoland/deno:alpine-1.24.1 AS deno

FROM docker:20.10.17-alpine3.16
RUN apk add libgcc qemu
COPY --from=deno /tini /tini
COPY --from=deno /bin/deno /usr/local/bin/deno

(I also tried deno:bin and deno:distroless, no luck there either)

Built container and ran deno within it:

docker buildx build --platform=linux/amd64 . --tag test-deno-alpine
docker run -it --rm --entrypoint=deno --platform=linux/amd64 test-deno-alpine

I get the following errors:

Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /usr/local/bin/deno)
Error relocating /usr/local/bin/deno: __isnan: symbol not found
Error relocating /usr/local/bin/deno: __memcpy_chk: symbol not found
Error relocating /usr/local/bin/deno: backtrace: symbol not found
Error relocating /usr/local/bin/deno: backtrace_symbols: symbol not found
Error relocating /usr/local/bin/deno: __vfprintf_chk: symbol not found
Error relocating /usr/local/bin/deno: __vsnprintf_chk: symbol not found
Error relocating /usr/local/bin/deno: __mbrlen: symbol not found
Error relocating /usr/local/bin/deno: strtoll_l: symbol not found
Error relocating /usr/local/bin/deno: strtoull_l: symbol not found
Error relocating /usr/local/bin/deno: __memmove_chk: symbol not found
Error relocating /usr/local/bin/deno: __register_atfork: symbol not found
Error relocating /usr/local/bin/deno: gnu_get_libc_version: symbol not found
Error relocating /usr/local/bin/deno: __res_init: symbol not found

It looks like this is because glibc, and I'm not sure why that's so difficult to get to work properly on alpine. The deno:alpine image looks like it's using a base image that already has this resolved.

@kitsonk kitsonk transferred this issue from denoland/deno_install Aug 3, 2022
@kitsonk
Copy link
Contributor

kitsonk commented Aug 3, 2022

I have moved this to deno_docker as any solution should be addressed in this repo.

@kitsonk kitsonk added the enhancement New feature or request label Aug 3, 2022
@stabai
Copy link
Author

stabai commented Aug 4, 2022

I finally managed to get Deno installed into an existing Alpine image without too much complexity. Piggybacking on the deno:alpine image did work, there were just more resources that needed to be copied.

Here's what I did:

FROM denoland/deno:alpine-1.24.1 AS deno

FROM docker:20.10.16-dind-alpine3.16   # or whatever alpine base image you want
COPY --from=deno /bin/deno /usr/local/bin/deno
COPY --from=deno /usr/glibc-compat /usr/glibc-compat
COPY --from=deno /lib/* /lib/
COPY --from=deno /lib64/* /lib64/
COPY --from=deno /usr/lib/* /usr/lib/

Now works perfectly when running:

docker buildx build --platform=linux/amd64 . --tag test-deno-alpine
docker run -it --rm --entrypoint=deno --platform=linux/amd64 test-deno-alpine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants