50 lines
1.6 KiB
YAML
50 lines
1.6 KiB
YAML
name: Build Docker Container
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
dockerfile:
|
|
description: 'The dockerfile to build'
|
|
required: false
|
|
type: string
|
|
default: './Dockerfile'
|
|
context:
|
|
description: 'The build context'
|
|
required: false
|
|
type: string
|
|
default: './'
|
|
tag:
|
|
description: 'The tag to apply to the built image'
|
|
required: true
|
|
type: string
|
|
registry:
|
|
description: 'The registry to push the image to'
|
|
required: true
|
|
type: string
|
|
username:
|
|
description: 'The username to authenticate with the registry'
|
|
required: true
|
|
type: string
|
|
password:
|
|
description: 'The password to authenticate with the registry'
|
|
required: true
|
|
type: string
|
|
|
|
jobs:
|
|
build-go:
|
|
runs-on: docker
|
|
container:
|
|
image: forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/pipeline-container/kaniko:v1.23.2-2
|
|
steps:
|
|
- name: Clone Repository
|
|
uses: https://forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/DevFW-CICD/checkout@main
|
|
|
|
- name: Build Credentials File
|
|
run: |
|
|
mkdir -p /kaniko/.docker
|
|
AUTHSTRING=$(echo -n "${{ inputs.username }}:${{ inputs.password }}" | base64)
|
|
echo "{\"auths\":{\"${{ inputs.registry }}\":{\"auth\":\"${AUTHSTRING}\"}}}" > /kaniko/.docker/config.json
|
|
|
|
- name: Build Docker Container
|
|
run: |
|
|
/kaniko/executor --dockerfile=${{ inputs.dockerfile }} --context=${{ inputs.context }} --destination=${{ inputs.tag }}
|