Skip to content

Commit c4febf4

Browse files
committed
Updates for what-the-hack
1 parent d6bdd88 commit c4febf4

22 files changed

+814
-0
lines changed

content/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Exploring modern DevOps
2+
3+
This repository is built as a resource for developers and other DevOps professionals to build core skills on creating and deploying software with GitHub. The repository contains an application written using [Next.js](https://nextjs.org/) with a [MongoDB](https://www.mongodb.com/) backend, and the beginnings of end-to-end testing with [Cypress](https://www.cypress.io/).
4+
5+
## Required resources
6+
7+
### Local development
8+
9+
To run the project locally, you will need the following resources:
10+
11+
- [Node.js](https://nodejs.org/)
12+
- [MongoDB](https://www.mongodb.com/try/download/community)
13+
14+
Alternatively, you could use a [dev container](https://code.visualstudio.com/docs/devcontainers/containers) by moving the [.devcontainer solution](./what-the-hack/Coach/.devcontainer) folder to the root of the project and opening the project with [Visual Studio Code](https://code.visualstudio.com/).
15+
16+
### Cloud deployment
17+
18+
The workshop contains the necessary files to deploy the project to [Azure Container Apps](https://learn.microsoft.com/azure/container-apps/overview) with a [Azure Cosmos DB for MongoDB](https://learn.microsoft.com/azure/cosmos-db/mongodb/introduction) backend. You can use your Azure account to perform these steps, or [create a trial](https://azure.microsoft.com/free/).
19+
20+
## Formats
21+
22+
### Challenge-based
23+
24+
Many learners find the best results if they explore technology by performing the tasks without step-by-step instructions. To support this style, we have built a workshop using a format modeled from Microsoft's What the Hack. A set of challenges is provided in the [Student folder](./what-the-hack/Student/), where you begin by first opening the project and progressing through a set of tasks typical of a developer using DevOps processes.
25+
26+
**[Begin the challenge-based workshop!](./what-the-hack/README.md)**
27+
28+
> The [Coach folder](./what-the-hack/Coach/) contains the solution. This is to be used by the mentors at your event, or if you get stuck.
29+
30+
### Step-by-step
31+
32+
A [step-by-step workshop](./guided-workshop/) is currently being built.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM mcr.microsoft.com/devcontainers/javascript-node:0-18
2+
3+
# Install MongoDB command line tools - though mongo-database-tools not available on arm64
4+
ARG MONGO_TOOLS_VERSION=6.0
5+
RUN . /etc/os-release \
6+
&& curl -sSL "https://www.mongodb.org/static/pgp/server-${MONGO_TOOLS_VERSION}.asc" | gpg --dearmor > /usr/share/keyrings/mongodb-archive-keyring.gpg \
7+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] http://repo.mongodb.org/apt/debian ${VERSION_CODENAME}/mongodb-org/${MONGO_TOOLS_VERSION} main" | tee /etc/apt/sources.list.d/mongodb-org-${MONGO_TOOLS_VERSION}.list \
8+
&& apt-get update && export DEBIAN_FRONTEND=noninteractive \
9+
&& apt-get install -y mongodb-mongosh \
10+
&& if [ "$(dpkg --print-architecture)" = "amd64" ]; then apt-get install -y mongodb-database-tools; fi \
11+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
12+
13+
# [Optional] Uncomment this section to install additional OS packages.
14+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
15+
# && apt-get -y install --no-install-recommends <your-package-list-here>
16+
17+
# [Optional] Uncomment if you want to install an additional version of node using nvm
18+
# ARG EXTRA_NODE_VERSION=10
19+
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
20+
21+
# [Optional] Uncomment if you want to install more global node modules
22+
# RUN su node -c "npm install -g <your-package-list-here>"
23+
24+
25+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node-mongo
3+
{
4+
"name": "Node.js & Mongo DB",
5+
"dockerComposeFile": "docker-compose.yml",
6+
"service": "app",
7+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
8+
9+
// Features to add to the dev container. More info: https://containers.dev/features.
10+
// "features": {},
11+
12+
// Configure tool-specific properties.
13+
"customizations": {
14+
// Configure properties specific to VS Code.
15+
"vscode": {
16+
// Add the IDs of extensions you want installed when the container is created.
17+
"extensions": [
18+
"mongodb.mongodb-vscode"
19+
]
20+
}
21+
},
22+
"features": {
23+
"ghcr.io/devcontainers/features/azure-cli:1": {},
24+
"ghcr.io/devcontainers/features/github-cli:1": {}
25+
}
26+
27+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
28+
// "forwardPorts": [3000, 27017],
29+
30+
// Use 'postCreateCommand' to run commands after the container is created.
31+
// "postCreateCommand": "yarn install",
32+
33+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
34+
// "remoteUser": "root"
35+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
volumes:
9+
- ../..:/workspaces:cached
10+
11+
# Overrides default command so things don't shut down after the process ends.
12+
command: sleep infinity
13+
14+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
15+
network_mode: service:db
16+
17+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
18+
# (Adding the "ports" property to this file will not forward from a Codespace.)
19+
20+
db:
21+
image: mongo:latest
22+
restart: unless-stopped
23+
volumes:
24+
- mongodb-data:/data/db
25+
26+
# Uncomment to change startup options
27+
# environment:
28+
# MONGO_INITDB_ROOT_USERNAME: root
29+
# MONGO_INITDB_ROOT_PASSWORD: example
30+
# MONGO_INITDB_DATABASE: your-database-here
31+
32+
# Add "forwardPorts": ["27017"] to **devcontainer.json** to forward MongoDB locally.
33+
# (Adding the "ports" property to this file will not forward from a Codespace.)
34+
35+
volumes:
36+
mongodb-data:
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# What The Hack - Modern development and DevOps with GitHub
2+
3+
## Introduction
4+
5+
Welcome to the coach's guide for the Modern development and DevOps with GitHub What The Hack. Here you will find links to specific guidance for coaches for each of the challenges.
6+
7+
> **NOTE:** If you are a Hackathon participant, this is the answer guide. Don't cheat yourself by looking at these during the hack! Go learn something. :)
8+
9+
## Coach's Guides
10+
11+
- [Challenge 0](./Coach/solution00.md) - Setup and Introduction
12+
- [Challenge 1](./Coach/solution01.md) - Configure your development environment
13+
- [Challenge 2](./Coach/solution02.md) - Add a feature to the existing application
14+
- [Challenge 3](./Coach/solution03.md) - Setup continuous integration and ensure security
15+
- [Challenge 4](./Coach/solution04.md) - Create a deployment environment
16+
- [Challenge 5](./Coach/solution05.md) - Setup continuous deployment
17+
18+
## Coach Prerequisites
19+
20+
This hack has pre-reqs that a coach is responsible for understanding and/or setting up BEFORE hosting an event. Please review the [What The Hack Hosting Guide](https://aka.ms/wthhost) for information on how to host a hack event.
21+
22+
The guide covers the common preparation steps a coach needs to do before any What The Hack event, including how to properly configure Microsoft Teams.
23+
24+
### Coach notes
25+
26+
- DevOps is a large topic, one which students can explore many aspects. Feel free to have conversations with teams about different approaches. Allow them to explore as they like.
27+
28+
### Student Resources
29+
30+
- The [student resources folder](../Student/resources/) contains a copy of a possible solution for the React component for [Challenge 2 - Add a feature to the existing application](../Student/challenge02.md). Students are welcome to copy/paste this file if they don't feel comfortable coding.
31+
32+
> **NOTE:** Always refer students to the [What The Hack website](https://aka.ms/wth) for the student guide. Students should **not** be given a link to the What The Hack repo before or during a hack. The student guide does **NOT** have any links to the Coach's guide or the What The Hack repo on GitHub.
33+
34+
## Azure Requirements
35+
36+
This hack requires students to have access to an Azure subscription where they can create and consume Azure resources. These Azure requirements should be shared with a stakeholder in the organization that will be providing the Azure subscription(s) that will be used by the students.
37+
38+
- Attendees should have the “Azure account administrator” (or "Owner") role on the Azure subscription in order to authenticate, create and configure the resource group and necessary resources including:
39+
- Serverless Cosmos DB with Mongo API
40+
- Azure Container App with supporting services
41+
42+
> **NOTE:** A [bicep file](../Student/resources/main.bicep) is provided to create the necessary Azure resources
43+
44+
## Repository Contents
45+
46+
- `./Coach`
47+
- Coach's Guide and related files
48+
- `./Coach/Solutions`
49+
- Solution files with completed example answers to a challenge
50+
- `./Student`
51+
- Student's Challenge Guide
52+
- `./Student/Resources`
53+
- Resource files, sample code, scripts, etc meant to be provided to students. (Must be packaged up by the coach and provided to students at start of event)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
on: [workflow_dispatch]
2+
name: Create Azure resources
3+
jobs:
4+
build-and-deploy:
5+
runs-on: ubuntu-latest
6+
steps:
7+
8+
# Checkout code
9+
- uses: actions/checkout@main
10+
11+
# Log into Azure
12+
- uses: azure/login@v1
13+
with:
14+
creds: ${{ secrets.AZURE_CREDENTIALS }}
15+
16+
# Deploy Bicep file
17+
- name: create resources
18+
uses: azure/arm-deploy@v1
19+
with:
20+
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }}
21+
resourceGroupName: ${{ secrets.AZURE_RG }}
22+
template: ${{ github.workspace }}/config/main.bicep
23+
parameters: 'namePrefix=${{ secrets.AZURE_PREFIX }}'
24+
failOnStdErr: false
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
name: Deploy to Azure
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v3
13+
14+
- name: Log in to Azure
15+
uses: azure/login@v1
16+
with:
17+
creds: ${{ secrets.AZURE_CREDENTIALS }}
18+
19+
- name: Build and deploy Container App
20+
uses: azure/container-apps-deploy-action@v0
21+
with:
22+
appSourcePath: ${{ github.workspace }}/src
23+
acrName: ${{ secrets.AZURE_CONTAINER_REGISTRY }}
24+
resourceGroup: ${{ secrets.AZURE_RG }}
25+
containerAppName: ${{ secrets.AZURE_CONTAINER_APP }}
26+
containerAppEnvironment: ${{ secrets.AZURE_CONTAINER_APP_ENVIRONMENT }}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Challenge 0 - Setup and introduction - Coach's guide
2+
3+
## Notes and guidance
4+
5+
- Students are introduced to the scenario and obtain the source code
6+
- Students should create a repository from the template on their own GitHub account or using the organization provided for the event
7+
8+
**[Home](./README.md)** - [Next Solution >](./solution01.md)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Challenge 1 - Configure your development environment - Coach's guide
2+
3+
## Notes and guidance
4+
5+
- Students **do not** need to install any resources on their local system. The challenge uses Codespaces, which is a cloud-based development container.
6+
- Rebuilding the container after it's been configured for the project may take several minutes. Highlight how [prebuilds](https://docs.github.com/en/codespaces/prebuilding-your-codespaces) can ensure a Codespace is available for developers within seconds.
7+
- Ensure attendees have created the secret for Codespaces for `MONGODB_URI`
8+
- Ensure the features are added for **GitHub CLI**, **Azure CLI** and **MongoDB**
9+
10+
[< Previous Solution](./solution00.md) - **[Home](./README.md)** - [Next Solution >](./solution02.md)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Challenge 2 - Add a feature to the existing application - Coach's guide
2+
3+
## Notes and guidance
4+
5+
- Students **do not** need coding experience. If they are unfamiliar with code, they can copy/paste from the [provided Hours.js file](../Student/resources/Hours.js).
6+
- Ensure students install the [Copilot extension](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot) for their Codespace. This can also be done by registering it in the devcontainer.json file.
7+
8+
[< Previous Solution](./solution01.md) - **[Home](./README.md)** - [Next Solution >](./solution03.md)

0 commit comments

Comments
 (0)