Stacktape

Sign up



CI/CD

Overview

Using Stacktape in your continuous integration/continuous deployment pipeline is very straightforward.

In most cases, you just need to add 2 simple steps to your pipeline to deploy your application in a CI/CD pipeline:

  1. Install Stacktape (curl -L https://installs.stacktape.com/linux.sh | bash or curl -L https://installs.stacktape.com/alpine.sh | bash for alpine linux images).
  2. Deploy using stacktape deploy --stage <<stage>> --region region.

Deploying from Github actions

If you're using Github and want to deploy your Stacktape application from a CI/CD pipeline:

1. (optional) Create github repository

If you don't have a repository, navigate to https://github.com/new.

2. Create github repository secrets

  • The deployment pipeline requires AWS credentials AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
  • Hard-coding them in the pipeline file is not safe, and you should use secrets instead.
  • To create these secrets, navigate to your github project's settings, select Secrets tab, choose Actions->secrets and then create your secrets by clicking on New repository secret. These secrets will be securely stored and accessible to all of your workflows using the ${{ secrets.<<secret-name>> }} syntax.
  • Alternatively, you can use organization-wide secrets.

Creating Github Actions secrets
Creating Github Actions secrets

3. Add github workflow configuration

  • Create your Github action workflow configuration at .github/workflows/<<your-workflow-name>>.yml in your project directory. You can use the following template:

  • The Install project dependencies step is optional and required only if you use Stacktape lambda buildpack or Stacktape image buildpack to package your workloads.

Copy

name: Deploy application using Stacktape
on:
push:
branches:
- main
jobs:
deploy-app:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "16"
- name: Install Stacktape
run: curl -L https://installs.stacktape.com/linux.sh | bash
- name: Install project dependencies
run: npm install
- name: Deploy the stack
run: stacktape deploy --stage <<stage>> --region <<region>>
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

4. Push to the github repository

The pipeline is triggered when you push to the main branch of you github repository.

  1. git init --initial-branch=main
  2. git commit -m "setup stacktape project"
  3. git remote add origin git@github.com:<<namespace-name>>/<<repo-name>>.git (replace with your github repository)
  4. git push -u origin main
  5. To monitor the deployment progress, navigate to your gitlab project and select Actions tab.

Deploying from Gitlab CI

If you're using Gitlab and want to deploy your Stacktape application from a CI/CD pipeline:

1. (optional) Create gitlab repository

If you don't have a repository, navigate to https://gitlab.com/projects/new.

2. Create gitlab repository secrets

  • The deployment pipeline requires AWS credentials AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
  • Hard-coding them in the pipeline file is not safe, and you should use secrets instead.
  • @todo

3. Add gitlab workflow configuration

  • Create your Gitlab action workflow configuration at .gitlab-ci.yml in the root directory of your project. You can use the following template:

  • The install project dependencies step is optional and required only if you use Stacktape lambda buildpack or Stacktape image buildpack to package your workloads.

Copy

variables:
DOCKER_DRIVER: overlay2
stages:
- build
services:
- docker:dind
deploy-app-job:
stage: build
rules:
# only execute job on push to the master/main
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
image: docker:20
script:
# install container dependencies
- apk add --update bash curl nodejs npm
# install project dependencies
- npm install
# install Stacktape
- curl -L https://installs.stacktape.com/alpine.sh | bash
# set PATH so that we can use the "stacktape" and "stp" aliases for the binary
- export PATH=$PATH:/root/.stacktape/bin
# deploy the stack
- stp deploy --stage <<stage>> --region <<region>>

4. Push to the gitlab repository

The pipeline is triggered when you push to the main branch of you gitlab repository.

  1. git init --initial-branch=main
  2. git commit -m "setup stacktape project"
  3. git remote add origin git@gitlab.com:<<namespace-name>>/<<repo-name>>.git (replace with your gitlab repository)
  4. git push -u origin main
  5. To monitor the deployment progress, navigate to your gitlab project and select CI/CD->jobs.
Need help? Ask a question on SlackDiscord or info@stacktape.com.