diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e461241 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM node:8.1.2 +COPY . . +RUN if [ -n "$http_proxy" ]; then npm config set proxy $http_proxy && npm config set https-proxy $https_proxy; fi +RUN npm install gulp-cli -g && npm install +WORKDIR /app +EXPOSE 8080 +CMD gulp watch diff --git a/README.md b/README.md index 953f49e..bca0950 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,40 @@ Build and reload server: `gulp watch` +## Docker + +To simplify the installation we also provide a Dockerfile to run the application in a container. + +Build image: +`docker build -t cheatsheet .` + +Build image w/ proxy: +`docker build -t cheatsheet --build-arg http_proxy= --build-arg https_proxy= .` + +Add cheatsheet: +``` +docker run \ +-v $PWD:/app \ +cheatsheet:latest gulp create-new-cheat-sheet --name --category +``` + +`-v $PWD:/app` mounts the current directory as working directory inside the container. + +Put your svg|png logo in assets/images folder +Put your commands or codes on: + - src/\/first-side/column1.md + - src/\/first-side/column2.md + - src/\/reverse/column1.md + - src/\/reverse/column2.md + +Run the web server to display all the cheat-sheets: +``` +docker run -ti \ +-v $PWD:/app \ +-p 8080:8080 \ +cheatsheet:latest +``` + ## Print - Hit `Ctrl+P` to generate the PDF version, using `Save as PDF` diff --git a/assets/images/ansible.png b/assets/images/ansible.png new file mode 100644 index 0000000..0bb9f2b Binary files /dev/null and b/assets/images/ansible.png differ diff --git a/assets/images/docker-swarm.png b/assets/images/docker-swarm.png new file mode 100644 index 0000000..e96af6a Binary files /dev/null and b/assets/images/docker-swarm.png differ diff --git a/assets/images/docker.png b/assets/images/docker.png new file mode 100644 index 0000000..049967e Binary files /dev/null and b/assets/images/docker.png differ diff --git a/package.json b/package.json index 84aa4f0..c84f727 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ }, "license": "MIT", "devDependencies": { - "del": "^2.2.2", - "eslint": "^3.14.0", + "del": "^3.0.0", + "eslint": "^4.2.0", "express": "^4.14.0", "gulp": "^3.9.1", "gulp-clean": "^0.3.2", @@ -23,12 +23,12 @@ "gulp-livereload": "^3.8.1", "gulp-markdown": "^1.2.0", "gulp-rename": "^1.2.2", - "gulp-replace": "^0.5.4", + "gulp-replace": "^0.6.1", "gulp-sass": "^3.0.0", - "gulp-tap": "^0.1.3", + "gulp-tap": "^1.0.1", "gulp-template": "^4.0.0", "merge-stream": "^1.0.1", - "yargs": "^6.5.0" + "yargs": "^8.0.2" }, "engines": { "node": ">=6.9.0 ", diff --git a/src/angular-cli/first-side/column2.md b/src/angular-cli/first-side/column2.md index fa3e22e..9db12cd 100644 --- a/src/angular-cli/first-side/column2.md +++ b/src/angular-cli/first-side/column2.md @@ -1,4 +1,4 @@ - current version: __1.0.0-beta.32.3__ - Date: __Feb. 2017__ + current version: __1.2.1__ - Date: __July 2017__ # Test Running unit tests @@ -26,4 +26,4 @@ Enum Module `ng g module my-new-module` Module with module routes -`ng g module my-new-module --routing` \ No newline at end of file +`ng g module my-new-module --routing` diff --git a/src/angular-cli/index.html b/src/angular-cli/index.html index 5855696..61dc7cf 100644 --- a/src/angular-cli/index.html +++ b/src/angular-cli/index.html @@ -9,7 +9,7 @@
- @@include('../../dist/common/first-side/header.html', {"title": "Angular CLI cheat sheet", "subtitle": "Angular CLI for Angular applications", "imageName": "@@folder"}) + @@include('../../dist/common/first-side/header.html', {"title": "Angular CLI cheat sheet", "subtitle": "CLI tool for Angular", "imageName": "@@folder"})
diff --git a/src/ansible/ansible.scss b/src/ansible/ansible.scss new file mode 100644 index 0000000..65706bd --- /dev/null +++ b/src/ansible/ansible.scss @@ -0,0 +1,13 @@ +/* put your all custom css rules here */ +/* you must not change other scss files */ + +body { + // available colors are: blue, green, purple, orange and grey + --currentColor: var(--blue); + + main div { + img { + height: 230px; + } + } +} \ No newline at end of file diff --git a/src/ansible/first-side/column1.md b/src/ansible/first-side/column1.md new file mode 100644 index 0000000..9a6eeee --- /dev/null +++ b/src/ansible/first-side/column1.md @@ -0,0 +1,43 @@ + Ansible version: __2.3__ - Date: __June 2017__ + +# Getting Started +**Installation** (example on RedHat environnement) : +``` +$ sudo yum -y install epel-release +$ sudo yum -y update +$ sudo yum -y install ansible +``` + +** Doc link : http://docs.ansible.com/ansible/latest/** + +# Inventory files +The default file is **/etc/ansible/hosts** : +``` +[web] +web1.sii-ouest.fr ansible_ssh_host=192.168.0.101 +web2.sii-ouest.fr ansible_ssh_host=192.168.0.102 + +[db] +db1.sii-ouest.fr ansible_ssh_host=192.168.0.100 + +[production:children] +web +db +``` + +## Hostname ranges +``` +www[01:50].example.com, db-[a:f].example.com +``` + +# Variable files + - **./group_vars/web** : variable definitions for all members of group 'web' + - **./host_vars/web1.sii-ouest.fr** : variable definitions for 'web1.sii-ouest.fr' + +# Ad-Hoc commands +```ansible -m -a ``` + +Execute reboot on all servers in a group (example on production, in 10 parallel forks) : +``` +$ ansible production -i ./hosts all -m command -a "/sbin/reboot" -f 10 +``` diff --git a/src/ansible/first-side/column2.md b/src/ansible/first-side/column2.md new file mode 100644 index 0000000..6b7cdb5 --- /dev/null +++ b/src/ansible/first-side/column2.md @@ -0,0 +1,47 @@ +# Playbooks + +Execute a playbook : +```ansible-playbook -i ./hosts``` + +Test a playbook (don't make any changes on servers) : +```ansible-playbook --check``` + +Limit a playbook on a host : +```ansible-playbook --limit ``` + +**Tasks** : +``` +--- +- hosts: web + tasks: + - name: Installation of Apache Package + yum: + name: httpd + state: present + update_cache: yes + + - name: Ensure Apache is running (and enable it at boot) + service: name=httpd state=started enabled=yes +``` + +**Roles** (use to structure a list of Tasks): +- Directory structure : +``` +. +├── ansible.cfg +├── hosts +└── roles + └── myrole + ├── defaults + │   └── main.yml + ├── files + │   └── myfile + ├── handlers + │   └── main.yml + ├── tasks + │   └── main.yml + ├── templates + │   └── mytemplate.j2 + └── vars + └── main.yml +``` diff --git a/src/ansible/index.html b/src/ansible/index.html new file mode 100644 index 0000000..b60e179 --- /dev/null +++ b/src/ansible/index.html @@ -0,0 +1,48 @@ + + + + + + + + + + +
+ @@include('../../dist/common/first-side/header.html', {"title": "ansible cheat sheet", "subtitle": "Configuration Management Tool", "imageName": "@@folder"}) + +
+
+ @@include('../../dist/@@folder/first-side/column1.html') +
+
+ @@include('../../dist/@@folder/first-side/column2.html') +
+
+ + @@include('../../dist/common/footer.html', {"class": "print-only"}) + + +
+ +
+ +
+ @@include('../../dist/common/reverse/header.html', {"title": "ansible cheat sheet", "imageName": "@@folder"}) + +
+
+ @@include('../../dist/@@folder/reverse/column1.html') +
+
+ @@include('../../dist/@@folder/reverse/column2.html') +
+
+ + @@include('../../dist/common/footer.html') +
+ + + + + diff --git a/src/ansible/reverse/column1.md b/src/ansible/reverse/column1.md new file mode 100644 index 0000000..3836e34 --- /dev/null +++ b/src/ansible/reverse/column1.md @@ -0,0 +1,56 @@ +**Handlers and Notify** : +``` +tasks: + - name: Install Apache + yum: name=httpd state=present + notify: Start Apache + +handlers: + - name: Start Apache + service: name=httpd state=started +``` + +Handlers by default get executed at the end of the playbook. + +**Conditionnals** : +``` +- name: Analyse 'my_file' + shell: cat "my_file" + register: my_file_contents + +- name: Show results + shell: echo "find pattern" + when: my_file_contents.stdout.find('toto') != -1 +``` + +**Template** : Jinja Templating +- **{% ... %}** for control statements +- **{{ ... }}** for expressions +- **{# ... #}** for comments + +**Tags** : +Limit a playbook on tags : +```ansible-playbook -i ./hosts --tag ``` + +**Loops over items** : +``` +- name: Add a list of users + user: name={{ item }} state=present + with_items: + - testuser1 + - testuser2 + - testuser3 +``` + +## Example (Installation and conf. of Apache server): + +./playbook-deploy-apache.yml +``` +--- +- hosts: web + roles: + - { role: demo-install-apache } + - { role: demo-configure-apache } +``` + + diff --git a/src/ansible/reverse/column2.md b/src/ansible/reverse/column2.md new file mode 100644 index 0000000..f645770 --- /dev/null +++ b/src/ansible/reverse/column2.md @@ -0,0 +1,49 @@ +./roles/demo-configure-apache/vars/main.yml +``` +--- +apache_listen_port: 8081 +app_directory: /var/www/html +app_user: apache +app_group: apache +``` + +./roles/demo-configure-apache/handlers/main.yml +``` +--- + - name: Reload Apache + service: + name: httpd + state: reloaded +``` + +./roles/demo-install-apache/tasks/main.yml +``` +--- + - name: Installation of Apache Package + yum: + name: httpd + state: present + update_cache: yes + + - name: Ensure Apache is running (and enable it at boot) + service: name=httpd state=started enabled=yes +``` + +./roles/demo-configure-apache/tasks/main.yml +``` +--- + - name: Modify permission of directory {{ app_directory }} + file: + dest: '{{ app_directory }}' + mode: 0755 + owner: '{{ app_user }}' + group: '{{ app_group }}' + recurse: yes + + - name: Modify Apache configuration + lineinfile: + dest: /etc/httpd/conf/httpd.conf + regexp: '^Listen ' + line: 'Listen {{ apache_listen_port }}' + notify: Reload Apache +``` diff --git a/src/cordova/first-side/column1.md b/src/cordova/first-side/column1.md index 1b583c5..c9d0a6e 100644 --- a/src/cordova/first-side/column1.md +++ b/src/cordova/first-side/column1.md @@ -1,4 +1,4 @@ -Cordova : __6.5.0__ - Date : __March 2017__ +Cordova : __7.0.0__ - Date : __July 2017__ # NPM commands @@ -50,4 +50,4 @@ You can run application on added platform cordova run android cordova run ios cordova run browser -``` \ No newline at end of file +``` diff --git a/src/cordova/index.html b/src/cordova/index.html index b0de131..f29703a 100644 --- a/src/cordova/index.html +++ b/src/cordova/index.html @@ -9,7 +9,7 @@
- @@include('../../dist/common/first-side/header.html', {"title": "cordova cheat sheet", "subtitle": "sous titre, une description.", "imageName": "@@folder"}) + @@include('../../dist/common/first-side/header.html', {"title": "cordova cheat sheet", "subtitle": "Mobile apps with HTML, CSS & JS", "imageName": "@@folder"})
diff --git a/src/docker-swarm/docker-swarm.scss b/src/docker-swarm/docker-swarm.scss new file mode 100644 index 0000000..f8e8ed2 --- /dev/null +++ b/src/docker-swarm/docker-swarm.scss @@ -0,0 +1,19 @@ +/* put your all custom css rules here */ +/* you must not change other scss files */ + +body { + // available colors are: blue, green, purple, orange and grey + --currentColor: var(--blue); + + main div { + img { + height: 230px; + } + } + + h2 { + margin-top: 1.5rem; + padding: 0; + font-size: 1.2rem; + } +} diff --git a/src/docker-swarm/first-side/column1.md b/src/docker-swarm/first-side/column1.md new file mode 100644 index 0000000..0727f3a --- /dev/null +++ b/src/docker-swarm/first-side/column1.md @@ -0,0 +1,29 @@ + docker version: __17.09+__ - Date: __October 2017__ + +# Cluster initialization + +## On the first Manager node + +Initialize the cluster +`docker swarm init --advertise-addr ` + +Retrieve the token to add a new Manager node +`docker swarm join-token manager` + +Retrieve the token to add a new Worker node +`docker swarm join-token worker` + +## On every new node + +Join the node to the cluster +`docker swarm join --token ` + +# Cluster events + +Show real time events +`docker events` + +# Manage networks + +Create a distributed overlay network +`docker network create --driver overlay ` diff --git a/src/docker-swarm/first-side/column2.md b/src/docker-swarm/first-side/column2.md new file mode 100644 index 0000000..0ef0c02 --- /dev/null +++ b/src/docker-swarm/first-side/column2.md @@ -0,0 +1,28 @@ +# Manage nodes + +List all nodes +`docker node ls` + +Inspect a node +`docker node inspect ` + +List tasks running on a node +`docker node ps ` + +Promote a node to Manager +`docker node promote ` + +Demote a node to Worker +`docker node demote ` + +Update a node +`docker node update [OPTIONS] ` + + * Add a label: `docker node update --label-add type=front node-1` + * Drain a node: `docker node update --availability drain node-1` + +Make a Worker node leave the Cluster +`docker swarm leave` + +Remove a node from nodes list +`docker node rm ` diff --git a/src/docker-swarm/index.html b/src/docker-swarm/index.html new file mode 100644 index 0000000..65674c6 --- /dev/null +++ b/src/docker-swarm/index.html @@ -0,0 +1,48 @@ + + + + + + + + + + +
+ @@include('../../dist/common/first-side/header.html', {"title": "docker swarm", "subtitle": "Container orchestration platform", "imageName": "@@folder"}) + +
+
+ @@include('../../dist/@@folder/first-side/column1.html') +
+
+ @@include('../../dist/@@folder/first-side/column2.html') +
+
+ + @@include('../../dist/common/footer.html', {"class": "print-only"}) + + +
+ +
+ +
+ @@include('../../dist/common/reverse/header.html', {"title": "docker cheat sheet", "imageName": "@@folder"}) + +
+
+ @@include('../../dist/@@folder/reverse/column1.html') +
+
+ @@include('../../dist/@@folder/reverse/column2.html') +
+
+ + @@include('../../dist/common/footer.html') +
+ + + + + diff --git a/src/docker-swarm/reverse/column1.md b/src/docker-swarm/reverse/column1.md new file mode 100644 index 0000000..5de11e0 --- /dev/null +++ b/src/docker-swarm/reverse/column1.md @@ -0,0 +1,33 @@ +# Manage services + +Create a new service +`docker service create [OPTIONS] [COMMAND] [ARGS...]` + + * Create a busybox service: `docker service create --name busybox busybox` + +List all services +`docker service ls` + +List the tasks of a service +`docker service ps ` + +Remove a service +`docker service rm ` + +Update a service +`docker service update [OPTIONS] ` + + * Update service image `docker service update --image my-service:2 my-service` + +Scale a service +`docker service scale =` + +Inspect a service +`docker service inspect ` + +Fetch the logs of a service or task +`docker service logs ` +`docker service logs ` + +Roll back a service to its previous version +`docker service rollback ` diff --git a/src/docker-swarm/reverse/column2.md b/src/docker-swarm/reverse/column2.md new file mode 100644 index 0000000..030098a --- /dev/null +++ b/src/docker-swarm/reverse/column2.md @@ -0,0 +1,38 @@ +# Manage stacks + +Deploy a new stack from a compose file +`docker stack deploy --compose-file ` + +List all stacks +`docker stack ls` + +List the services of a stack +`docker stack services ` + +List the tasks of a stack +`docker stack ps ` + +Remove a stack +`docker stack rm ` + +# Manage secrets + +Create a secret from a file or STDIN +`Docker secret create ` +`echo |docker secret create ` + +List all secrets +`Docker secret ls` + +Use a secret in a compose file +```dockerfile +version: "3.1" +services: + web: + image: secrets_web + secrets: + - mysql-password +secrets: + mysql-password: + external: true +``` diff --git a/src/docker/docker.scss b/src/docker/docker.scss new file mode 100644 index 0000000..65706bd --- /dev/null +++ b/src/docker/docker.scss @@ -0,0 +1,13 @@ +/* put your all custom css rules here */ +/* you must not change other scss files */ + +body { + // available colors are: blue, green, purple, orange and grey + --currentColor: var(--blue); + + main div { + img { + height: 230px; + } + } +} \ No newline at end of file diff --git a/src/docker/first-side/column1.md b/src/docker/first-side/column1.md new file mode 100644 index 0000000..3287bb9 --- /dev/null +++ b/src/docker/first-side/column1.md @@ -0,0 +1,37 @@ + docker version: __17.05+__ - Date: __June 2017__ + +# Installation + +From Linux shell +`curl -fsSL https://get.docker.com/ | sh` + +Show the Docker version information +`docker version` + +# Start containers + +Run a container +`docker run ` + +Run a container in background +`docker run -d ` + +# Manage containers + +List running containers +`docker ps` + +List all containers +`docker ps -a` + +Restart container +`docker restart ` + +Stop a running container +`docker stop ` + +Remove a container +`docker rm ` + +Remove all containers +`docker rm $(docker ps -a -q)` diff --git a/src/docker/first-side/column2.md b/src/docker/first-side/column2.md new file mode 100644 index 0000000..fdb5cec --- /dev/null +++ b/src/docker/first-side/column2.md @@ -0,0 +1,37 @@ +# Manage images + +Build an image from a Dockerfile +`docker build -t -f ` + +Search an image on Dockerhub +`docker search ` + +Pull an image from Dockerhub +`docker pull ` + +List all local images +`docker images` + +Remove an image +`docker rmi ` + +Remove all images +`docker rmi $(docker images -q)` + +Login to a registry +`docker login ` + +Pull an image from a registry +`docker pull /` + +Push an image to a registry +`docker push /` + +Save container state to an image +`docker commit