我需要在GitHub动作中定义服务,并通过向其添加参数来覆盖其入口点。我该怎么办?
这是一个我要翻译的docker-compose。
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
这是我的操作,以及我最初认为它如何工作...
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:
...
但是,这在初始化容器时会炸毁,因为它运行的命令不正确...
/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
错误为unknown flag: --listen-client-urls
我认为实际上应该是这样...
/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
关于在GitHub Action Service定义中如何通过传递给可执行文件的参数覆盖入口点的任何想法?
据我所知,这是不可能的。
最简单的方法是使用入口点覆盖来运行docker create命令,并且将args作为构建步骤。像这样的东西:
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
...
但是,我最后要做的是只是构建并运行我已经知道作为工作流程中一步的docker-compose.yml。这是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
这是相关步骤:
steps:
- uses: actions/checkout@v2
- name: Build
run: docker-compose build --pull --force-rm config
- name: Test
run: docker-compose run --rm config test
...