Skip to content

Commit 111533b

Browse files
authored
Merge pull request #1 from github/wth-updates
Updates for what-the-hack
2 parents 311387b + c4febf4 commit 111533b

29 files changed

+818
-4
lines changed
File renamed without changes.

src/Dockerfile renamed to Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ENV NODE_ENV production
4343
RUN addgroup --system --gid 1001 nodejs
4444
RUN adduser --system --uid 1001 nextjs
4545

46-
COPY --from=builder /app/public ./public
46+
COPY --from=builder /app/src/public ./public
4747

4848
# Automatically leverage output traces to reduce image size
4949
# https://nextjs.org/docs/advanced-features/output-file-tracing

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
This repository contains the project for both a guided workshop and the Modern DevOps with GitHub What The Hack. The project is a Next.js app that uses MongoDB for the database. The design is to be used as a walk-through of GitHub features, including [Codespaces](https://docs.github.com/en/codespaces/overview), [Actions](https://docs.github.com/en/actions/learn-github-actions) and [GitHub Advanced Security (GHAS)](https://docs.github.com/en/github/getting-started-with-github/about-github-advanced-security). You'll explore how to use these features to implement and improve your organization's DevOps processes.
44

5-
## Requirements
5+
## Getting started
66

7-
This project uses Node.js for the application and MongoDB for the database. You can [install locally MongoDB](https://www.mongodb.com/docs/manual/administration/install-community/) or use a cloud based provider of your choosing.
7+
**[Get started learning about development and DevOps with GitHub!](./content/README.md)**
88

99
## License
1010

config/main.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ resource containerApp 'Microsoft.App/containerApps@2022-03-01' = {
145145
}
146146
]
147147
resources: {
148-
cpu: '1'
148+
cpu: '0.5'
149149
memory: '1.0Gi'
150150
}
151151
}

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

0 commit comments

Comments
 (0)