Pipelines: How do I get both the latest node and Python running in my docker image?

Hi there

I need a docker image with the latest Python (3.5.x) because I am using some of the more recent Python methods, and nodejs/npm because I am building my app using Webpack 2.

I have the choice, it seems, of using the Python docker and install npm; or the node Docker and install Python. Both of these have turned out to be a little difficult — at the moment I am running a Python image and am trying to install nodejs/npm.

I am having real problems installing nodejs/npm. My bitbucket-pipelines.yml looks like this:

image: python:3.5.1
pipelines:
    branches:
        master:
            - step:
                script:
                    - apt-get update
                    - apt-get install lsb-release -y
                    # need to install lsb-release here
                    - curl --silent https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
                    - VERSION=node_5.x
                    - DISTRO="$(lsb_release -s -c)"
                    - echo "deb https://deb.nodesource.com/$VERSION $DISTRO main" | tee /etc/apt/sources.list.d/nodesource.list
                    - echo "deb-src https://deb.nodesource.com/$VERSION $DISTRO main" | tee -a /etc/apt/sources.list.d/nodesource.list
                    - apt-get update
                    - apt-get install nodejs -y
                    - npm install
                    - npm run build
                    - python get-pip.py
                    - pip install boto3==1.3.0
                    - python s3_upload.py io-master.fromthiscomesthat.co.uk dist io-master

The problem is, I don't really know enough about the environment to download and install the lsb_release executable/binary that is needed to set the DISTRO variable.

Am I approaching this in the wrong way? What can I do to get the release into the DISTO variable?

Please help!

Mark

 

5 answers

1 vote

You can try to debug this locally by following this guide: https://confluence.atlassian.com/display/BITBUCKET/Debug+your+pipelines+locally+with+Docker

To address your nodejs vs python question. You can create a Docker image that has both: https://confluence.atlassian.com/display/BITBUCKET/Use+Docker+images+as+build+environments+in+Bitbucket+Pipelines#UseDockerimagesasbuildenvironmentsinBitbucketPipelines-Createnewenvironments Or you can find an existing on to use on Dockerhub.

Gotta dash off now, so I can't give this a proper look. Hopefully, this will help you make some progress. smile

I know this is so late reply. However, I had the same issue and end up with 2 steps pipeline. Perhaps in 2016 at the time of this thread the multiple steps as a feature was not there. but it is an interesting feature that separate the pipelines into multiple steps . For this scenario one step for installing and run testing (node image) and the other step is for deployment (python image).

We shipped multiple steps in 2017, so your approach is correct. And in my opinion, cleaner.

Thank you for your response @Philip Hodder. I have decided to go down the route of creating my own image. Perhaps I should create it in my own image and see how it feels to be a God.

Ahem.

As it goes, I have already run into an obstacle. Does this make any sense?

It seems someone has already marked my question down. Grr.

You might try using an existing image on Docker Hub that already has both. Maybe https://hub.docker.com/r/nsdont/python-node/ or https://hub.docker.com/r/zbyte64/docker-python-node/~/dockerfile/ ?

I've sorted it now, thanks. Using a virtual machine inside Docker to run Python in an isolated environment.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

457 views 5 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you