[英]how to build docker-image and use it with k8s in github actions?
我有 2 個軟件包的 monorepo:
為了確保 k8s 將與本地 docker 守護進程對話並從那里獲取圖像,在我的本地機器上,我運行:
在 github-actions 中,我嘗試運行相同的命令,但第一步不起作用:( https://github.com/stavalfi/k8test/pull/6/checks?check_run_id=785330120 )
Run eval $(minikube docker-env --shell sh)
/home/runner/work/_temp/932fe76c-855f-4ed6-9fa3-dcd5cea6df7e.sh: line 1: README.md: command not found
##[error]Process completed with exit code 127.
我不知道這個錯誤是什么意思以及為什么“README.md”出現在錯誤中。
有什么辦法讓它工作嗎? 甚至另一種方法來確保在 github-actions 中,k8s 會找到我構建的 docker-image?
一段時間后,我為這個問題創建了一個可行的解決方案。 我不確定為什么會出現該錯誤,但這是一個可行的解決方案:
github 動作配置文件:
name: Node.js CI
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- uses: secrethub/actions/env-export@v0.1.0
env:
SECRETHUB_CREDENTIAL: ${{ secrets.SECRETHUB_CREDENTIAL }}
DOCKER_USERNAME: secrethub://stavalfi/dockerhub/username
DOCKER_PASSWORD: secrethub://stavalfi/dockerhub/access-token
- name: install k8s
uses: engineerd/setup-kind@v0.4.0
- run: minikube start
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn install
- run: yarn build
- run: eval $(minikube docker-env --shell sh) && yarn workspace simple-service build:docker # build the docker image and let k8s use it locally
- run: eval $(minikube docker-env --shell sh) && yarn workspace k8test-monitoring build:docker # build the docker image and let k8s use it locally
- run: DEBUG=k8test:* yarn test # create k8s deployments from the docker-images from the last 2 steps
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.