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

Update Dockerfile #1092

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Update Dockerfile #1092

wants to merge 2 commits into from

Conversation

am97
Copy link
Contributor

@am97 am97 commented Sep 12, 2024

  • Node 16 is the current version used to build Pulsar.
  • Remove libs that seem no longer necessary
  • Do not install npm as it's already included in new base image
  • Python 2 is no longer supported. Build and packaging run fine with Python 3
  • Instead of copying the repo to the image, it's more efficient to do a bind mount when using the image, it's quicker and doesn't require a rebuild
  • Use a non-root user, it's a security best-pratice, and fixes an error when running 'yarn build:apm': "EACCES: permission denied, scandir '/root/.npm/_logs'"

Tests

After cloning the pulsar repo and updating submodules, I run the image with docker run --rm -it -v /path/to/pulsar:/repo -w /repo my_image. The following commands are working correctly inside the image:

  • yarn install
  • yarn build
  • yarn build:apm
  • yarn dist appimage
  • yarn dist deb
  • yarn dist rpm
  • yarn dist targz

- Node 16 is the current version used to build Pulsar.
- Remove libs that seem no longer necessary
- Do not install npm as it's already included in new base image
- Python 2 is no longer supported. Build and packaging run fine with Python 3
- Instead of copying the repo to the image, it's more efficient to do a bind
  mount when using the image, it's quicker and doesn't require a rebuild
- Use a non-root user, it's a security best-practice, and fixes an error when
  running 'yarn build:apm': "EACCES: permission denied, scandir '/root/.npm/_logs'"
@confused-Techie
Copy link
Member

Thanks a ton for contributing!

I'll be honest, we don't really use the docker file anywhere in production currently, but it's a fantastic idea to keep this updated to help others use cases or just to make sure information is easily shared to others attempting to setup Pulsar.

So I'll do my best to take a look into this PR soon, and confirm that everything matches how it should.

@am97
Copy link
Contributor Author

am97 commented Oct 16, 2024

Thanks ! My use case is to make a local build without installing all the dev tools directly on my system, so I updated the Dockerfile while working on my other PR.

I realized that since a non-root user is used now, there should be a way to configure it's UID/GID, I'll add that

@am97
Copy link
Contributor Author

am97 commented Oct 17, 2024

The steps to build Pulsar using Docker would be now:

  • Clone the repo and update submodules
  • Prepare the build image: docker build --build-arg "PUID=$(id -u)" --build-arg "PGID=$(id -g)" -t pulsar-dev (the UID/GID of the current user will be used for the pulsar user inside the container, so that it can read/write bind mounts)
  • Launch the build image: docker run --rm -it -v $PWD:/repo -w /repo pulsar-dev
  • Inside the container, install dependencies and build Pulsar & ppm:
    yarn install
    yarn build
    yarn build:apm
    
  • Package Pulsar with one of:
    • yarn dist appimage
    • yarn dist deb
    • yarn dist rpm
    • yarn dist targz

I also realized that yarn start doesn't work inside the container, as that requires a GUI. It's possible, but non-trivial to share the host GUI with the container (see for example https://stackoverflow.com/a/25280523).

Even without a working yarn start, it would still be useful to be able to build Pulsar with Docker, for people making just small changes / fixing bugs

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

Successfully merging this pull request may close these issues.

2 participants