I’m learning to deploy github actions to run multiple jobs with docker, and this is what I have so far:
github actions yml file is shown as follow. There are 2 jobs:
job0 builds docker with
job1 builds docker with
# .github/workflows/main.yml name: docker CI on: push jobs: job0: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build and Run run: docker build . --file Dockerfile0 --tag job0 job1: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build and Run run: docker build . --file Dockerfile1 --tag job1
Dockerfile1 share basically the same content, except for the argument in the last line:
FROM ubuntu:20.04 ADD . /docker_ci RUN apt-get update -y RUN apt-get install -y ... ... WORKDIR /docker_ci RUN python3 script.py <arg>
I wonder, can I build a docker for the 1st job, and then invoke multiple jobs execute command within the docker built from the 1st job? Thus I don’t have to keep multiple Dockerfile and save some docker building time.
It would be better to build my docker locally from Dockerfile so I hope to avoid using
container from docker hub.
runs-for-docker-actions looks relevant but I have trouble finding example deploying action locally (without publishing).