This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| STACK_NAME=$1 | |
| if [ -z "$STACK_NAME" ]; then | |
| echo "Usage: $0 <stack_name>" | |
| exit 1 | |
| fi | |
| services=$(docker stack services $STACK_NAME --format '{{.Name}}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| - hosts: all | |
| become: true | |
| vars: | |
| container_count: 4 | |
| default_container_name: docker | |
| default_container_image: ubuntu | |
| default_container_command: sleep 1d | |
| tasks: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| http { | |
| limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m; | |
| # Define a zone to track requests from each IP | |
| limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=10r/s; | |
| server { | |
| listen 80; | |
| server_name example.com; | |
| # Rate limit requests | |
| limit_req zone=req_limit_per_ip burst=20; | |
| # Limit maximum number of connections from a single IP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| docker service create --name shepherd \ | |
| --constraint "node.role==manager" \ | |
| --env SLEEP_TIME="2m" \ | |
| --env ROLLBACK_ON_FAILURE="true" \ | |
| --env IMAGE_AUTOCLEAN_LIMIT="5" \ | |
| --env UPDATE_OPTIONS="--update-delay=30s" \ | |
| --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock,ro \ | |
| containrrr/shepherd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| apt-get upgrade -y | |
| apt-get install ca-certificates curl gnupg lsb-release | |
| mkdir -p /etc/apt/keyrings | |
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg | |
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ | |
| $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
| apt-get install apache2 | |
| apt-get update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| const path = require('path'); | |
| // Recursive function to get all .ts and .js files in a directory | |
| function getFiles(dir) { | |
| let files = []; | |
| fs.readdirSync(dir).forEach(file => { | |
| const filePath = path.join(dir, file); | |
| const stats = fs.statSync(filePath); | |
| if (stats.isDirectory()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| const path = require('path'); | |
| function countLinesInFile(file) { | |
| const content = fs.readFileSync(file, 'utf8'); | |
| return content.split('\n').length; | |
| } | |
| function countLinesInDirectory(dir) { | |
| let totalLines = 0; |
NewerOlder