Skip to content

Build rust-base Docker Image 🦀🐳 #49

Build rust-base Docker Image 🦀🐳

Build rust-base Docker Image 🦀🐳 #49

name: Build rust-base Docker Image 🦀🐳
on:
workflow_dispatch:
inputs:
debug_image:
description: "Are you bulding a debug image for experimenting?"
type: boolean
default: false
env:
FORCE_COLOR: 1
REGISTRY: ghcr.io
IMAGE_NAME: "${{ github.repository }}/rust-base"
jobs:
build:
name: Build Docker Image
permissions:
contents: read
packages: write
runs-on: namespace-profile-rust-builder
steps:
- name: Checkout 🛒
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Get toolchain version 🛠🦀️
id: toolchain
run: |
RUST_TOOLCHAIN=$(grep 'channel' rust-toolchain.toml | sed -n -e 's/^.*channel = "\(.*\)".*$/\1/p')
echo "Found Rust Toolchain: $RUST_TOOLCHAIN"
echo "rust_toolchain=$RUST_TOOLCHAIN" >> $GITHUB_OUTPUT
- name: Set Image Tags 🏷
id: image_tags
run: |
if [ "${{ github.event.inputs.debug_image }}" = "true" ]; then
echo "image_tag=${{ steps.toolchain.outputs.rust_toolchain }}-${{ github.run_number }}" >> $GITHUB_OUTPUT
else
echo "image_tag=${{ steps.toolchain.outputs.rust_toolchain }}" >> $GITHUB_OUTPUT
fi
- name: Debug | Check Docker Image Tag 🧐🐳
run: echo "Docker Image Tag output ${{ steps.image_tags.outputs.image_tag }}"
- name: Install and configure Namespace CLI 📟
uses: namespacelabs/nscloud-setup@v0
- name: Set up Namespace Buildx 👷
uses: namespacelabs/nscloud-setup-buildx-action@v0
- name: Docker meta 🔖
id: meta
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: ${{ steps.image_tags.outputs.image_tag }}
- name: Login to Github Container Registry 🔑
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push 🏗️🫸
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
no-cache: true
file: ci/docker/development/rust-base.Dockerfile
- name: Summary 📋
run: |
echo "The following images were built and pushed: \`${{ steps.image_tags.outputs.image_tag }}\`" >> $GITHUB_STEP_SUMMARY