Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/build-newsbot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Lint and build Docker
on: [push, pull_request]

jobs:
lint:
timeout-minutes: 10
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.7"

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
cd source-code/chapter-7/exercise-2/newsbot-compose
pip install -r requirements.txt

- name: Lint with flake8
run: |
pip install flake8
cd source-code/chapter-7/exercise-2/newsbot-compose
# run flake8 first to detect any python syntax errors
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# run again to exit treating all errors as warnings
flake8 . --count --exit-zero --max-complexity=10 --statistics

docker-build:
timeout-minutes: 10
runs-on: ubuntu-latest
needs: lint

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Build Docker Image
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

run: |
cd source-code/chapter-7/exercise-2/newsbot-compose
docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
docker build -t ${DOCKER_USERNAME}/newsbot:${GITHUB_SHA} .
docker push ${DOCKER_USERNAME}/newsbot:${GITHUB_SHA}
2 changes: 2 additions & 0 deletions source-code/chapter-8/exercise-1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[kind](https://kind.sigs.k8s.io/), short for Kubernetes in Docker is a tool for running local Kubernetes clusters using Docker containers acting as nodes. For this exercise, we will look at how we can spin up a multi-node Kubernetes cluster using Kind.
Kind makes it easy to create multi-node clusters to test out locally. The final Kind configuration to create a multi-node cluster comprising of 3 control-plane nodes and 3 workers is found in [kind-multi-node.yml](kind-multi-node.yml)
9 changes: 9 additions & 0 deletions source-code/chapter-8/exercise-1/kind-multi-node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: control-plane
- role: control-plane
- role: worker
- role: worker
- role: worker
4 changes: 4 additions & 0 deletions source-code/chapter-8/exercise-2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
In this exercise, we will set up a Continuous Integration workflow for Newsbot that will run flake8, build the Docker image, and push the resulting image to Docker Hub. The Continuous Integration workflow will be set up using GitHub Actions, but the same principle could be applied using any Continuous Integration tool.

This exercise also assumes that we will be working with the Newsbot source code and the Dockerfile from Chapter 7, Exercise 2. You can find the GitHub Actions Workflow file in [.github/workflows/build-newsbot.yaml](../../../.github/workflows/build-newsbot.yaml) file.