Git Product home page Git Product logo

Comments (18)

eos87 avatar eos87 commented on May 27, 2024 53

You can use GitHub Actions Services within your jobs, like this

services:
  mongodb:
    image: mongo:3.4.23
    ports:
      - 27017:27017

Basically, you can add any service in a container using any docker image (I think). More info here https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idservices

from example-services.

wbari avatar wbari commented on May 27, 2024 3

I am just running mongo as docker which is enough for me to test my stuff with minimal steps to install/run dependency.

  run:  sudo docker run --name mongo -d -p 27017:27017 mongo

from example-services.

ktutnik avatar ktutnik commented on May 27, 2024 2

You can use GitHub Actions Services within your jobs, like this

services:
  mongodb:
    image: mongo:3.4.23
    ports:
      - 27017:27017

Basically, you can add any service in a container using any docker image (I think). More info here https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idservices

Any chance to make it work on Windows?

from example-services.

chrispat avatar chrispat commented on May 27, 2024 2

I just merged #21 from @kaytwo.

from example-services.

cjwiseman11 avatar cjwiseman11 commented on May 27, 2024 1

Not sure if this is best practice... but would something like this be useful to you?

name: Server and Database Start and Test

on: [push]

jobs:
  build:

    runs-on: ubuntu-16.04

    strategy:
      matrix:
        node-version: [8.x]

    steps:
    - uses: actions/checkout@v1
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: Install dependencies
      run: npm install
    - name: Install MongoDB
      run: |
        wget -qO - https://www.mongodb.org/static/pgp/server-3.6.asc | sudo apt-key add -
        echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
        sudo apt-get update
        sudo apt-get install -y mongodb-org
        sudo apt-get install -y mongodb-org=3.6.14 mongodb-org-server=3.6.14 mongodb-org-shell=3.6.14 mongodb-org-mongos=3.6.14 mongodb-org-tools=3.6.14
    - name: Start MongoDB
      run: sudo systemctl start mongod
    - name: Start Server
      run: node server/index.js

from example-services.

wbari avatar wbari commented on May 27, 2024 1

@cjwiseman11 Thanks for message, Yea that we are using as of now and install mongo as 0 step. But I guess as this is so common use, rather than writing whole isntallation steps better to just make an action call. We actually wrote these steps in a install.sh script and call to keep it clean.

from example-services.

wusatosi avatar wusatosi commented on May 27, 2024 1

Not sure if this is best practice... but would something like this be useful to you?

name: Server and Database Start and Test

on: [push]

jobs:
  build:

    runs-on: ubuntu-16.04

    strategy:
      matrix:
        node-version: [8.x]

    steps:
    - uses: actions/checkout@v1
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: Install dependencies
      run: npm install
    - name: Install MongoDB
      run: |
        wget -qO - https://www.mongodb.org/static/pgp/server-3.6.asc | sudo apt-key add -
        echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
        sudo apt-get update
        sudo apt-get install -y mongodb-org
        sudo apt-get install -y mongodb-org=3.6.14 mongodb-org-server=3.6.14 mongodb-org-shell=3.6.14 mongodb-org-mongos=3.6.14 mongodb-org-tools=3.6.14
    - name: Start MongoDB
      run: sudo systemctl start mongod
    - name: Start Server
      run: node server/index.js

Yeah, this is probably the "straight" way to do it, however, having to do this each time is kind of time consuming. I would like to look for base images that contains mongodb, like what circle-ci provides, .

from example-services.

kaytwo avatar kaytwo commented on May 27, 2024 1

I haven't had this issue, but you could try using the healthcheck-enabled mongo:latest image available at https://hub.docker.com/r/healthcheck/mongo, which should only require changing the image line from

        image: mongo

to

        image: healthcheck/mongo

from example-services.

wbari avatar wbari commented on May 27, 2024

Any plans for this request ?

from example-services.

wusatosi avatar wusatosi commented on May 27, 2024

I am just running mongo as docker which is enough for me to test my stuff with minimal steps to install/run dependency.

  run:  sudo docker run --name mongo -d -p 27017:27017 mongo

I'm using such setup as well

from example-services.

wbari avatar wbari commented on May 27, 2024

I just created an Action based on docker and published, my first attempt, Basically starts mongodb specific version as detach docker container. Nothing fancy just a utility

https://github.com/marketplace/actions/start-mongodb-as-docker

from example-services.

gblock0 avatar gblock0 commented on May 27, 2024

I was able to get windows-latest to start downloading the mongo docker container, but failed because of not enough disk space:

    - name: start mongod
      run: |
        echo "docker run --name mongo -d -p 27017:27017 mongo:4.2.3-windowsservercore-ltsc2016"
        docker run --name mongo -d -p 27017:27017 mongo:4.2.3-windowsservercore-ltsc2016
        shell: cmd

docker: failed to register layer: re-exec error: exit status 1: output: BackupWrite \?\C:\ProgramData\docker\windowsfilter\8790a08ac436398f78c865675ab58d908148e39f0124695cfba3fdbb813a6d86\Files\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Data.Services\v4.0_4.0.0.0__b77a5c561934e089\System.Data.Services.dll: There is not enough space on the disk.

It seems there is ~8GB of space available on the runner and the mongo docker container only takes up ~400MB of space...

from example-services.

wbari avatar wbari commented on May 27, 2024

@ktutnik Thanks, Yes we figure it out and using services now. Its cool allows to express multiple versions as well. vhttps://github.com/opencb/cellbase/blob/next/.github/workflows/main.yml#L37

from example-services.

robertsLando avatar robertsLando commented on May 27, 2024

What if I would like to add a command to mongodb using services?

services:
  mongo:
    image: mongo
    command: --serviceExecutor adaptive

I get this error:

Your workflow file was invalid: The pipeline is not valid. .github/workflows/ci.yml (Line: 9, Col: 17): Unexpected value 'command'

from example-services.

wbari avatar wbari commented on May 27, 2024

Try env instead of command because there is no command option like docker compose under services : https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainerenv

from example-services.

robertsLando avatar robertsLando commented on May 27, 2024

from example-services.

kaytwo avatar kaytwo commented on May 27, 2024

I just submitted #21 for anyone interested in a mongo example.

from example-services.

ianwalter avatar ianwalter commented on May 27, 2024

I've been using the basic implementation suggested above (using the mongo Docker image) but it's been flaky. Sometimes my workflow times out on the step that should seed the database. I'm thinking you'd need to add additional health check config like you do for running a Postgres service in Actions. Anyone else have this issue?

from example-services.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.