In the fight for the speeding up the coding we first disabled our developers to waste their work time managing the development environment on their workstations and invented our own unique CI/CD scheme.
S4Y CI/CD implementation is different from the others we do not have “central main CI/CD server” to handle all the company builds. Instead we launch the lightweight drone.io server on every testing/development host and avoid the huge network traffic and the build tasks queues.
It might seems to be overkill to manage many CI/CD services, but practice showed to launch CI/CD with docker-compose and grant access to few developers it 30 minutes task requiring no attention for the rest of the host life. The developers manage per-project YML files by themselves having no delays caused by extra requests to DevOp in order to make changes in the integration configs.
Another trick is to use mounted host volumes and host docker socket for caching temporary files like node_modules, .nuget and go/pkg which would take lot of time to be downloaded on every build.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
#avoid unnessary submodules cloning clone: git: image: plugins/git recursive: false submodule_update_remote: false submodule_override: protobuf: git@bitbucket.org:....git pipeline: # restore nugets from the previous success build restore-cache: image: drillster/drone-volume-cache restore: true mount: - /root/.nuget volumes: - /tmp/cache-drone:/cache build: .. run: ... # create new cache on succes build rebuild-cache: image: drillster/drone-volume-cache rebuild: true mount: - /root/.nuget volumes: - /tmp/cache-drone:/cache |
And particularly for nodejs/react builds we check if the package.json has been changed from the recent build and skip the npm update if it was not.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
build: image: s4ysolutions/nodejs10x commands: # move npm cache from the home directory to avoid permission problems - npm set config cache npm_cache # test if package.json from the previous build is different from the current - test -f ./npm_cache/package.json && diff package.json ./npm_cache/package.json || touch need_update # run npm instal ONLY if there is a change - test -f need_update && npm install --no-package-lock --loglevel=warn # run npm scripts as usual - npm run build # copy the current package.json to the cached filesystem to persist it # on the host - test -d ./npm_cache && cp package.json ./npm_cache/package.json |
Moreover we avoid to build and run dockers in the development environment if possible, for example the frontend static files built within nodejs container are just copied to the host’s directory served by pre-configured nginx:
1 2 3 4 5 6 7 8 |
build: ... # jsut copy build files to the host filesystem served by nginx - rm -rf /var/www/map2online/* - cp -rp dist/* /var/www/map2online # "volumes" lets drone.io access the host's filesystem volumes: - /var/www/map2online:/var/www/map2online |