Skip to content

Commit fd6b0db

Browse files
authored
refactoring testing, building and Image system
This is a complete refactoring of our testing, building and Image system: - no `./buildImages.sh` anymore it's all happening with `make` - all images built by make, make also knows the dependency of the images and build them in the correct order - docker-compose does not build images anymore, it just references images that are build by make - new naming of images: version numbers all in image name, not in image tag (`centos7-node6` instead of `centos7-node:6`) - no minishift anymore, we're using `oc cluster up` which runs within Docker, it's faster! - using Travis for CI, which can run multiple tests at the same time. - read DEVELOPMENT.md and TESTS.md to learn more
1 parent 1a6d959 commit fd6b0db

File tree

92 files changed

+1232
-722
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1232
-722
lines changed

.dockerignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
**/node_modules
2-
.dockerignore
2+
.dockerignore
3+
.git
4+
tests
5+
.cache
6+
Makefile

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ deploytest
55
.DS_Store
66
*.retry
77
startVagrant.sh
8+
local-dev/oc
89
minishift
910
**/v8-*
1011
node_modules
12+
build/*
13+
!build/.gitkeep
14+
openshift
15+
.loopback

.travis.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
sudo: required
2+
services:
3+
- docker
4+
before_install:
5+
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
6+
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
7+
- sudo apt-get update
8+
- sudo apt-get -y install docker-ce
9+
- sudo sh -c "echo \"DOCKER_OPTS='--insecure-registry 172.30.0.0/16'\" >> /etc/default/docker" && sudo service docker restart && sudo mount --make-rshared /
10+
- docker info
11+
- docker version
12+
- docker login -u amazeeiojenkins -p $DOCKERHUB_PASSWORD
13+
install:
14+
- make pull -j6 TAG=$TRAVIS_BRANCH
15+
- docker image ls -a --digests
16+
before_script:
17+
- make openshift
18+
script:
19+
- docker logs -f origin &> .openshift-logs &
20+
- make build TAG=$TRAVIS_BRANCH
21+
- make tag-push TAG=$TRAVIS_BRANCH &> .push-logs &
22+
- make up
23+
- docker-compose -p lagoon logs -f &> .service-logs &
24+
- sleep 45
25+
- make tests
26+
after_script:
27+
- cat .build-logs
28+
- cat .openshift-logs
29+
- cat .push-logs
30+
- cat .service-logs
31+
notifications:
32+
slack:
33+
secure: XavhNWfkLB2MfuEg6UrIZ6jz3NNRr9drcyOWlI75wB2iPuP7C/rGrZ1NZJNjGvykM7JvZqcfD+tyzolP+MgzIthJF51mooC8QyfZc1BoiS2uhg+hD/g3COB+XbRnHv76Q4I42KRP/vHM2quNaW79VWovyCoTcWzJqVpKnLvs26asl38+5Z0oYGXTROC6c5rfow8aAsix1ZatCwugOQmVmepsKpLjNpiSv1OyWeIqURkqTxO2Q/Pw6Kow6O0DZZZW75swDNbNeC4OK4mZiGj5yPFRpiVqz1DHIWYAvCzkMVqgxubn5Ob/cDlkY306XGauetOlfx2SgL1FN4sbVFnu9t2JZJXj+Zzg7ccoGtN3rlfIpoUGb4U6hIQFmLky8XnZYnEF1D+n9ld3/y5WV7qOeVYTZsf5nEopD1Kq/8Zc+Hi6VJZ1nZEaovlLL2USnWfo4E/PlO3hSTF/9FEPy2JyWuExdcBxxTBWwgNwihBvpEyFG+YeryNR2kAlax8cRi8inhHLIBg+PhSDFB5r/kMjwDYqWQ/uTIFxLbZa+s1TEhNspPaeyDJkj8wYnlrlWuAC9fDppFFM8BbZrK1Lc6nIY0VMFVZOyKug6TW3/Jy2iKY1D0+EoCg78qHWn9xnXWfMugQKKLz+/p+WocC9HTiijYbqWtuUPBupF5SQpCQhw+0=

DEVELOPMENT.md

+25-20
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,55 @@ Please check the [official Docs of Docker](https://docs.docker.com/engine/instal
88

99
## Start Services
1010

11-
1. clone this repo
11+
1. Add `172.30.0.0/16` to insecure registries in Docker (see [here](https://docs.docker.com/registry/insecure/) how to do that). Also make sure that you give your Docker Host minimum 4 CPUs and 6GB Ram. Also check that nothing is running on localhost:80 and localhost:443, as OpenShift will use these ports to run.
1212

13-
2. build base images needed for testing
13+
2. Pull existing images for faster building as we use Docker Layer Caching
1414

1515
```sh
16-
./buildBaseImages.sh
16+
make pull
1717
```
1818

19-
3. start Lagoon Services
19+
Important: Lagoon consists of a lot of Services and Docker Images, building and running them locally might not even be necessary.
20+
We're using make (see the [Makefile](./Makefile)) in order to only build the needed Docker Images specifically for a part of Lagoon.
2021

21-
```sh
22-
docker-compose up -d
23-
```
22+
All of it is based around tests. So if you like to only build the part that is needed to work on the Node.js deployment, you can run the tests with `make tests/node`, this will then setup (openshift, building images, services) all the needed stuff for the Node.js deployment part.
2423

25-
4. Follow the Services logs
24+
If you would still like to build and start all services, go ahead:
25+
26+
2. Build images
2627

2728
```sh
28-
docker-compose logs -f
29+
make build
2930
```
3031

31-
## Start & Test OpenShift
32-
33-
1. start OpenShift
32+
3. start Lagoon Services
3433

3534
```sh
36-
./startOpenShift.sh
35+
make up
3736
```
3837

39-
2. Add `https://docker-registry-default.192.168.77.100.nip.io:443` to insecure registries in Docker (see [here](https://docs.docker.com/registry/insecure/) how to do that).
38+
4. Follow the Services logs
4039

41-
4. run tests
40+
```sh
41+
make logs
42+
```
4243

44+
5. run tests (read [TESTS.md](./TESTS.m) to learn more about testing)
4345
```sh
44-
docker-compose run --rm tests ansible-playbook /ansible/tests/ALL.yaml
46+
make tests
4547
```
4648

49+
6. Look what happens in OpenShift: https://172.16.123.1:8443/console (developer/developer)
50+
4751
## Local Development
4852

4953
Most services are written in Node.js. As many of these services share similar Node code and Node Packages, we're using a new feature of yarn, called `yarn workspaces`. Yarn Workspaces needs a package.json in the projects root directory that defines the workspaces plus an `.yarnrc` that enables workspace mode.
5054

51-
The development of the services can happen directly within Docker. Each container for each service is setup in a way that it's source code is mounted into the running container. Node itself is watching the code via `nodemon` and restarts the node process automatically on a change.
55+
The development of the services can happen directly within Docker. Each container for each service is setup in a way that it's source code is mounted into the running container (see [docker-compose.yml](./docker-compose.yml). Node itself is watching the code via `nodemon` and restarts the node process automatically on a change.
5256

5357
### lagoon-commons
5458

55-
The services not only share many node packages, but also share actual custom code. This code is within `node-packages/lagoon-commons` it will be automatically symlinked by yarn workspaces, plus the nodemon of the services is setup in a way that it also checks for changes in `node-packages` and will restart the node process automatically
59+
The services not only share many node packages, but also share actual custom code. This code is within `node-packages/lagoon-commons` it will be automatically symlinked by yarn workspaces, plus the nodemon of the services is setup in a way that it also checks for changes in `node-packages` and will restart the node process automatically.
5660

5761
### Hiera
5862

@@ -62,10 +66,11 @@ The API uses a puppet compatible yaml format to store it's data. On production t
6266

6367
**I can't build any docker image for any Node.js based service**
6468

65-
Build the latest base images via
69+
Rebuild the images via
6670

6771
```sh
68-
./buildBaseImages.sh
72+
make clean
73+
make build
6974
```
7075

7176
**I get errors about missing node_modules content when I try to build / run a NodeJS based image**

Jenkinsfile

-117
This file was deleted.

0 commit comments

Comments
 (0)