Skip to content

Build Docker (manually) #67

Build Docker (manually)

Build Docker (manually) #67

Workflow file for this run

name: Build Docker (manually)
# Controls when the action will run.
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
imageTag:
description: 'The tag to be used for the images'
required: true
default: 'latest'
env:
IMAGE_NAME_BASE: seerep_base
IMAGE_NAME_SERVER: seerep_server
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build-docker:
runs-on: ubuntu-20.04
permissions:
packages: write
steps:
-
name: Generate tags base
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME_BASE
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# save to env for later steps
echo "image_id_base=$IMAGE_ID" >> $GITHUB_ENV
-
name: Generate tags server
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME_SERVER
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# save to env for later steps
echo "image_id_server=$IMAGE_ID" >> $GITHUB_ENV
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push base image
uses: docker/build-push-action@v5
with:
push: true
file: Dockerfile
context: "{{defaultContext}}:docker/base"
tags: ${{ env.image_id_base }}:${{ github.event.inputs.imageTag }}
cache-from: type=registry,ref=${{ env.image_id_base }}:${{ github.event.inputs.imageTag }}
cache-to: type=inline
-
name: Build and push server image
uses: docker/build-push-action@v5
with:
push: true
file: docker/server/Dockerfile
tags: ${{ env.image_id_server }}:${{ github.event.inputs.imageTag }}
cache-from: type=registry,ref=${{ env.image_id_server }}:${{ github.event.inputs.imageTag }}
cache-to: type=inline
build-args: |
IMAGEBASE=${{ env.image_id_base }}
IMAGEBASETAG=${{ github.event.inputs.imageTag }}