Skip to content

Could we use this project within our Dockerfile #2

Open

Description

@pascalandy

Curious to know if we could run pkg without installing in on the host and still be able to package a nodeapp with pkg.

Some more context:
https://medium.com/@marcosnils/reducing-nodejs-docker-images-size-by-50-using-multi-sage-builds-and-zeit-pkg-360ab8b6c6d2

Activity

  1. beeman commented on May 3, 2017

    @beeman
    Collaborator

    Hi @pascalandy ,

    If you run the following command in your project it should build a file called app.bin:

    docker run -it --name dockerpkg-builder -v $(pwd):/app/ -v $(pwd)/.pkg-cache:/root/.pkg-cache --rm dockerpkg/builder:latest
    

    This is the file that you can run in your own container, which you can base on the Dockerfile of this example:

    FROM dockerpkg/runner
    
    COPY app.bin /app/
    

    The idea behind this project is to separate building and running.

    I think I'm going to create an npm package that you can use to easily run the builder.

    I hope this make it a bit clearer :)

  2. pascalandy commented on May 3, 2017

    @pascalandy
    Author

    Seems exactly like the way it should! I think this will be a killer for the docker community :)

    If you want to enhance the example from @marcosnils (link above) that would be great :)

  3. marcosnils commented on May 3, 2017

    @marcosnils

    NPM all the things!.

    @pascalandy not sure I'm understanding the use-case you need. You want to have an npm package that just triggers a pkg through docker and just builds a binary?, or create a docker image?

    In the example I've provided you only need to have docker to create your new docker images, for what I understand seems like you want to run pkg in a container and then take the binary output and run it in your host, right?. If this is the case, then you need to be extremely careful about different runtimes as you might get unexpected errors while trying to do it.

    If you build + package using docker all the way, you minimize these types of mistakes.

  4. beeman commented on May 4, 2017

    @beeman
    Collaborator

    I just created and released the package dockerpkg to npmjs.

    It's now as simple as running npm install --save-dev dockerpkg and add "prebuild": "dockerpkg" to the scripts object in package.json, as demonstrated in the update example.

  5. pascalandy commented on May 4, 2017

    @pascalandy
    Author

    @marcosnils Thanks for jumping in. I want to create a docker image like you did in your post without installing pkg locally.

    About:

    In the example I've provided you only need to have docker to create your new docker images, for what I understand seems like you want to run pkg

    Are you saying I don't need to have pkg installed locally ?

  6. marcosnils commented on May 4, 2017

    @marcosnils
  7. pascalandy commented on May 4, 2017

    @pascalandy
    Author

    Got it. I guess something brake when I tested your example as I used Alpine + 17.04 CE
    It's all clear now :)

  8. beeman commented on May 4, 2017

    @beeman
    Collaborator

    @marcosnils nice post, those multi-step Dockerfiles look very interesting. I will probably move the project to that once it's live.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions