dockerpkg-example icon indicating copy to clipboard operation
dockerpkg-example copied to clipboard

Could we use this project within our Dockerfile

Open pascalandy opened this issue 8 years ago • 8 comments

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

pascalandy avatar May 03 '17 22:05 pascalandy

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 :)

beeman avatar May 03 '17 22:05 beeman

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 :)

pascalandy avatar May 03 '17 22:05 pascalandy

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.

marcosnils avatar May 03 '17 23:05 marcosnils

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.

beeman avatar May 04 '17 03:05 beeman

@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 ?

pascalandy avatar May 04 '17 11:05 pascalandy

Yes, you don't need pkg to run my example. Everything stays within docker

sent from mobile

On May 4, 2017 8:24 AM, "Pascal Andy" [email protected] wrote:

@marcosnils https://github.com/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 ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dockerpkg/dockerpkg-example/issues/2#issuecomment-299158709, or mute the thread https://github.com/notifications/unsubscribe-auth/ABgV2hwJ5mDBAIBOhMD3-_2lgVGwLJa6ks5r2bVXgaJpZM4NQCZ0 .

marcosnils avatar May 04 '17 11:05 marcosnils

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

pascalandy avatar May 04 '17 13:05 pascalandy

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

beeman avatar May 04 '17 14:05 beeman