Reputation: 2870
I need to define a service in my GitHub action and override its entrypoint by adding arguments to it. How can I do this?
Here's a docker-compose that works that I'm trying to translate.
version: '2'
services:
config:
build: .
links:
- etcd
etcd:
image: microbox/etcd:2.1.1
entrypoint: "etcd --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379"
hostname: etcd
container_name: build_etcd
expose:
- 2379
Here's my Action and how I initially thought it'd work...
name: Node CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
services:
etcd:
image: microbox/etcd:2.1.1
options: --entrypoint 'etcd --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379'
steps:
...
However, this blows up when initializing containers because the command it runs isn't right...
/usr/bin/docker create --name 1062a703242743a29bbcfda9fc19c823_microboxetcd211_3767cc --label 488dfb --network github_network_244f1c7676b8488e99c66694d06a21f2 --network-alias etcd --entrypoint 'etcd --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379' -e GITHUB_ACTIONS=true microbox/etcd:2.1.1
The error is unknown flag: --listen-client-urls
I think it should actually be like this...
/usr/bin/docker create --name 1062a703242743a29bbcfda9fc19c823_microboxetcd211_3767cc --label 488dfb --network github_network_244f1c7676b8488e99c66694d06a21f2 --network-alias etcd --entrypoint etcd -e GITHUB_ACTIONS=true microbox/etcd:2.1.1 --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379
Any ideas how within a GitHub Action Service definition I can override the entrypoint with arguments being passed to the executable?
Upvotes: 10
Views: 5888
Reputation: 2870
From what I can tell, it's not possible.
The simplest thing to do is to run the docker create command with the entrypoint override and it's args as a build step. Something like this:
name: Node CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
...
- run: docker create --name build_etcd --network-alias etcd --entrypoint etcd microbox/etcd:2.1.1 --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:237
...
However, what I wound up doing is to just build and run the docker-compose.yml that I already knew worked as a step in the workflow. Here's the docker-compose.
version: '3'
services:
config:
build: .
links:
- etcd
etcd:
image: microbox/etcd:2.1.1
entrypoint: "etcd --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379"
hostname: etcd
container_name: build_etcd
expose:
- 2379
And here are the related steps:
steps:
- uses: actions/checkout@v2
- name: Build
run: docker-compose build --pull --force-rm config
- name: Test
run: docker-compose run --rm config test
...
Upvotes: 5