Skip to content

add docker multistage build #2

add docker multistage build

add docker multistage build #2

Workflow file for this run

name: run Docker CI
on:
push:
branches:
- main
- master
- add-docker-build
pull_request:
branches:
- main
- master
env:
CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm_modules
jobs:
build:
name: CI build docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
#
# configure and build in GitHub CI as smoke test
# speed up configure step by installing boost as system lib, also use Ninja for faster builds
- name: speed up configure and build
shell: bash
run: sudo apt-get update && sudo apt-get install -y libboost-all-dev ninja-build
# use GitHub cache to cache dependencies
- uses: actions/cache@v2
with:
path: "**/cpm_modules"
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
- name: configure
run: cmake -S standalone -B build -G Ninja -D CMAKE_BUILD_TYPE=Release
- name: build
run: cmake --build build
#
# end GitHub CI local build
- name: set up Docker Buildx for multi-platform support
uses: docker/setup-buildx-action@v1
- name: set up QEMU for multi-platform support
uses: docker/setup-qemu-action@v1
# build image but do NOT push to DockerHub
- name: build Docker image
uses: docker/build-push-action@v2
with:
file: ./standalone/Dockerfile
platforms: linux/amd64,linux/arm64
push: false
tags: ${{ secrets.DOCKERHUB_USERNAME }}/greeter-webapi:ci
cache-from: type=gha
cache-to: type=gha,mode=max