Skip to content

build-docker-image-manual #1

build-docker-image-manual

build-docker-image-manual #1

# This manually-triggered workflow builds OpenFAST docker images for the linux/amd64 and linux/aarch64 architectures for
# the specified git ref (this can be a branch, tag, or commit hash). The image is tagged with the given tag and pushed
# to the `nrel/openfast` repository. The build cache is stored in GitHub actions.
name: build-docker-image-manual
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag for Docker image (excluding the "v" prefix e.g. 3.5.3)'
required: true
ref:
description: 'Branch, tag, or commit SHA to build from'
required: true
default: main
jobs:
build-and-push:
runs-on: ubuntu-latest
timeout-minutes: 300
env:
DOCKERFILE_PATH: share/docker/Dockerfile
DOCKERFILE_PERMALINK: https://raw.githubusercontent.com/OpenFAST/openfast/main/share/docker/Dockerfile
DOCKERHUB_REPOSITORY: nrel/openfast
GH_REGISTRY: ghcr.io/OpenFAST/openfast
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Commenting out until we get the NREL DockerHub credentials
# - name: Log in to DockerHub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GH_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# The updated Dockerfile is only available in the repository at the tag v3.5.3 and above. To build versions of
# OpenFAST that are below this version, the updated Dockerfile from that tag of the repository has to be acquired
# before building. For versions >= v3.5.3, the Dockerfile is already there so this step does nothing.
- name: Get Dockerfile for versions < 3.5.3
run: |
if [ ! -f ${{ env.DOCKERFILE_PATH }} ]; \
then wget -O ${{ env.DOCKERFILE_PATH }} ${{ env.DOCKERFILE_PERMALINK }}; \
fi
- name: Build and push to registry
uses: docker/build-push-action@v5
with:
context: .
file: ${{ env.DOCKERFILE_PATH }}
platforms: linux/amd64,linux/aarch64
tags: |
${{ env.GH_REGISTRY }}:${{ github.event.inputs.tag }}
# ${{ env.DOCKERHUB_REPOSITORY }}:${{ github.event.inputs.tag }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max