Local Deployment

You can skip the automated CI/CD anytime and update your application locally by following the instructions provided below.

Contents

  1. Server and Job Applications
    1. Pre-requisites
    2. Steps
  2. Static Applications
    1. Pre-requisites
    2. Steps

Server and Job Applications

How you tag is important. Your image tag must begin with the environment name. For example, if you are pushing a new image to the dev environment, your image tag must begin with dev.

DragonOps uses ArgoCD image updater to listen for new images being pushed to your ECR Repository (also created by DragonOps). This means anytime you push an image to your ECR repo with a tag prefixed with dev, your image will be deployed to your dev environment. The same is true for all environment names – if you push an image with a tag prefixed with stage, your image will be deployed to your stage environment, etc.

Using this information you can integrate your own CI/CD pipeline with DragonOps! If you are not yet using CI/CD for your application, you can manually update your application code from your local machine as well. Below, we’ve included an example of what this might look like.

Pre-requisites

  1. You must have the AWS CLI installed and configured with the correct credentials.
  2. You must have a Dockerfile for your application.
  3. Docker must be installed and running.

Steps

Let’s say you have an application, my-app, and are ready to build and push a new image. First, you’ll need to login to your ECR repository. Then you will build, tag, and push your image. From there, your new application code will be re-deployed to each environment you tag it with.

  1. aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <AWS_ACCOUNT_ID>.dkr.ecr.<AWS_REGION>.amazonaws.com
  2. docker build -t my-app .
  3. docker tag my-app:latest <AWS_ACCOUNT_ID>.dkr.ecr.<AWS_REGION>.amazonaws.com/my-app:dev-1.0.0
  4. docker push <AWS_ACCOUNT_ID>.dkr.ecr.<AWS_REGION>.amazonaws.com/my-app:dev-1.0.0

Note: If this example we use the version 1.0.0 for the image tag version. You can use any versioning scheme you like, as long as it is prefixed with the environment you want to deploy to.

Repeat steps 3 and 4 for any other environment you want to deploy to. For example, if you want to deploy to the stage environment, you would tag your image with stage-1.0.0 and push it to your ECR repository with the same tag.

Static Applications

You will need your Cloudfront distribution ID to perform the following steps. You can find this with the dragonops endpoint list command.

DragonOps hosts your static sites in an S3 Bucket with a Cloudfront distribution in front of it.

Using this information you can integrate your own CI/CD pipeline with DragonOps! If you are not yet using CI/CD for your application, you can manually update your application code from your local machine as well. Below, we’ve included an example of what this might look like.

Pre-requisites

  1. You must have the AWS CLI installed and configured with the correct credentials.
  2. You must have your Cloudfront Distribution ID (see note above).
  3. Be able to build/compile your static files.

Steps

Let’s say you have an application, my-app, and are ready push an update. Updating your application code takes three steps: compiling your static files, syncing them to your S3 bucket, and invalidating your Cloudfront distribution.

  1. First, you need to build your application (or compile your static files). This looks different depending on the tool you use.
    • For Hugo, you use the hugo command, and your files are output in the ./public directory.
    • For Jekyll, you use the jekyll build command, and your files are output in the ./_site directory.
    • Refer to the documentation for your specific tool.
  2. Sync your files to your S3 bucket by running the command below:
    • aws s3 sync ./public s3://<AWS_ACCOUNT_ID>-my-app-<GROUP>-<ENVIRONMENT> --delete
    • Replace <AWS_ACCOUNT_ID>, <GROUP>, and <ENVIRONMENT> with the appropriate values, ie s3://111111111111-my-app-preprod-dev
  3. Invalidate your cloudfront distribution with the command below:
    • aws cloudfront create-invalidation --distribution-id <CLOUDFRONT_DISTRO_ID> --paths "*"

Repeat steps 2 and 3 for any other environment you want to deploy to. For example, if you want to deploy to the stage environment in the preprod group, you would sync to the bucket s3://<AWS_ACCOUNT_ID>-my-app-preprod-stage. Make sure you also update your Cloudfront distribution id in the next command as well (you can use dragonops endpoint list to find the correct distribution id).