8000 maint(developer): add docker image to build developer node modules by ermshiperete · Pull Request #14058 · keymanapp/keyman · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

maint(developer): add docker image to build developer node modules #14058

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

Merged
merged 6 commits into from
Jun 10, 2025

Conversation

ermshiperete
Copy link
Contributor

Also update build documentation.

Fixes: #14045
Test-bot: skip

Also update build documentation.

Fixes: #14045
Test-bot: skip
@keymanapp-test-bot
Copy link
keymanapp-test-bot bot commented May 27, 2025

User Test Results

Test specification and instructions

User tests are not required

@keymanapp-test-bot keymanapp-test-bot bot added this to the A19S4 milestone May 27, 2025
@github-actions github-actions bot added docs resources/ developer/ maint Maintenance work -- continuous integration, build scripts, infrastructure labels May 27, 2025
@ermshiperete ermshiperete requested a review from Markus-SWAG May 27, 2025 16:18
Copy link
Member
@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to run this on my machine, failed:

marc@QUAMBY MINGW64 /d/Projects/keyman/app (maint/developer/14045_docker)
$ ./resources/docker-images/build.sh :developer
[resources/docker-images] Local build environment detected:  setting --debug
[resources/docker-images] build.sh parameters: <:developer --debug>
[resources/docker-images] Building image for base
noble: Pulling from library/ubuntu
0622fac788ed: Pull complete
Digest: sha256:6015f66923d7afbc53558d7ccffd325d43b4e249f41a6e93eef074c9505d2233
Status: Downloaded newer image for ubuntu:noble
docker.io/library/ubuntu:noble

What's next:
    View a summary of image vulnerabilities and recommendations → docker scout quickview ubuntu:noble
[+] Building 82.3s (10/13)                                                                                                             docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                   0.0s
 => => transferring dockerfile: 2.14kB                                                                                                                 0.0s 
 => [internal] load metadata for docker.io/library/ubuntu:noble                                                                                        0.0s 
 => [internal] load .dockerignore                                                                                                                      0.0s 
 => => transferring context: 2B                                                                                                                        0.0s 
 => [ 1/10] FROM docker.io/library/ubuntu:noble                                                                                                        0.0s 
 => [ 2/10] RUN grep ubuntu /etc/passwd && userdel ubuntu || true &&   rm -rf /home/ubuntu &&   useradd -c "Build user" --uid 1000 --home-dir /home/b  0.9s
 => [ 3/10] RUN apt-get -q -y update &&    apt-get -q -y install ca-certificates curl gnupg meson software-properties-common sudo &&   if [[ "$(lsb_  75.5s
 => [ 4/10] RUN apt-get -q -y update &&    apt-get -q -y upgrade                                                                                       3.5s
 => [ 5/10] RUN echo "build ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers                                                                                   0.5s
 => [ 6/10] RUN <<EOF cat > /usr/bin/bashwrapper                                                                                                       0.5s
 => ERROR [ 7/10] RUN NVM_RELEASE=$(curl -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep tag_name | cut -d : -f 2 | cut -d '"' -f 2  1.2s
------
 > [ 7/10] RUN NVM_RELEASE=$(curl -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep tag_name | cut -d : -f 2 | cut -d '"' -f 2) &&   curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_RELEASE}/install.sh | bash:
1.040   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
1.040                                  Dload  Upload   Total   Spent    Left  Speed
100   450  100   450    0     0   3252      0 --:--:-- --:--:-- --:--:--  3237
1.178 bash: line 2: syntax error near unexpected token `newline'
1.178 bash: line 2: `<?xml version="1.0" encoding="utf-8"?>'
------
Dockerfile:44
--------------------
  43 |     # Install NVM
  44 | >>> RUN NVM_RELEASE=$(curl -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep tag_name | cut -d : -f 2 | cut -d '"' -f 2) && \        
  45 | >>>   curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_RELEASE}/install.sh | bash
  46 |     RUN <<EOF cat >> /usr/bin/bashwrapper
--------------------
ERROR: failed to solve: process "/bin/bash -c NVM_RELEASE=$(curl -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep tag_name | cut -d : -f 2 | cut -d '\"' -f 2) &&   curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_RELEASE}/install.sh | bash" did not complete successfully: exit code: 2

@cvosoft
Copy link
cvosoft commented May 29, 2025

Thanks a lot for working on this! Having a Docker image will be a big help.

@ermshiperete
Copy link
Contributor Author

Thanks a lot for working on this! Having a Docker image will be a big help.

@cvosoft Does it work for you?

@ermshiperete
Copy link
Contributor Author

@mcdurdin Can you please try again? I don't know where it would get a XML file from, so it might have been a network glitch that returned an error page instead of nvm's install.sh.

Co-authored-by: Marc Durdin <marc@durdin.net>
@mcdurdin
Copy link
Member
mcdurdin commented Jun 4, 2025

@mcdurdin Can you please try again? I don't know where it would get a XML file from, so it might have been a network glitch that returned an error page instead of nvm's install.sh.

Yes, it built this time. However, attempting to run.sh on Windows fails:

marc@QUAMBY MINGW64 /d/Projects/keyman/app (maint/developer/14045_docker)
$ ./resources/docker-images/run.sh developer
[resources/docker-images] Local build environment detected:  setting --debug
[resources/docker-images] run.sh parameters: <developer --debug>
[resources/docker-images] ## developer starting...
exec /usr/bin/bashwrapper: no such file or directory
[resources/docker-images] ## developer failed

image

(Separate question, why does build.sh use targets e.g. :developer, whereas run.sh uses actions e.g. developer? It seems confusing -- I think in both cases they should be targets, as 'developer' is not actually an action)

@cvosoft
Copy link
cvosoft commented Jun 4, 2025

Thanks a lot for working on this! Having a Docker image will be a big help.

@ 8000 cvosoft Does it work for you?

christoph@desktop:/media/daten/CODING/keyman/resources/docker-images/linux$ docker build -t keyman-dev-env .
Sending build context to Docker daemon 5.632kB
Step 1/15 : ARG BASE_VERSION=default
Step 2/15 : FROM keymanapp/keyman-base-ci:${BASE_VERSION}
pull access denied for keymanapp/keyman-base-ci, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

It seems like the base image keymanapp/keyman-base-ci is not publicly accessible (yet?), so the build fails for me at that point.

@ermshiperete
Copy link
Contributor Author

It seems like the base image keymanapp/keyman-base-ci is not publicly accessible (yet?), so the build fails for me at that point.

@cvosoft Use the build.sh script to build both the base and the developer image (see resources/docker-images/README.md):

resources/docker-images/build.sh build:developer

@cvosoft
Copy link
cvosoft commented Jun 4, 2025

It seems like the base image keymanapp/keyman-base-ci is not publicly accessible (yet?), so the build fails for me at that point.

@cvosoft Use the build.sh script to build both the base and the developer image (see resources/docker-images/README.md):

resources/docker-images/build.sh build:developer

Quick update: I was able to successfully build the keyman-developer Docker image locally using ./build.sh build:developer. Thanks again!

I'm now working on running the tests with coverage using ./run.sh, and will report back once that’s working as well.

@cvosoft
Copy 8000 link
cvosoft commented Jun 4, 2025

I was able to successfully build the developer Docker image. But running the container fails with an execution error:

christoph@desktop:/media/daten/CODING/keyman/resources/docker-images$ ./run.sh developer -- npm run test:coverage --workspace @keymanapp/test-compiler

[resources/docker-images] Local build environment detected: setting --debug
[resources/docker-images] run.sh parameters: <developer --debug>
[resources/docker-images] run.sh extra parameters: <npm run test:coverage --workspace @keymanapp/test-compiler>
[resources/docker-images] ## developer starting...
exec /usr/bin/bashwrapper: exec format error
[resources/docker-images] ## developer failed

@ermshiperete
Copy link
Contributor Author
ermshiperete commented Jun 5, 2025

@cvosoft @mcdurdin You're both getting similar errors regarding /usr/bin/bashwrapper. Could you please run: resources/docker-images/run.sh developer -- /bin/bash and then post the output of:

ls -al /usr/bin/bashwrapper
cat /usr/bin/bashwrapper

Also, what version of docker do you have (docker --version) ?

@cvosoft
Copy link
cvosoft commented Jun 5, 2025

run.sh developer -- /bin/bash

christoph@desktop:/media/daten/CODING/keyman/resources/docker-images$ ./run.sh developer -- /bin/bash
[resources/docker-images] Local build environment detected: setting --debug
[resources/docker-images] run.sh parameters: <developer --debug>
[resources/docker-images] run.sh extra parameters: </bin/bash>
[resources/docker-images] ## developer starting...
exec /usr/bin/bashwrapper: exec format error
[resources/docker-images] ## developer failed

I am unable to start the container.

christoph@desktop:/media/daten/CODING/keyman/resources/docker-images$ docker --version
Docker version 27.5.1, build 27.5.1-0ubuntu3~24.04.2

rc-swag
rc-swag approved these changes Jun 6, 2025
@rc-swag rc-swag self-requested a review June 6, 2025 01:47
…`run.sh`

This adjusts `resources/docker-images/run.sh` to more closely match
the syntax in `build.sh`.
When running Docker on Windows Docker is not able to properly adjust to
the line ending. When it builds the image from a Dockerfile that's
checked out with the Windows-style line endings (\r\n), and it runs a
command like

```Dockerfile
RUN <<EOF cat > /usr/bin/bashwrapper
echo "Hello world!"
EOF
```

it makes the filename `/usr/bin/bashwrapper\r`! This change works around
this problem by always using LF line endings for
`resources/docker-images/**/Dockerfile`.
This change verifies that `docker buildx` is available and then uses that
for building the images. For that we apparently need the magic line at
the top of the `Dockerfile`s and set the environment variable
`DOCKER_BUILDKIT`. This solves a problem building docker images on
Linux with an older Docker version where the heredocs didn't work.
@ermshiperete
Copy link
Contributor Author
ermshiperete commented Jun 6, 2025
8000

@cvosoft I think I found and fixed the problem. Can you please try again with the latest changes from maint/developer/14045_docker?

(There were actually two different problems on Windows and on Ubuntu)

NOTE:* the run.sh command changed slightly, specifying the platform as target instead of action, so you'll have to run resource/docker-images/run.sh :developer

@ermshiperete ermshiperete requested a review from mcdurdin June 6, 2025 16:23
@cvosoft
Copy link
cvosoft commented Jun 6, 2025

Very well done!

Building (after installing docker-buildx) worked fine. And also running with the new syntax ( :developer) works.

Thanks!

@mcdurdin
Copy link
Member
mcdurdin commented Jun 7, 2025

Sadly, on Windows, the image is now building, but run.sh is giving bad results.

marc@QUAMBY MINGW64 /d/Projects/keyman/app (maint/developer/14045_docker)
$ ./resources/docker-images/run.sh :developer -- developer/build.sh --debug build
[resources/docker-images] Local build environment detected:  setting --debug
[resources/docker-images] run.sh parameters: <:developer --debug>
[resources/docker-images] run.sh extra parameters: <developer/build.sh --debug build>
[resources/docker-images] ## run:developer starting...
/usr/bin/bashwrapper: line 13: developer/build.sh: No such file or directory
[resources/docker-images] ## run:developer failed

Running bash works now, but I'm not sure I understand the filesystem as it stands; weird '\Program Files\...' paths, just emdsk and build folders in ~/:

marc@QUAMBY MINGW64 /d/Projects/keyman/app (maint/developer/14045_docker)
$ ./resources/docker-images/run.sh :developer -- bash
[resources/docker-images] Local build environment detected:  setting --debug
[resources/docker-images] run.sh parameters: <:developer --debug>
[resources/docker-images] run.sh extra parameters: <bash>
[resources/docker-images] ## run:developer starting...
build@29a9c7e5f26b:~/build$ ls -l
total 0
build@29a9c7e5f26b:~/build$ ls / -la
total 76
drwxr-xr-x   1 root root 4096 Jun  7 05:31  .
drwxr-xr-x   1 root root 4096 Jun  7 05:31  ..
-rwxr-xr-x   1 root root    0 Jun  7 05:31  .dockerenv
drwxrwxrwx   1 root root 4096 Jun  4 01:16 '\Program Files\Git\home\build\build'
drwxrwxrwx   1 root root 4096 Jun  4 01:16 '\Program Files\Git\home\build\build\core\build'
lrwxrwxrwx   1 root root    7 Apr 22  2024  bin -> usr/bin
drwxr-xr-x   2 root root 4096 Apr 22  2024  boot
drwxr-xr-x   5 root root  360 Jun  7 05:31  dev
drwxr-xr-x   1 root root 4096 Jun  7 05:31  etc
drwxr-xr-x   1 root root 4096 Jun  7 04:42  home
lrwxrwxrwx   1 root root    7 Apr 22  2024  lib -> usr/lib
drwxr-xr-x   2 root root 4096 Nov 14  2024  lib.usr-is-merged
lrwxrwxrwx   1 root root    9 Apr 22  2024  lib64 -> usr/lib64
drwxr-xr-x   2 root root 4096 May 29 02:14  media
drwxr-xr-x   2 root root 4096 May 29 02:14  mnt
drwxr-xr-x   2 root root 4096 May 29 02:14  opt
dr-xr-xr-x 339 root root    0 Jun  7 05:31  proc
drwx------   1 root root 4096 Jun  7 04:44  root
drwxr-xr-x   1 root root 4096 Jun  7 04:44  run
lrwxrwxrwx   1 root root    8 Apr 22  2024  sbin -> usr/sbin
drwxr-xr-x   2 root root 4096 May 29 02:14  srv
dr-xr-xr-x  13 root root    0 Jun  7 05:31  sys
drwxrwxrwt   1 root root 4096 Jun  7 05:20  tmp
drwxr-xr-x   1 root root 4096 May 29 02:14  usr
drwxr-xr-x   1 root root 4096 May 29 02:22  var
build@29a9c7e5f26b:~/build$ ls ..
build  emsdk

@ermshiperete
Copy link
Contributor Author
ermshiperete commented Jun 10, 2025

I created #14153 for the problems running on Windows since this seems to be a general problem and not directly related to this PR.

@ermshiperete ermshiperete merged commit 7ef985d into master Jun 10, 2025
28 checks passed
@ermshiperete ermshiperete deleted the maint/developer/14045_docker branch June 10, 2025 15:32
@github-project-automation github-project-automation bot moved this from Todo to Done in Keyman Jun 10, 2025
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 19.0.61-alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer/ docs maint Maintenance work -- continuous integration, build scripts, infrastructure resources/
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

maint(developer): add docker image for developer node modules
5 participants
0