CICD-Question
This is more of a usage question. It just works fine from my local. How do we integrate this in a CI-CD process, taking it through different environment lifecycles? is there anything similar to serverless package?
Do you mean for deploying to different environments? I just have multiple serverless.yml files for each env and the CI sets the serverless.yml for the build depending on the CI job configuration.
yes, that's what I meant. How do you take down the stack? This is not an issue running from local, because you do serverless and serverless remove from the same directory. But when you are running these commands on AWS on an ephemeral compute (say from CodeBuild), you lose all those temp directories (.serverless, .serverless_nextjs etc.,), which is what serverless reads to discover what was part of the deployment, right? or maybe I'm missing something simple.
Oh, you have to store the .serverless folder and restore between runs. Otherwise you'll end up with a new environment every time :)
Isn't there a better solution than that? Deployments should be idempotent, so they can be run from every where (local machines, CI machines, in Docker..) and not having to rely on a state, especially when this state (.serverless and .serverless_next) changes on every deployment.
I recommend to check this out: https://github.com/bhall2001/serverless-nextjs-github-ci-cd
@jwdotpark thanks!
I considered that approach but it does not sync between non Github actions deployments, e.g, if I deploy locally.
In that case, what's the benefit of synching with a bucket over actions/cache?
E.g:
- name: Cache Serverless artifacts
uses: actions/cache@v2
with:
path: |
.serverless
.serverless_next
key: serverless-next-dotfiles-staging
BTW, don't I need to sync also .serverless_next folder?
@elad-maimon Hmm I'm not sure about the artifact you mentioned, from my understanding it's a manifesto of previous deployment and it's needed if you want your deployment has a consistent place in cloudfront/lambda and what not.
According to readme here on Finalizing Production CI/CD, it seems a similar step of what you are doing. Hope that helps.
BTW I also had inconsistency problem with local/GA deployment, got it resolved after syncing artifacts. It's well instructed in readme :)