What is the correct way to deploy the code-server on alpine?
Is there an existing issue for this?
- [X] I have searched the existing issues
OS/Web Information
alpine3.18.4 in docker container
Steps to Reproduce
I try to step by step with the offical docs.
-
docker run --ti alpine:3.18.4 -
apk update && apk add alpine-sdk bash libstdc++ libc6-compat -
apk add python3 -
apk add nodejs=18.18.2-r0 -
apk add npm -
npm config set python python3, this command will error, then I try it thenpm config editand add the 'python=python3` in the open file -
export FORCE_NODE_VERSION=18 -
npm install --global code-server --unsafe-perm
Expected
success deploy the code-server
Actual
Print a log of error at the last step. I see the err tips:"You may not have the required dependencies to build the native modules", then I try to see the lists Node.js requirements and confirm the prerequisites, but also not success.
Logs
/ # npm install --global code-server --unsafe-perm
npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/code-server
npm ERR! command failed
npm ERR! command sh -c sh ./postinstall.sh
npm ERR! WARNING: Overriding required Node.js version to v18
npm ERR! This could lead to broken functionality, and is unsupported.
npm ERR! USE AT YOUR OWN RISK!
npm ERR! Installing Code dependencies...
npm ERR! User agent: npm/9.6.6 node/v18.18.2 linux x64 workspaces/false
npm ERR! You may not have the required dependencies to build the native modules.
npm ERR! Please see https://github.com/coder/code-server/blob/main/docs/npm.md
npm ERR! npm ERR! code 1
npm ERR! npm ERR! path /usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c prebuild-install --runtime napi || node-gyp rebuild
npm ERR! npm ERR! make: Entering directory '/usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos/build'
npm ERR! npm ERR! CXX(target) Release/obj.target/kerberos/src/kerberos.o
npm ERR! npm ERR! make: Leaving directory '/usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos/build'
npm ERR! npm ERR! prebuild-install warn install No prebuilt binaries found (target=4 runtime=napi arch=x64 libc=musl platform=linux)
npm ERR! npm ERR! gyp info it worked if it ends with ok
npm ERR! npm ERR! gyp info using [email protected]
npm ERR! npm ERR! gyp info using [email protected] | linux | x64
npm ERR! npm ERR! gyp info find Python using Python version 3.11.6 found at "/usr/bin/python3"
npm ERR! npm ERR! gyp info spawn /usr/bin/python3
npm ERR! npm ERR! gyp info spawn args [
npm ERR! npm ERR! gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! npm ERR! gyp info spawn args '-f',
npm ERR! npm ERR! gyp info spawn args 'make',
npm ERR! npm ERR! gyp info spawn args '-I',
npm ERR! npm ERR! gyp info spawn args '/usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos/build/config.gypi',
npm ERR! npm ERR! gyp info spawn args '-I',
npm ERR! npm ERR! gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! npm ERR! gyp info spawn args '-I',
npm ERR! npm ERR! gyp info spawn args '/root/.cache/node-gyp/18.18.2/include/node/common.gypi',
npm ERR! npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! npm ERR! gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/18.18.2',
npm ERR! npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! npm ERR! gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/18.18.2/<(target_arch)/node.lib',
npm ERR! npm ERR! gyp info spawn args '-Dmodule_root_dir=/usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos',
npm ERR! npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! npm ERR! gyp info spawn args '--depth=.',
npm ERR! npm ERR! gyp info spawn args '--no-parallel',
npm ERR! npm ERR! gyp info spawn args '--generator-output',
npm ERR! npm ERR! gyp info spawn args 'build',
npm ERR! npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! npm ERR! gyp info spawn args ]
npm ERR! npm ERR! gyp info spawn make
npm ERR! npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! npm ERR! In file included from ../src/kerberos_common.h:5,
npm ERR! npm ERR! from ../src/kerberos.h:12,
npm ERR! npm ERR! from ../src/kerberos.cc:1:
npm ERR! npm ERR! ../src/unix/kerberos_gss.h:21:14: fatal error: gssapi/gssapi.h: No such file or directory
npm ERR! npm ERR! 21 | #include <gssapi/gssapi.h>
npm ERR! npm ERR! | ^~~~~~~~~~~~~~~~~
npm ERR! npm ERR! compilation terminated.
npm ERR! npm ERR! make: *** [kerberos.target.mk:110: Release/obj.target/kerberos/src/kerberos.o] Error 1
npm ERR! npm ERR! gyp ERR! build error
npm ERR! npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! npm ERR! gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
npm ERR! npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:517:28)
npm ERR! npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:292:12)
npm ERR! npm ERR! gyp ERR! System Linux 3.10.0-1160.83.1.el7.x86_64
npm ERR! npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! npm ERR! gyp ERR! cwd /usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos
npm ERR! npm ERR! gyp ERR! node -v v18.18.2
npm ERR! npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! npm ERR! gyp ERR! not ok
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-11-15T11_07_26_826Z-debug-0.log
npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-11-15T11_07_16_538Z-debug-0.log
Screenshot/Video
No response
Does this issue happen in VS Code or GitHub Codespaces?
- [X] I cannot reproduce this in VS Code.
- [X] I cannot reproduce this in GitHub Codespaces.
Are you accessing code-server over a secure context?
- [X] I am using a secure context.
Notes
So, what the correct way to deploy the code-server on alpine? Or is it not support the alpine in docker?
Ah I think we are missing the krb5 dependency in our Alpine instructions. Maybe try installing krb5-dev.
https://github.com/mongodb-js/kerberos#requirements
I have followed the above steps. When I type code-server on the command line, the message says the server is at http://127.0.0.1:8080, but I can't pull anything up in the browser. I am attaching pictures. Anything else I can check?
Ah you probably need to bind to 0.0.0.0. If you use 127.0.0.1 then nothing outside the container can access it, even if the port is exposed.
8. npm install --global code-server --unsafe-perm
Thanks. As you suggested, I changed 127.0.0.1 to 0.0.0.0 in the config.yaml file. I restarted the container and now it works.
Closing for now since there are no action items for code-server. Tracking for potentially adding an official Alpine release is here: https://github.com/coder/code-server/issues/3431
@code-asher Do you have a working alpine Dockerfile are you willing to share it here in a post, been trying to get an alpine build up and running for several days now, still no luck with the latest 4.91.1 and alpine 3.20 or 3.19, so I hope you are willing to share.
No, I do not, but I tried building code-server on Alpine just now and these commands worked:
docker run -p 8080:8080 -it node:20.11.1-alpine sh
apk add git quilt python3 alpine-sdk libx11-dev libxkbfile-dev libstdc++ libc6-compat libsecret-dev jq rsync
git clone --recursive https://github.com/coder/code-server.git
cd code-server
quilt push -a
# Skipping kerberos since it fails to build and is optional anyway
sed -i 's/"kerberos": "^2.0.1",//' lib/vscode/package.json
sed -i 's/"kerberos": "^2.0.1",//' lib/vscode/remote/package.json
yarn install
yarn build
VERSION=4.91.1 yarn build:vscode
yarn release
yarn release:standalone
./release-standalone/bin/code-server --host 0.0.0.0
It would also normally be possible to package it withVERSION=4.91.1 yarn package to generate a tar.gz file but it looks like the version of tar in Alpine does not like the flags we use.