Create README.md #332
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Docker Images | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
service: [worker-cli, server, worker] | |
include: | |
- service: worker-cli | |
dockerfile: docker/docker/worker-cli/Dockerfile | |
context: docker/docker/worker-cli | |
component: worker-cli | |
- service: server | |
dockerfile: docker/docker/server/Dockerfile | |
context: docker/server/backend | |
component: server | |
- service: worker | |
dockerfile: docker/docker/worker/Dockerfile | |
context: docker/docker/worker | |
component: worker | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: "latest" | |
- name: Create Docker Buildx builder | |
run: | | |
docker buildx create --use --name cloud-sunsolution-builder --driver docker-container | |
- name: Build and push Docker image | |
run: | | |
IMAGE_NAME=sunsolution/betterscan${{ matrix.component }} | |
TAG=${{ github.sha }} | |
docker buildx build \ | |
--builder cloud-sunsolution-builder \ | |
--file ${{ matrix.dockerfile }} \ | |
--target build \ | |
--cache-to=type=inline \ | |
--cache-from=type=local,src=/tmp/.buildx-cache \ | |
--tag $IMAGE_NAME:latest \ | |
--tag $IMAGE_NAME:$TAG \ | |
--push \ | |
${{ matrix.context }} |