spinframework / spinframework/spin

Opinion: Specify workdir on component instead of component build

Open
#963 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area/app-def-and-config enhancement open for comment
Dominant language
Rust
Stars
6.5k
Forks
310
Avg merge
1d 20h
Merged PRs (30d)
24

Description

Hey,

with #406 support for specifying the workdir for component build ([component.build]) was introduced. I wonder if it would make more sense to move the workdir property to [[component]]...

Moving workdir to the component level would allow Spin to re-use it when specifying component source

With the current implementation I end up with having the value of workdir twice (when sticking to default cargo build instructions)

[[component]]
id = "create-order"
source = "create_order/target/wasm32-wasi/release/create_order.wasm"
[component.trigger]
route = "/..."
[component.build]
workdir = "create_order"
command = "cargo build --target wasm32-wasi --release"

Actually, I'm not sure if component.source should automatically pick up the workdir or not, but it cloud lead to something like this:

[[component]]
id = "create-order"
workdir = "create_order"
source = "target/wasm32-wasi/release/create_order.wasm"
[component.trigger]
route = "/..."
[component.build]
command = "cargo build --target wasm32-wasi --release"

So internally, component source could be computed by combining workdir and source resulting again in
create_order/target/wasm32-wasi/release/create_order.wasm

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review Spin's current component configuration and build/source handling before proposing a change. The issue asks whether workdir should move from component.build to component and whether it should affect source resolution; done requires a maintainer decision on that behavior and an agreed implementation scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.