Drone

Use content from Docker image in next step

Hi

I’m trying to figure out a way that I can get content (like static files) out of a container after it has been built by plugins/docker.

I effectively would like to build a multi-stage Dockerfile that builds the project and for example docs, and then extract the docs from the container image so it can be pushed to GitHub Pagers.

I suppose this can be done by running a Docker in Docker step after, but I was hope someone knew about a slightly more elegant method.


Kristoffer

I’m trying to figure out a way that I can get content (like static files) out of a container after it has been built by plugins/docker .

The scope of plugins/docker is to build and publish an image using docker-in-docker in a stateless manner. Since you are only building (and not publishing) and you want to maintain state, this plugin would not be appropriate for your use case. Note that you can always create a custom plugin that targets your use case but I’m not sure that is necessary here.

I effectively would like to build a multi-stage Dockerfile that builds the project and for example docs, and then extract the docs from the container image so it can be pushed to GitHub Pagers.

I suppose this can be done by running a Docker in Docker step after, but I was hope someone knew about a slightly more elegant method.

We have examples in our documentation for using docker-in-docker service containers but this feels like it adds a layer of complexity that may not be needed.

I would probably avoid using a Dockerfile and instead do something like this:

kind: pipeline
type: docker
name: default

steps:
- name: build
  image: node
  commands:
  - npm i -g gatsby
  - npm i
  - gatsby build
  - gatsby build --prefix-paths

Hi

The use cases for that I have can think of is:

  • I often want to both build the container, publish it and extract the static files
  • If building projects (and premade Dockerfiles) that are note mine, it would still be nice to extract.

Do you think it would be easier to achieve this since I push the image? or is that irrelevant?

I’m using Jsonnet, so I guess that if I sit down and fiddle my way to get it working with Docker in Docker I can make my “own” reusable component and that that might be the easiest.