Sign inSign up

payway/ruby-mongodb

By payway

•Updated over 9 years ago

A Ruby image with MongoDB bundled to use with Bitbucket Pipelines.

Image
2

867

payway/ruby-mongodb repository overview

⁠Ruby and MongoDB for Bitbucket Pipelines

This repository contains a Dockerfile as well as a simple example that shows how you can run your own Docker container with Ruby and MongoDB on Bitbucket Pipelines.

The Docker image is using Ruby and MongoDB (ruby/version_mongodb/version)

  •   [`1.9.3_3.4.1`, `latest` (*1.9.3_3.4.1/Dockerfile*)](https://bitbucket.org/adeprimo/docker-ruby-mongodb/src/?at=1.9.3_3.4.1)
    
  •   [`1.9.3_3.2.11` (*1.9.3_3.2.11/Dockerfile*)](https://bitbucket.org/adeprimo/docker-ruby-mongodb/src/?at=1.9.3_3.2.11)
    
  •   [`1.9.3_3.0.13` (*1.9.3_3.0.13/Dockerfile*)](https://bitbucket.org/adeprimo/docker-ruby-mongodb/src/?at=1.9.3_3.0.13)
    
  •   [`1.9.3_2.6.11` (*1.9.3_2.6.11/Dockerfile*)](https://bitbucket.org/adeprimo/docker-ruby-mongodb/src/?at=1.9.3_2.6.11)
    

⁠Quickstart

⁠Using the image with Bitbucket Pipelines

Just copy/paste the YML below in your bitbucket-pipelines.yml and adapt the script to your needs.

# This is a sample build configuration for Ruby.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Dockerhub as your build environment.
image: payway/ruby-mongodb

pipelines:
  default:
    - step:
        script: # Modify the commands below to build your repository.
          - gem install mongo
          - service mongod start
          - ruby test.rb

⁠Create your own image

If you want to use a different version of Ruby you can simply create your own image for it. Just copy the content of the Dockerfile and replace the first line.

This image is built from the official Ruby image at https://hub.docker.com/_/ruby/⁠ and you can find there all the different versions that are supported.

Your Dockerfile won't need to have an ENTRYPOINT or CMD line as Bitbucket Pipelines will run the script commands that you put in your bitbucket-pipelines.yml file instead.

FROM ruby:1.9.3

ENV LANG C.UTF-8
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mongodb && useradd -r -g mongodb mongodb

ENV MONGO_MAJOR 3.4
ENV MONGO_VERSION 3.4.1
ENV MONGO_PACKAGE mongodb-org

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv 0C49F3730359A14518585931BC711F9BA15703C6 \
    && echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/$MONGO_MAJOR main" > /etc/apt/sources.list.d/mongodb-org.list \
    && apt-get update \
    && apt-get install -y \
        ${MONGO_PACKAGE}=$MONGO_VERSION \
        ${MONGO_PACKAGE}-server=$MONGO_VERSION \
        ${MONGO_PACKAGE}-shell=$MONGO_VERSION \
        ${MONGO_PACKAGE}-mongos=$MONGO_VERSION \
        ${MONGO_PACKAGE}-tools=$MONGO_VERSION \
    && apt-get clean \
    && service mongod start \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# This Dockerfile doesn't need to have an entrypoint and a command
# as Bitbucket Pipelines will overwrite it with a bash script.
⁠Build the image

docker build -t <your-docker-account>/ruby-mongodb .

⁠Run the image locally with bash to make some tests

docker run -i -t <your-docker-account>/ruby-mongodb /bin/bash

⁠Push the image back to the Docker Hub

docker push <your-docker-account>/ruby-mongodb

Tag summary

Content type

Image

Digest

Size

369.3 MB

Last updated

almost 10 years ago

docker pull payway/ruby-mongodb