Unverified Commit 27c7db42 authored by Marco Kellershoff's avatar Marco Kellershoff Committed by GitHub
Browse files

Merge pull request #1 from walialu/add-bash-commands-to-readme-files

Adds bash commands to README.md

This is an intermediate update of the `README.md`,
that means, that it is not finished yet; but there are yet so many
changes that it **IS** already beneficial to have it available for all
users (even if's not finished).

Therefore we decided to merge it ASAP into the master branch!
parents e1f6bbe1 4afde0c0
# react-workshop
# React Workshop - Onboarding Developers at SDP #
**Preface:** The upstream URL of this repository is:
This React Workshop has been used to get everyone of our team at
[SDP][sdp-github-orga] up and running with our new tech-stack.
## TOS
- [Requirements](required)
- [Start Minikube](#start-minikube)
- [Setup Environment Variables for Docker Image Compilation](#setup-environment-variables-for-docker-image-compilation)
- [Using helm](#using-helm)
- [NPM Run Script(s)](#npm-run-scripts)
- [Build a Docker Image (locally)](#build-the-docker-image-locally)
- [Screencast](#screencast)
## Required
Base Requirements that need to be installed, before you can continue.
- [Minikube][minikube-website]
- [VirtualBox][virtualbox-website]
- [Helm][helm-website]
## Start Minikube
Start minikube by typing
minikube start
List all active kubernetes nodes
kubectl get nodes
There should ne none, because we haven't launched any node yet.
## Setup Environment Variables for Docker Image Compilation
For Linux/Mac it is this one here
eval $(minikube docker-env)
## Using helm
List all Docker processes
docker ps
Change the current working directory to `content-repository`
cd content-repository
Init helm
helm init
Install helm chart found in the subdirectory `chart` and name it
helm install --name backend-database ./chart
List all pods
kubectl get pods
The output should be looking somehow like this
backend-database-postgresql-77455fbb6f-qn7qr 0/1 ContainerCreating 0 4s
As you can see, the `STATUS` indicates that the started pod is there, but still
not ready now.
You can keep checking the pod to become ready
while(kubectl get pods | grep "backend-databae" | awk '{print $2}' | grep "0/1");
do echo "Pod not ready.."; sleep 5;
echo "Pod is ready"
Once the pod has become ready, change the current working directory to
cd ../api
## Build the Docker Image locally
We have a `Dockerfile` which we will use to build our Docker image (locally).
If you're curious, you can peek into the file's contents
cat ./Dockerfile
### npm run scripts
In this specific example, we have the build command (to build the Docker Image)
included in the `package.json`, so we can run it via `npm run`.
If you happen to know Grunt, Gulp, Bower, or Gradle you might find `npm run`
You can run all commands that are part of the `scripts` section in the
`package.json` via `npm run [NAME]`
It's just a very convenient way of storing *scripts* that you need often,
or *scripts* that you want to have out of the developers way,
because they don't need to know exactly what is going on behind the scene.
Let's peek into what options we have in this example
cat ./package.json | jq .scripts
The output should look like this
"test": "echo \"Error: no test specified\" && exit 1",
"build": "docker build --no-cache -t workshop/graphqlapi .",
"showImages": "docker images",
"start": "node_modules/.bin/postgraphile -o -c postgresql://postgres@backend-database-postgresql/postgres -s workshop -w"
That `build` command will come in very handy,
but let's intall all dependencies first
npm install
**Hint:** If you omit the `-g` or `--global` flag,
the dependencies will be installed local to the current directory (inside the
`node_modules`) folder, which is exactly what we want here.
The `postgraphile` module should have been installed, because it's listed
as the only dependency.
cat package.json | jq .dependencies
"postgraphile": "^4.0.0-alpha2.28"
Now let's get back to the handy build command.
(let's just assume that [@jensneuse][jens-github] put it there to make our life
a whole lot easier)
Let's use it to create a Docker Image
npm run build
Once the build succeeded, let's install the Helm chart for this container and
assign the `api` name to it
helm install --name api ./chart
Let's check if the pod is ready
kubectl get pods | grep "api-graphqlapi"
## Screencast
[Jens][jens-github] recorded a screencast showing each step of the workshop
[upstream-repo]: https://github.com/jensneuse/react-workshop
[sdp-github-orga]: https://github.com/t-online
[asciicinema-link]: https://asciinema.org/a/t55y9ve9kc9oooKqsrOz4wFSB "ASCIICast Screencast"
[minikube-website]: https://github.com/kubernetes/minikube
[virtualbox-website]: https://www.virtualbox.org/
[helm-website]: https://github.com/kubernetes/helm
[jens-github]: https://github.com/jensneuse
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment