-
Notifications
You must be signed in to change notification settings - Fork 267
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
Support for running via a docker image? #46
Comments
This is what I am using: FROM node:18
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -qy tini libc++1
WORKDIR /app
RUN npm install workerd
COPY config.capnp hello.js ./
CMD ["tini", "./node_modules/.bin/workerd", "serve", "config.capnp"] |
I have the following Dockerfile but I get an error, running on M1 MacOS: FROM node:18
RUN apt-get update && apt-get -y install libc++-dev libunwind-dev
WORKDIR /app
RUN npm install workerd
COPY workerd.capnp worker.js health-check.js ./
CMD ["./node_modules/.bin/workerd", "serve", "workerd.capnp"]
Any ideas? |
You removed |
@frafra I tried that, same error: FROM node:18
RUN apt-get update && apt-get -y install libc++1 libunwind8
WORKDIR /app
RUN npm install workerd
COPY workerd.capnp worker.js health-check.js ./
CMD ["./node_modules/.bin/workerd", "serve", "workerd.capnp"] |
This is an error with your modified version of your Dockerfile. Please stick with the suggested packages. There is no need to install libunwind explicitly, since it is a dependency of libc++1. You are specifying a version of libunwind which is not the one required by libc++1 currently. Look at the Debian packages webpage for more information. I followed the Getting Started section of this repository and made a new one, with the suggested hello world example and a simple Dockefile, which works flawlessly. I would suggest you start there: https://github.com/frafra/workerd-docker |
I haven't written out everything I've tried, all of the changes to dockerfiles would probably blow through the character limit on a GitHub comment. I have of course tried your dockerfile with no luck. Anything I try throws back the |
You said to use M1. That could explain why you are having different results. Have you just tried to build the Dockerfile within the repository I linked? Do you get the very same error even when using that repository and the hello world files? libunwind8 does not provide libunwind.so.1. libunwind is a requirement of libc++ only staring from Debian Bookworm (v12, current testing), but node:18 uses Debian Buster (v11, current stable). The package is named libunwind-14 in Debian Sid and libunwind-13 in Debian Buster: https://packages.debian.org/search?suite=bullseye§ion=all&arch=any&searchon=contents&keywords=libunwind.so.1. Could it be that libunwind.so.1 is a (indirect) dependency of workerd only on M1? Try to add libunwind-13. |
I made a branch with the additional dependency: https://github.com/frafra/workerd-docker/tree/fix-missing-libunwind |
Ah, adding
|
I have a basic docker image for amd64 here: https://github.com/Cyb3r-Jak3/docker-workerd. Smaller than installing it via npm. Arm64 support is on the way. |
Zooming out a bit, a broader problem here may be that our binary has too many dependencies on shared libraries that lack stable ABIs across distros. We should try to statically link more of these, at least in our npm releases. When it comes to glibc specifically, though, we do need to dynamically link. Fortunately glibc has strong ABI compatibility. However, we need to make sure to link against an older version of glibc, since generally a binary will only work with the version it was linked against and newer versions, but not older ones. cc @penalosa |
Have you installed it together with |
Hmm are you sure? I don't think any of our binaries are static. |
My bad, I was looking at the wrong executable:
|
I managed to build
The compiled binary is located under Appreciate it's still an early Beta.... but an official Dockerfile in the repo would be really helpful for those who wants to try A static binary would be very helpful too, because then it could be copied to VSCode Dev Container as a 1-liner:
|
💯 for static binaries. This is something Deno got sooooo right. |
Trying to build the project in ubuntu:20.04
Any ideas? |
I also receive the following error using Docker (arm):
docker compose:
|
My guess is you need to install |
I'm working in a WSL Ubuntu VM and installing
|
Which version of Ubuntu are you using in WSL? There have been some issue with Ubuntu 20—trying Ubuntu 22 should work? |
Ah I do have Ubuntu 20. I'll try 22 at some point, thanks! |
If anyone has this working in Github Codespaces I'd love to know how. |
It's the same thing on ArchLinux.. Seems like that I have all devel things, like It definitely would be better to lower the dependencies.
Yep. |
Does anyone have it working on WSL without the dreaded |
@KeesCBakker you need to upgrade your ubuntu version, 22.04 |
Now that Miniflare v3 (with workerd) is the default dev command in Wrangler, this issue is more important to robustly solve. To summarise the above: The two packages that are most commonly concurrently out of date in this thread are The workaround is to upgrade your Docker image—or really, to upgrade whatever base images you’re relying on—to one of those OS versions. In my case, the stack of images I was relying on was:
(The last two images are commonly used by GitHub Codespaces) I was able to adapt the images pretty easily by combining them into one Dockerfile and adapting the deepest dependency from My Dockerfile is below, but don’t copy-paste this. Your setup is going to be different to mine depending on your container/OS. #
# Adapted from Node's image (with `corepack enable` instead of installing Yarn)
#
FROM buildpack-deps:bookworm
RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
ENV NODE_VERSION 18.6.0
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
&& case "${dpkgArch##*-}" in \
amd64) ARCH='x64';; \
ppc64el) ARCH='ppc64le';; \
s390x) ARCH='s390x';; \
arm64) ARCH='arm64';; \
armhf) ARCH='armv7l';; \
i386) ARCH='x86';; \
*) echo "unsupported architecture"; exit 1 ;; \
esac \
# gpg keys listed at https://github.com/nodejs/node#release-keys
&& set -ex \
&& for key in \
4ED778F539E3634C779C87C6D7062848A1AB005C \
141F07595B7B3FFE74309A937405533BE57C7D57 \
74F12602B6F1C4E913FAA37AD3A89613643B6201 \
DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7 \
61FC681DFB92A079F1685E77973F295594EC4689 \
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \
C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \
108F52B48DB57BB0CC439B2997B01419BD92F80A \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs \
&& corepack enable \
# smoke tests
&& node --version \
&& npm --version
#
# Adapted from Microsoft's `javascript-node` repo
#
ARG USERNAME=node
ARG NPM_GLOBAL=/usr/local/share/npm-global
# Add NPM global to PATH.
ENV PATH=${NPM_GLOBAL}/bin:${PATH}
RUN \
# Configure global npm install location, use group to adapt to UID/GID changes
if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
&& usermod -a -G npm ${USERNAME} \
&& umask 0002 \
&& mkdir -p ${NPM_GLOBAL} \
&& touch /usr/local/etc/npmrc \
&& chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
&& chmod g+s ${NPM_GLOBAL} \
&& npm config -g set prefix ${NPM_GLOBAL} \
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
# Install eslint
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
&& npm cache clean --force > /dev/null 2>&1
#
# Adapted from Microsoft's `typescript-node` repo
#
ARG NODE_MODULES="tslint-to-eslint-config typescript"
RUN su node -c "umask 0002 && npm install -g ${NODE_MODULES}" \
&& npm cache clean --force > /dev/null 2>&1
# Install `libc++-dev` for workerd to work
RUN apt-get update && apt-get -y install libc++-dev This is too much to expect a normal user to do, however, and at least being clearer about minimum OS versions in Wrangler would be a good move. |
I was able to get this working with the proposed node Bookworm Docker images. I |
For Arch users, it seems we can make a soft link to |
A (temporary) solution for Fedora 38 is to install $ ./node_modules/workerd/bin/workerd --version
./node_modules/workerd/bin/workerd: error while loading shared libraries: libunwind.so.1: cannot open shared object file: No such file or directory
$ dnf install -y llvm-libunwind
$ ./node_modules/workerd/bin/workerd --version
workerd 2023-05-12 The library has a different soname ( For distros that doesn't distribute LLVM's libunwind, one could attempt to symlink |
I got this working by selecting a newer devcontainer image (f.ex. ubuntu 22.04 -> mcr.microsoft.com/devcontainers/base:ubuntu), see https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers#using-a-predefined-dev-container-configuration for instructions on how to customize your codespaces devcontainer. If you're using the Ubuntu base image, just install npm/node using your preferred method, then make sure to |
I can confirm the above suggestion by @jormaj works on docker (managed by VS Code) running mcr.microsoft.com/devcontainers/base:ubuntu (ubuntu 22.04) image. |
I am using image 'mcr.microsoft.com/vscode/devcontainers/javascript-node:16', with wrangler 3.0.1 after installing |
For Arch Linux users:
|
Cannot get |
Wrangler does not work on Debian 11 , I installed clang libc++-dev libc++abi-dev by apt install command , however, does not work correctly. Please let me know, I think Debian and Ubuntu are most popular Linux OS on Interent server. Thanks. -- log ? Compiled Worker successfully
|
@Karakatiza666 As of this morning, you should be able to depend on |
Hey! 👋 As of #793 and #800, running FROM node:18
WORKDIR /app
RUN npm install workerd@beta
COPY config.capnp worker.js ./
EXPOSE 8080
CMD ["./node_modules/.bin/workerd", "serve", "config.capnp"] I'm going to close this now, and will update this comment once |
Could this be supported out of the box?
Looks like there's been some teething problems getting it to work here: #20 (comment)
The text was updated successfully, but these errors were encountered: