serverless-next.js icon indicating copy to clipboard operation
serverless-next.js copied to clipboard

CICD-Question

Open vgthoppae opened this issue 4 years ago • 8 comments

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?

vgthoppae avatar Dec 01 '21 20:12 vgthoppae

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.

tyler-ground avatar Dec 02 '21 01:12 tyler-ground

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.

vgthoppae avatar Dec 02 '21 01:12 vgthoppae

Oh, you have to store the .serverless folder and restore between runs. Otherwise you'll end up with a new environment every time :)

tyler-ground avatar Dec 02 '21 02:12 tyler-ground

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.

elad-maimon avatar Apr 28 '22 11:04 elad-maimon

I recommend to check this out: https://github.com/bhall2001/serverless-nextjs-github-ci-cd

jwdotpark avatar Apr 28 '22 23:04 jwdotpark

@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

elad-maimon avatar May 02 '22 06:05 elad-maimon

BTW, don't I need to sync also .serverless_next folder?

elad-maimon avatar May 02 '22 06:05 elad-maimon

@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 :)

jwdotpark avatar May 02 '22 10:05 jwdotpark