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

supporting installing node into an alpine based container #109

Closed
fagai opened this issue Feb 2, 2020 · 10 comments
Closed

supporting installing node into an alpine based container #109

fagai opened this issue Feb 2, 2020 · 10 comments
Assignees
Labels
enhancement New feature or request

Comments

@fagai
Copy link

fagai commented Feb 2, 2020

I use alpine linux for my container.

jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: php:7.3-fpm-alpine

    steps:
    - uses: actions/checkout@v1

    - name: use Node
      uses: actions/setup-node@v1
      with:
        node-version: 12.x

    - name: npm install
      run: npm install

actions/setup-node succeeds, but npm install fails.

Run npm install
  npm install
  shell: sh -e {0}
env: can't execute 'node': No such file or directory
##[error]Process completed with exit code 127.

Is there a way to work with alpine linux?

@fagai fagai changed the title Setuped in alpine container but not available. alpine linux container is fail. Feb 2, 2020
@Swiftwork
Copy link

Swiftwork commented Feb 3, 2020

Hi @fagai,

As you you might have noticed alpine is a very bare-bones container and is often used for hosting small containers. php:7.3-fpm.alpine does indeed not contain nodejs as seen in this Dockerfile. So you will have to find another image that suits your needs or create your own like this Dockerfile and push it to Docker Hub or any other repository you might have access to.

Edit: My bad, this is incorrect.

@fagai
Copy link
Author

fagai commented Feb 3, 2020

@Swiftwork
Isn't this an action to include node.js?

@Swiftwork
Copy link

You are right @fagai, I'm not sure what I was thinking 😅

@bryanmacfarlane
Copy link
Member

Node doesn't have a dist yet for alpine where you can pull JIT
https://nodejs.org/dist/index.json

But they do publish alpine containers with node
https://hub.docker.com/_/node

Can you elaborate on your scenario a bit? Are you trying to test your lib on alpine with node? Are you trying to test a node app meant to distribute with node?

@bryanmacfarlane bryanmacfarlane self-assigned this Mar 31, 2020
@fagai
Copy link
Author

fagai commented Apr 1, 2020

@bryanmacfarlane
I wanted to build assets with a personal alpine linux image.
However, I now use the standard ubuntu-latest.

@bryanmacfarlane
Copy link
Member

Have you considered something like this instead?

jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: 'node:12.16.1-alpine3.9'

    steps:
    - uses: actions/checkout@v1
    - name: npm install
       run: npm install

Note that you end up with node 12 in an alpine container and the toolset is sealed (good practice in containers).

If you need to customize the container then you can docker build from that image.

@fagai
Copy link
Author

fagai commented Apr 1, 2020

I wanted to use php at the same time, so I made it based on php-fpm image.
As we understood that it was not available, we stopped building in the container.

@bryanmacfarlane bryanmacfarlane changed the title alpine linux container is fail. supporting installing node into an alpine based container Apr 1, 2020
@bryanmacfarlane bryanmacfarlane added the enhancement New feature or request label Apr 1, 2020
@adabru
Copy link

adabru commented Apr 9, 2021

There are unofficial builds for 64-bit alpine provided by a nodejs member: https://unofficial-builds.nodejs.org . They have no dedicated maintainer but the build process is open for contributions if an issue should arise in the future.

@dmitry-shibanov
Copy link
Contributor

Hello @fagai. Actually setup-node sets up a volume to the toolcache directory where nodejs versions persist. I think node installed to docker image was not compatible with used alpine image.

As @adabru mentioned for alpine images unofficial-builds.nodejs.org builds are used or nodejs is built from source code. For now I think the error is expected because setup-node installs nodejs binaries from https://nodejs.org/dist.

@dmitry-shibanov
Copy link
Contributor

Hello @fagai. I've tried to investigate the issue deeper and it looks like the action won't be able to configure nodejs from source code for alpine images, because it requires extra tools and libs (for example python) which could not persist on the docker image.

I think the most suitable solution for this will be installing unofficial builds. We have issue with adding mirrors. But you still can have problems with node because alpine does not contain all necessary libs, that is why possibly you'll need to execute apk add --no-cache libstdc++.

For now I'm closing the issue. If you have any concerns or questions feel free to ping us.

deining pushed a commit to deining/setup-node that referenced this issue Nov 9, 2023
Bumps [husky](https://github.com/typicode/husky) from 4.3.0 to 4.3.6.
- [Release notes](https://github.com/typicode/husky/releases)
- [Commits](typicode/husky@v4.3.0...v4.3.6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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

5 participants