Skip to content

fix: dockerfile

fix: dockerfile #40

Workflow file for this run

name: Docker Build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Prepare
id: prepare
run: |
IMAGE_NAME=hive
GIT_REPO='https://github.com/${{ github.repository }}'
DOCKER_USER=`echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]'`
DOCKER_IMAGE=ghcr.io/$DOCKER_USER/$IMAGE_NAME
VERSION=`git rev-parse --short HEAD`
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
echo "git_repo=${GIT_REPO}" >> $GITHUB_OUTPUT
echo "docker_user=${DOCKER_USER}" >> $GITHUB_OUTPUT
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ steps.prepare.outputs.docker_user }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v3
with:
context: .
push: ${{ (github.ref == 'refs/heads/master') || (contains(github.ref, 'refs/tags/') == true) }}
tags: |
${{ steps.prepare.outputs.docker_image }}:latest
${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
build-args: |
GIT_VERSION=${{ steps.prepare.outputs.version }}
GIT_REPO=${{ steps.prepare.outputs.git_repo }}
cache-from: type=gha
cache-to: type=gha,mode=max