https://serverless-stack.com/ logo
#help
Title
# help
a

Aleksandr Matrosov

05/28/2022, 11:16 AM
Hi! Is it possible to build and deploy only one certain stack?
npx sst diff dev-sst-Stack --stage dev
does deploy only
dev-sst-Stack
but it builds all 100 others as wel
I trying to deploy stacks in parallel on Gitlab, but what the point if every job builds all stacks))
a

Arpad

05/28/2022, 12:01 PM
I guess cdk does that by default because it needs to know all references, and deploys only what you tell him to deploy. Indeed it can get slow because of lambdas or docker images if you use those 😅
a

Aleksandr Matrosov

05/28/2022, 12:02 PM
yeap, docker is the one i want to run separatly
a

Arpad

05/28/2022, 12:05 PM
I might have a solution (haven't tried it yet). You can reference an image from a tarball with
Copy code
ecs.ContainerImage.fromTarball(file)
where the tarball can be generated after building a Docker image with
Copy code
docker save
https://docs.docker.com/engine/reference/commandline/save/ This way you can build the image separately and cache layers using CI
a

Aleksandr Matrosov

05/28/2022, 12:08 PM
My problem is this guy:
Copy code
new Function(this, "categorization", {
            handler: "lala.lala_handler",
            runtime: "python3.9",
        });
And it build inside container....
a

Arpad

05/28/2022, 12:09 PM
ohh
hmmm
seems like someone else reported this (exactly with python) and there is a cli arg
skip: true
in CDK for this (see this test). However I'm not sure if sst passes this command down
there's also this section in the cdk cli guide
a

Aleksandr Matrosov

05/28/2022, 12:23 PM
skipping is complicated...
f

Frank

05/28/2022, 4:24 PM
@Aleksandr Matrosov we’ve got a couple of things on the roadmap that could fix this: • possible fix 1: only building Functions in the stack to be deployed https://github.com/serverless-stack/serverless-stack/issues/1755 • possible fix 2: run
sst build
once, and
sst deploy
reuse the built artifact, instead of building again https://github.com/serverless-stack/serverless-stack/issues/779
I bumped up the priority for both issues.
For now, here’s a work around. Define ur stack like this:
Copy code
const STACK = process.env.STACK;

(!STACK || STACK === "StackA") && app.stack(StackA);
(!STACK || STACK === "StackB") && app.stack(StackB);
(!STACK || STACK === "StackC") && app.stack(StackC);
And this will only build and deploy a single stack
Copy code
STACK=StackA sst deploy
And this will deploy all stacks
Copy code
sst deploy
Hope that helps 😁
k

Klaus

05/29/2022, 1:46 AM
@Frank regarding Python builds, I know that e.g. serverless-python-requirements provides an option to determine the need for docker based on the underlying OS.
Copy code
pythonRequirements:
    dockerizePip: non-linux
To my mind most CI/CD systems aren't running on Windows platforms. Could we potentially get a feature that simply allows to zip up a .venv library folder in Linux / OSX systems with CDK? This would speed up the process even further to my mind.