Comments (18)
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.
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.
You can use GitHub Actions Services within your jobs, like this
services: mongodb: image: mongo:3.4.23 ports: - 27017:27017Basically, 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.
I just merged #21 from @kaytwo.
from example-services.
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.
@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.
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.
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.
Any plans for this request ?
from example-services.
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.
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.
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.
@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.
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.
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.
from example-services.
I just submitted #21 for anyone interested in a mongo example.
from example-services.
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)
- container-job/vm-job failed to run with exit code 126 HOT 9
- Postgres service unhealthy HOT 1
- Kindly add an example for using Microsoft SQL Server on Windows VM HOT 2
- Feature Request: Add example for OracleDB-XE HOT 1
- Contributing Example for WebDriver Selenium
- dial tcp 127.0.0.1:5432: connect: connection refused HOT 4
- Provide native seeding capability for actions
- The postgres example does not work out of the box. HOT 4
- Rename default branch
- Please delete this
- Actions and services feedback (health check questions) HOT 12
- Error: Process completed with exit code 6. HOT 2
- Incorrect comment for POSTGRES_HOST line HOT 3
- github actions fail when redis tries to save an RDB snapshot HOT 5
- Confused about the goal of these examples
- Running services from the Github Package Registry
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from example-services.