Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why isn't --platform passed in to docker build in start / dev mode? #21

Open
zya opened this issue Dec 10, 2024 · 3 comments
Open

Why isn't --platform passed in to docker build in start / dev mode? #21

zya opened this issue Dec 10, 2024 · 3 comments

Comments

@zya
Copy link

zya commented Dec 10, 2024

Had an issue with docker layers in my SST container build, dug around and saw that in start mode, the --platform value is not passed in whereas in deploy mode, it is.

Why is that case? And can --platform be added to start mode as well.

if (input.mode === "start") {
try {
const result = await execAsync(
[
`docker build`,
`-t sst-dev:${input.functionID}`,
...(input.props.container?.file
? [`-f ${input.props.container.file}`]
: []),
...Object.entries(input.props.container?.buildArgs || {}).map(
([k, v]) => `--build-arg ${k}=${v}`
),
...(input.props.container?.buildSsh
? [`--ssh ${input.props.container.buildSsh}`]
: []),
...(input.props.container?.cacheFrom || []).map(
(v) =>
"--cache-from=" +
[
`type=${v.type}`,
...(v.params
? Object.entries(v.params).map(
([pk, pv]) => `${pk}=${pv}`
)
: []),
].join(",")
),
...(input.props.container?.cacheTo
? [
"--cache-to=" +
[
`type=${input.props.container?.cacheTo.type}`,
...(input.props.container?.cacheTo?.params
? Object.entries(
input.props.container?.cacheTo?.params
).map(([pk, pv]) => `${pk}=${pv}`)
: []
)
].join(","),,
]
: []),
`.`,
].join(" "),
{
cwd: project,
env: {
...process.env,
},
}
);
} catch (ex) {
return {
type: "error",
errors: [String(ex)],
};
}
}
if (input.mode === "deploy") {
try {
const platform =
input.props.architecture === "arm_64"
? "linux/arm64"
: "linux/amd64";
await execAsync(
[
`docker build`,
`-t sst-build:${input.functionID}`,
...(input.props.container?.file
? [`-f ${input.props.container.file}`]
: []),
...Object.entries(input.props.container?.buildArgs || {}).map(
([k, v]) => `--build-arg ${k}=${v}`
),
...(input.props.container?.buildSsh
? [`--ssh ${input.props.container.buildSsh}`]
: []),
...(input.props.container?.cacheFrom || []).map(
(v) =>
"--cache-from=" +
[
`type=${v.type}`,
...(v.params
? Object.entries(v.params).map(
([pk, pv]) => `${pk}=${pv}`
)
: []),
].join(",")
),
...(input.props.container?.cacheTo
? [
"--cache-to=" +
[
`type=${input.props.container?.cacheTo.type}`,
...(input.props.container?.cacheTo?.params
? Object.entries(
input.props.container?.cacheTo?.params
).map(([pk, pv]) => `${pk}=${pv}`)
: []
)
].join(","),,
]
: []),
`--platform ${platform}`,
`.`,
].join(" "),

@jayair
Copy link
Contributor

jayair commented Dec 14, 2024

Yeah feel free to open a PR

@zya
Copy link
Author

zya commented Dec 16, 2024

@jayair so --platform wasn't intentionally left out in start mode?

@jayair
Copy link
Contributor

jayair commented Dec 21, 2024

I'm not entirely sure. It's likely that it wasn't initially supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants