looking4ward / CloudShirtOnEKS

eShop on AWS - Docker Application Templates demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

eShop on AWS - Docker App Template demo

In this demo you'll learn how to deploy applications to EKS on AWS using Docker Application Templates and GitHub Actions.

This is what you'll be doing:

  • create a GitHub repository to store your demo code and the credentials to deploy to AWS

  • run a Docker Application Template which generates code and a CI/CD pipelie for the .NET Core demo app eShopOnWeb

  • push your local code to GitHub which runs a workflow to create an AWS SQL Server database and an AWS Kubernetes cluster

  • run the app locally in Docker containers to see how it works, and make some simple changes

  • push the changed code to GitHub which runs a workflow to build Docker images, push them to Docker Hub, and deploy the app onto your EKS cluster.

It sounds like a lot, but it's really simple because the template generates documentation for you which guides you through all the steps.

Pre-requisites

You'll need a few things before you start:

  1. A version of Docker Desktop with Application Templates enabled.

The demo is a Linux app, so on Windows you need to use Linux container mode. That's the default so you only need to change it if you've switched to Windows container mode.

  1. A Docker Hub account, so the pipeline can push the Docker images it builds, and the Kubernetes cluster can pull them.

  2. Some tools to work with the source code - Git and Visual Studio Code. If you have Chocolatey set up you can install them with:

choco install -y git
choco install -y visualstudiocode
  1. AWS access key

Make a note of the output, you'll need to add the details to GitHub

  1. A GitHub repo. The pipeline runs using GitHub Actions. Create an empty repo and set the following secrets (under Settings...Secrets):
  • AWS_ACCESS_KEY_ID - the access key ID for AWS
  • AWS_SECRET_ACCESS_KEY - the secret key for AWS
  • RDS_SQL_DATABASE_NAME - the name of the SQL Server database to create
  • RDS_SQL_PASSWORD - the password for the master SQL Server user
  • DOCKER_HUB_USERNAME - Docker Hub username
  • DOCKER_HUB_ACCESS_TOKEN - Docker Hub Personal Access Token

Setup

Update your App Template config in ~/.docker/application-template/preferences.yaml to include the template library at https://raw.githubusercontent.com/sixeyed/eshoponaws/master/eshoponaws.yaml.

This example includes the local demo libraries and the main Docker library:

apiVersion: v1alpha1
disableFeedback: false
kind: Preferences
repositories:
- name: eshoponaws
  url: https://raw.githubusercontent.com/sixeyed/eshoponaws/master/eshoponaws.yaml
- name: library
  url: https://docker-application-template.s3.amazonaws.com/production/v0.1.7/library.yaml

Run the template

Right-click the Docker whale icon in your taskbar and select Design new application... A window launches asking if you want to choose an existing template or design a custom app; select Choose a template.

If you're running Docker Desktop on Windows you'll be asked if you want to run a Linux or Windows app - the template we'll be using is Linux so select Linux.

Now select the eShop on Web template from the gallery:

The Docker app template gallery

From here you'll need to add some details about the deployment, which the template captures as parameters:

Adding deployment parameters to the template

  • GitHub Username and Repository name - use the repo you created earlier with all the secrets stored for AWS and Docker Hub

  • AWS region - region to deploy the EKS cluster & RDS database

  • EKS Cluster name - any name for the cluster to create

The other parameters have default values, and you can leave them as they are or change them to suit your deployment.

The SQL Server password is only used when you run the app locally, the AWS deployment uses the password you stored in the GitHub secret

Now click Continue, give your application a name and click Scaffold. Docker Desktop runs the template and generates the source code and GitHub workflows on you local machine.

When the scaffolding process finishes click Run application. That builds and runs the app in local containers. While it's building click Open in Visual Studio Code to launch a VS Code instance with the generated application code:

Running the application locally with Docker Desktop

Head over to the new docs

Now you can follow the generated documentation from the source code. Browse to the README file in the eshop-web folder and contine from there.

Good luck :)

About

eShop on AWS - Docker Application Templates demo

License:Apache License 2.0


Languages

Language:JavaScript 42.2%Language:C# 41.3%Language:HTML 9.1%Language:CSS 6.0%Language:Shell 0.7%Language:Dockerfile 0.7%