You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This started as a simple use case to discover `docker`, `docker-compose` 🐳 and the creation of `Dockerfile` in both development and production:
5
+
This started as a simple use case to discover `docker` and `docker-compose` 🐳 :
6
6
7
-
* A [front](front) made with create-react-app, running in a nodejs container for development (only the built artefacts will be used in production, not this container)
8
-
* A very simple [api](api) made in go (the challenge is also not to have everything in JavaScript), containerized in docker with a development and a production image
7
+
* A [front](front) made with create-react-app, running in a nodejs container for development
8
+
* A very simple [api](api) made in go (the challenge is also not to have everything in JavaScript)
9
9
10
-
I also setup **deployments on a local kubernetes** ☸️ - it can be fun to start to play with if you want to discover kubernetes.
10
+
I also setup **deployments on a local kubernetes** ☸️ .
11
+
12
+
## TL;DR
13
+
14
+
You are a true developer? You don't RTFM? After all, this is why we have docker ... not to bother with all the boring setup/install steps ... 😉
You are good to go with a development server running at [http://localhost:3000](http://localhost:3000), with the front in react, the api in go and everything hot reloading. 👏
23
+
24
+
Try to take a few minutes to read the doc bellow ... 😇
* local kubernetes server and client (only if you want to play with kubernetes deployment - more about that on the [deployment section](#deployment---kubernetes))
A [Makefile](Makefile) is available that automates all the commands that are described bellow. For each section, you'll find the related commands next to the 🖊 emoji.
59
+
60
+
Just run `make help` to see the whole list.
61
+
20
62
## Development
21
63
22
-
### Install / launch
64
+
### Launch development
23
65
24
66
```shell
25
67
docker-compose up -d
@@ -33,15 +75,17 @@ This will create (if not already done) and launch a whole development stack, bas
33
75
34
76
Go to http://localhost:3000/ to access the frontend, you're good to go, the api is accessible at http://localhost:5000/.
docker-compose run --rm -e CI=true front npm run -s test&& docker-compose run --rm api go test -run ''
42
86
```
43
87
44
-
⚠️ TODO: Make shortcuts for tests from the root of the project (some shortcuts are already available in [front](front#tasks)) / parallelize tests ? Maybe a Makefile ?
88
+
🖊 `make test`, `make test-front`, `make test-api`
45
89
46
90
## Production - docker-compose
47
91
@@ -53,6 +97,8 @@ Make sure you have built the frontend with `docker-compose run --rm front npm ru
53
97
docker-compose -f ./docker-compose.yml -f ./docker-compose.prod.yml up --build
54
98
```
55
99
100
+
Note: make sure to use the `--build` flag so that it will rebuild the images if anything changed (in the source code or whatever), thanks to [docker images layers](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/), only changes will be rebuilt, based on cache (not the whole image).
101
+
56
102
This will create (if not already done) and launch a whole production stack:
57
103
58
104
* No nodejs image (it should not be shipped to production, the development image is only used to launch the container that creates the build artefacts with create-react-app).
@@ -63,6 +109,8 @@ This will create (if not already done) and launch a whole production stack:
63
109
64
110
Access [http://localhost](http://localhost) and you're good to go.
This section is about **deploying the app locally with kubernetes** ☸️ (not tested with a cloud provider). To stay simple, there aren't any TLS termination management (only port 80 exposed).
@@ -74,7 +122,7 @@ Local kubernetes server and client:
74
122
75
123
The files descripting the deployments are stored in the [deployments](deployments) folder. You will find two files, each containing the deployment and the service.
76
124
77
-
### Deploy
125
+
### Deploy with kubernetes
78
126
79
127
1) If you haven't built the frontend, run `docker-compose run --rm front npm run build`
@@ -171,6 +221,7 @@ Don't want to use `docker-compose` (everything bellow is already specified in th
171
221
* exposes the port 3000
172
222
* creates (if not exists) and bind the volumes
173
223
* the container will be removed once you kill the process (`--rm`)
224
+
*`docker rmi $(docker images -q --filter="dangling=true")`: remove dangling images (layers that have no more relationships to any tagged image. Tagged as <none>, they no longer serve a purpose and consume disk space)
174
225
175
226
#### Kubernetes commands
176
227
@@ -230,4 +281,5 @@ More bookmarks from my research:
*[Kubernetes NodePort vs LoadBalancer vs Ingress? When should I use what?](https://medium.com/google-cloud/kubernetes-nodeport-vs-loadbalancer-vs-ingress-when-should-i-use-what-922f010849e0)
232
283
*[Kubectl apply vs kubectl create?](https://stackoverflow.com/questions/47369351/kubectl-apply-vs-kubectl-create)
233
-
*[awesome-kubernetes - A curated list for awesome kubernetes sources](https://ramitsurana.github.io/awesome-kubernetes/)
284
+
*[awesome-kubernetes - A curated list for awesome kubernetes sources](https://ramitsurana.github.io/awesome-kubernetes/)
285
+
*[Tutoriel Linux : Makefile](https://youtu.be/2VV9FAQWHdw)
0 commit comments