Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket pipelines docker image with multiple FROM?

Rick Henry March 2, 2022

Hi,

First of all, I'm brand new to Docker! I am currently trying to create my own docker image which I can use in my bitbucket pipelines. What I am trying to do is install node and ruby on the same container. Here is what my current `Dockerfile` looks like:

```

FROM node:12.22.10

FROM ruby:2.7.5

```

I've built, tagged and pushed this image and use it in my `bitbucket-pipelines.yml` and I'm trying to run this step script:

```

script:
    - yarn install

    - gem install bundler -v 2.2.29

```

When this is run in the pipeline I get this error: 

```
bash: yarn: command not found
```

I've tried a couple of things, I removed the `FROM ruby:2.7.5` and the yarn command worked but obviously the `gem install bundler...` did not. So, I know that the Dockerfile and image are working but I don't know how to use both images in my own Dockerfile. Does anyone know what I'm doing wrong? 

1 answer

0 votes
Norbert C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 4, 2022

Hi @Rick Henry 

Thank you for contacting Atlassian Support, I'm Norbert and I'm a Bitbucket Cloud Support Engineer, it's nice to meet with you!

I would like to inform you that in case you use multiple FROM in a Dockerfile, you can create a "multi-stage build", which generates two seperate Docker images. You can read further about this on the following site: https://docs.docker.com/develop/develop-images/multistage-build/

As a workaround, what I would like to suggest you is to use a similar Docker image in your build like this: https://hub.docker.com/r/timbru31/ruby-node

timbru31 has already created a Docker image, which contains both Ruby and Node.

Please let me know if this helps.

Have a great day!

Best Regards,

Norbert
Atlassian Bitbucket Cloud Support

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events