Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions integration-tests/test-repo/recipes/stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ stages:
- from-file: stages.yml
- name: fedora-test
from: fedora
platform: linux/amd64
modules:
- from-file: stages.yml
- name: alpine-test
Expand Down
8 changes: 7 additions & 1 deletion recipe/src/stage.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::PathBuf;

use blue_build_utils::syntax_highlighting::highlight_ser;
use blue_build_utils::{platform::Platform, syntax_highlighting::highlight_ser};
use bon::Builder;
use colored::Colorize;
use miette::{Result, bail};
Expand All @@ -23,6 +23,12 @@ pub struct StageRequiredFields {
/// This is set directly in a `FROM` instruction.
pub from: String,

/// Run a stage on a specific platform.
///
/// This sets the `--platform` arg on the
/// `FROM` instruction.
pub platform: Option<Platform>,

/// The shell to use in the stage.
#[builder(into)]
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
6 changes: 5 additions & 1 deletion template/templates/stages.j2
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ COPY cosign.pub /keys/{{ recipe.name|replace('/', "_") }}.pub
{%- for stage in stages_ext.stages %}
{%- if let Some(stage) = stage.required_fields %}
# {{ stage.name|capitalize }} stage
FROM {{ stage.from }} AS {{ stage.name }}
FROM \
{%- if let Some(platform) = stage.platform %}
--platform="{{ platform }}" \
{%- endif %}
{{ stage.from }} AS {{ stage.name }}

ARG TARGETARCH
{%- if self::should_color() %}
Expand Down
Loading