[
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2018 Anton Bagaiev\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Docker bootstrap collection\n\nHowdy! This is Docker bootstrap templates to start your new applications faster.\n\n## Table of contents\n\nBasic web applications:\n\n* [Classic LNMP server](https://github.com/abagayev/docker-bootstrap-collection/tree/master/lnmp-server) \n* [Command line PHP](https://github.com/abagayev/docker-bootstrap-collection/tree/master/php-cli)\n* [Simple static server for JS apps](https://github.com/abagayev/docker-bootstrap-collection/tree/master/static-server)\n\nBasic databases and customization:\n\n* [MySQL with few databases](https://github.com/abagayev/docker-bootstrap-collection/tree/master/mysql-few-databases)\n* [DynamoDB for local development](https://github.com/abagayev/docker-bootstrap-collection/tree/master/dynamodb-local)\n\nOperations and service observability:\n\n* [Private Docker Registry](https://github.com/abagayev/docker-bootstrap-collection/tree/master/docker-registry)\n* [Filebeat configuration](https://github.com/abagayev/docker-bootstrap-collection/tree/master/filebeat-logz-io)\n* [Multiple docker compose services with common network](https://github.com/abagayev/docker-bootstrap-collection/tree/master/multiple-services-with-common-network)\n\nTips and hacks:\n\n* [Crontab in container](https://github.com/abagayev/docker-bootstrap-collection/tree/master/crontab-in-container)\n* [Makefile example](https://github.com/abagayev/docker-bootstrap-collection/tree/master/makefile-example)\n\n## Also\n\nFeel free to add comments, issues, pull requests or buy me a coffee:  \nhttps://www.buymeacoffee.com/tonybug\n"
  },
  {
    "path": "crontab-in-container/README.md",
    "content": "# Crontab in docker compose example\n\nTo enable crontab in your docker compose you need to use docker image with preinstalled cron and share crontab schedule in volumes.  \nTo try this example you need to up your compose and see date appending to the logs file every minute. \n\n```shell\ndocker-compose up -d\ncat logs/cron.log\n```\n\nPlease don't forget to leave a blank line in the end of file.\n"
  },
  {
    "path": "crontab-in-container/docker/cron/app",
    "content": "# let's append current date to the log file every minute for a test\n* * * * * root /bin/echo Hello from `date` >> /tmp/logs/cron.log\n"
  },
  {
    "path": "crontab-in-container/docker-compose.yml",
    "content": "app:\n  image: webdevops/php-nginx\n  volumes:\n    - ./docker/cron:/etc/cron.d\n    - ./logs:/tmp/logs\n"
  },
  {
    "path": "docker-registry/Readme.md",
    "content": "# Private Docker Registry\n\nRun your registry with Docker compose, generate a login/password keys and login with new credentials:\n\n```bash\ndocker-compose up -d\nhtpasswd -Bbn user pass > auth/htpasswd\ndocker login https://0.0.0.0:443\n```\n\nThen try to pull, tag and push an image to your new registry\n\n```bash\ndocker pull ubuntu\ndocker tag ubuntu 0.0.0.0:5000/bubuntu\ndocker push 0.0.0.0:443/bubuntu\n```\n\nIf you are having trouble with message like `server gave HTTP response to HTTPS client`, just follow this link: \nhttps://stackoverflow.com/questions/38695515/can-not-pull-push-images-after-update-docker-to-1-12\n"
  },
  {
    "path": "docker-registry/auth/htpasswd",
    "content": "user:$2y$05$cCibwxM8hHEijvPgmpk9he9nhxCiyPrw0CFLFVEwZUO.ImGuBM5hW\n"
  },
  {
    "path": "docker-registry/docker-compose.yml",
    "content": "registry:\n  image: registry:2\n  ports:\n    - 443:5000\n  environment:\n    REGISTRY_AUTH: htpasswd\n    REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd\n    REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm\n  volumes:\n    - ./registry:/var/lib/registry\n    - ./auth:/auth\n"
  },
  {
    "path": "dynamodb-local/README.md",
    "content": "# DynamoDB for local development\n\nIf you need DynamoDB at your project, just use this docker compose to add it to your environment.\n\nAlso, this is configured to store data at volume, if you need it to store data in memory, just remove volumes and command directives.\n\nAlso, this can be helpful for you:    \nhttps://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html\n"
  },
  {
    "path": "dynamodb-local/docker-compose.yml",
    "content": "version: \"3\"\n\nservices:\n  dynamodb:\n    image: amazon/dynamodb-local\n    volumes:\n    - dynamodb:/home/dynamodblocal\n    command: [\n      \"-jar\",\n      \"DynamoDBLocal.jar\",\n      \"-sharedDb\",\n      \"-dbPath\",\n      \".\"\n    ]\n\nvolumes:\n  dynamodb:\n    driver: local\n"
  },
  {
    "path": "filebeat-logz-io/README.md",
    "content": "# Filebeat configuration\n\nThis is an example of how to run Filebeat via Docker to send logs of your application to ELK stack at provider like [logz.io](https://logz.io).  \n\nTo make things work, do the next to prepare:\n\n1. Create your configuration (or generate it with [configuration wizard](https://app.logz.io/#/dashboard/data-sources/Filebeat)) and store it to `filebeat.yml`\n\n2. Add your logs directories to the list of volumes (or just try example logs prepared in _logs_ directiry)\n\n3. Create certificates directory and download certificate\n   \n\n```shell\nmkdir -p cert && curl https://raw.githubusercontent.com/logzio/public-certificates/master/COMODORSADomainValidationSecureServerCA.crt > cert/COMODORSADomainValidationSecureServerCA.crt\n```\n\nFinally, run docker compose and check your ELK:\n\n```shell\ndocker-compose up -d\n```\n\nCan you see any logs? I hope you do."
  },
  {
    "path": "filebeat-logz-io/docker-compose.yaml",
    "content": "version: \"3\"\n\nservices:\n  filebeat:\n    image: docker.elastic.co/beats/filebeat:7.6.1\n    volumes:\n    # filebeat configuration\n    - \"./filebeat.yml:/usr/share/filebeat/filebeat.yml:ro\"\n\n    # add your logs directories here\n    - \"./logs:/var/logs:ro\"\n\n    # install certificate\n    - \"./cert:/etc/pki/tls/certs:ro\"\n\n    # store filebeat data and don't lose it on container restart\n    - \"filebeat_data:/var/lib/filebeat:rw\"\n\nvolumes:\n  filebeat_data:\n    driver: local\n"
  },
  {
    "path": "filebeat-logz-io/filebeat.yml",
    "content": "############################# Filebeat #####################################\n\nfilebeat.inputs:\n\n- type: log\n  paths:\n  - /var/logs/*.log\n  fields:\n    logzio_codec: plain\n    token: %LOGZ_TOKEN%\n    type: nginx\n  fields_under_root: true\n  encoding: utf-8\n  ignore_older: 3h\n\n#For version 7 and higher\nfilebeat.registry.path: /var/lib/filebeat\n\n#The following processors are to ensure compatibility with version 7\nprocessors:\n- rename:\n    fields:\n    - from: \"agent\"\n      to: \"beat_agent\"\n    ignore_missing: true\n- rename:\n    fields:\n    - from: \"log.file.path\"\n      to: \"source\"\n    ignore_missing: true\n\n############################# Output ##########################################\n\noutput:\n  logstash:\n    hosts: [\"listener.logz.io:5015\"]\n    ssl:\n      certificate_authorities: ['/etc/pki/tls/certs/COMODORSADomainValidationSecureServerCA.crt']\n"
  },
  {
    "path": "filebeat-logz-io/logs/example.log",
    "content": "{\"@timestamp\":\"2020–03–11T12:00:00.00+00:00\",\"message\":\"This is a test message, can't you see it?\", \"level\":\"INFO\"}\n{\"@timestamp\":\"2020–03–11T13:00:00.00+00:00\",\"message\":\"This is a test message number two, can't you see it too?\", \"level\":\"INFO\"}\n{\"@timestamp\":\"2020–03–11T14:00:00.00+00:00\",\"message\":\"This is a test message number three, can't you see a tree?\", \"level\":\"WARNING\"}\n"
  },
  {
    "path": "lnmp-server/.gitignore",
    "content": "/docker/volumes\n/vendor\n"
  },
  {
    "path": "lnmp-server/README.md",
    "content": "# Classic LNMP server\n\nThis is an example of classic LNMP application(linux, nginx, mysql, php). Just add this docker-compose file to your application, change mysql credentials and you are ready to go. \n\nTo build and test service use next command and check your application reaching [localhost](http://localhost): \n\n```shell\ndocker-compose up -d\ndocker-compose exec app composer install\n```\n\nTo connect with MySQL use next credentials(or change them in docker-compose):\n\n```\nMYSQL_HOST: db\nMYSQL_PORT: 3306\nMYSQL_DATABASE: lnmp\nMYSQL_USER: root\nMYSQL_PASSWORD: local\n```\n\nIf you want to connect to MySQL from outside(for example, with your IDE), use `localhost` for a host and port `3308` instead.\n"
  },
  {
    "path": "lnmp-server/composer.json",
    "content": "{\n    \"require\": {\n    },\n    \"require-dev\": {\n        \"fzaninotto/faker\": \"^1.7\"\n    }\n}\n"
  },
  {
    "path": "lnmp-server/docker-compose.yml",
    "content": "app:\n  image: webdevops/php-nginx-dev:7.1\n  ports:\n    - \"80:80\"\n  volumes:\n  - .:/app\n  working_dir: /app\n  environment:\n    WEB_DOCUMENT_ROOT: /app/public\n    PHP_DEBUGGER: xdebug\n    PHP_IDE_CONFIG: serverName=lnmp-server\n    XDEBUG_CONFIG: idekey=PHPSTORM\n    XDEBUG_REMOTE_AUTOSTART: 1\n    XDEBUG_REMOTE_CONNECT_BACK: 0\n    XDEBUG_REMOTE_ENABLE: 1\n    XDEBUG_REMOTE_HOST: docker.for.mac.localhost # 172.17.0.1 for linux users\n    XDEBUG_PROFILER_ENABLE: 0\n  links:\n    - db\n\ndb:\n  image: mysql:latest\n  command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci\n  ports:\n    - \"3308:3306\"\n  volumes:\n    - ./docker/volumes/db:/var/lib/mysql\n  restart: always\n  environment:\n    MYSQL_DATABASE: lnmp\n    MYSQL_USER: root\n    MYSQL_PASSWORD: local\n    MYSQL_ROOT_PASSWORD: local\n"
  },
  {
    "path": "lnmp-server/public/index.php",
    "content": "<?php\n\nrequire_once '/app/vendor/autoload.php';\n\n$faker = Faker\\Factory::create();\n$name = $faker->name;\n\necho 'Hello, my name is ', $name, PHP_EOL;\n"
  },
  {
    "path": "makefile-example/Makefile",
    "content": "up:\n\tdocker-compose up -d\n\nps:\n\tdocker-compose ps\n\nstop:\n\tdocker-compose stop\n\n# combine two directives in one\nrestart: stop up\n\nbash:\n\tdocker-compose exec app bash\n"
  },
  {
    "path": "makefile-example/README.md",
    "content": "# Makefile example\n\nMakefile is a powerful tool to manage your containers and services easier.    \n\nIt is good to make shortcuts with commands like docker-compose and running container scripts like migrations, provision, configuration.\n\nFor example, with Makefile in this folder, you can do the next: \n\n```shell\nmake up\nmake ps\nmake stop\nmake restart\nmake bash\n```\n\nOr even combine few directives from the command line, this will run your containers, show the list of them and get you inside of your app:\n\n```shell\nmake up ps bash\n```\n\nPlease notice that make is not installed as default, try this for ubuntu:\n \n```shell\napt-get update && apt-get install build-essential\n```\n"
  },
  {
    "path": "makefile-example/docker-compose.yml",
    "content": "app:\n  image: nginx\n"
  },
  {
    "path": "multiple-services-with-common-network/Readme.md",
    "content": "# Multiple docker compose services with common network\n\nSometimes it is needed to share some resources between few docker compose services. For example, you are creating microservices with common database.  \n\nTo reach resource hosted on other service you need to create docker network and configure it as external network for both services.\n\nIn this example we are creating common network, master service with nginx and slave service with curl, witch can call nginx resource as well. \n\n```bash\n# create and check network\ndocker network create services-common-network\ndocker network ls | grep services-common-network\n \n# create master service\ndocker-compose -f master/docker-compose.yml up -d\n \n# create slave service and test master nginx from slave\ndocker-compose -f slave/docker-compose.yml up -d\ndocker-compose -f slave/docker-compose.yml run alpine-curl nginx\n```\n\nTo remove network you need to stop your services first (you can't remove network with active endpoints). \n\n```bash\ndocker-compose -f master/docker-compose.yml stop\ndocker-compose -f slave/docker-compose.yml stop\ndocker network rm services-common-network\n```\n"
  },
  {
    "path": "multiple-services-with-common-network/master/docker-compose.yml",
    "content": "version: '3'\n\nnetworks:\n    services-common-network:\n        external: true\n\nservices:\n    nginx:\n        image: nginx\n        volumes:\n          - ./public:/usr/share/nginx/html\n        networks:\n          - services-common-network\n"
  },
  {
    "path": "multiple-services-with-common-network/master/public/index.html",
    "content": "<h2>It works!</h2>\n"
  },
  {
    "path": "multiple-services-with-common-network/slave/docker-compose.yml",
    "content": "version: '3'\n\nnetworks:\n    services-common-network:\n        external: true\n\nservices:\n    alpine-curl:\n        image: byrnedo/alpine-curl\n        networks:\n          - services-common-network\n"
  },
  {
    "path": "mysql-few-databases/README.md",
    "content": "# MySQL with few databases\n\nThis is an example of MySQL container with few databases.\n\nDefault MySQL image can create only one database out of the box, but we can customize it, adding SQL files to `/docker-entrypoint-initdb.d` directory.\n\nPlease notice, that MySQL will run these files only on container creation, and will not call them on next container start.\n\nIn this example we added SQL file with commands to run on container creation and create databases and grant all rights to them. We can create service and login inside mysql container to check out fresh databases:  \n\n```bash\n# start service\ndocker-compose up -d\n \n# login to database and type password 'local'\ndocker-compose exec db mysql -uroot -p -e 'SHOW DATABASES;'\n``` \n\nThat's it!\n"
  },
  {
    "path": "mysql-few-databases/docker/provision/mysql/init/01-databases.sql",
    "content": "-- create databases\nCREATE DATABASE IF NOT EXISTS `primary`;\nCREATE DATABASE IF NOT EXISTS `secondary`;\n\n-- create root user and grant rights\nCREATE USER 'root'@'localhost' IDENTIFIED BY 'local';\nGRANT ALL ON *.* TO 'root'@'localhost';\n"
  },
  {
    "path": "mysql-few-databases/docker-compose.yml",
    "content": "version: '3'\n\nvolumes:\n    db:\n        driver: local\n\nservices:\n    db:\n        image: mysql:5.7\n        command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci\n        volumes:\n          - ./docker/provision/mysql/init:/docker-entrypoint-initdb.d\n        environment:\n          MYSQL_ROOT_PASSWORD: local\n"
  },
  {
    "path": "php-cli/Readme.md",
    "content": "# Command line PHP\n\nThis is an example of basic PHP CLI with Xdebug installed. You can use it to develop terminal PHP applications from scratch. \n\nTo build and test php cli service use next command: \n\n```shell\ndocker-compose up -d\ndocker-compose exec cli php sum.php 1 2 3\n# Sum of your arguments is 6\n```\n"
  },
  {
    "path": "php-cli/app/sum.php",
    "content": "<?php\n\n$sum = array_sum($argv);\n$message = \"Sum of your arguments is $sum\";\n\necho $message, PHP_EOL;\n"
  },
  {
    "path": "php-cli/docker-compose.yml",
    "content": "cli:\n  image: webdevops/php-dev\n  volumes:\n  - ./app:/app\n  working_dir: /app\n  environment:\n    PHP_IDE_CONFIG: serverName=php-cli\n    XDEBUG_CONFIG: idekey=PHPSTORM\n    XDEBUG_REMOTE_AUTOSTART: 1\n    XDEBUG_REMOTE_CONNECT_BACK: 0\n    XDEBUG_REMOTE_ENABLE: 1\n    XDEBUG_REMOTE_HOST: docker.for.mac.localhost # 172.17.0.1 for linux users\n    XDEBUG_PROFILER_ENABLE: 0\n"
  },
  {
    "path": "static-server/.babelrc",
    "content": "{\n  \"presets\": [\n    \"env\"\n  ]\n}"
  },
  {
    "path": "static-server/.gitignore",
    "content": "public/dist\nnode_modules\n"
  },
  {
    "path": "static-server/Dockerfile",
    "content": "FROM node:8.10\n\nARG BUILD_ID\nENV BUILD_ID ${BUILD_ID:-0}\n\nCOPY . ./app/\nWORKDIR /app/\n\nRUN apt-get update\nRUN npm install\n\nCMD [\"npm\", \"run\", \"build\"]\n"
  },
  {
    "path": "static-server/Readme.md",
    "content": "# Simple static server for JS apps\n\nThis is an example of static server with nginx and npm dependencies, webpack and babel. You can build and run your server calling next commands: \n\n```shell\ndocker-compose build\ndocker-compose up -d\n```\n\nNow you can open your application opening [localhost in browser](http://localhost). \n\nAnd you are ready to develop. Run watch script and it will update application automatically: \n\n```shell\ndocker-compose run node npm run-script watch\n```\n"
  },
  {
    "path": "static-server/docker-compose.yml",
    "content": "nginx:\n  image: nginx:latest\n  working_dir: /usr/share/nginx/html\n  ports:\n    - \"80:80\"\n  volumes:\n    - ./public:/usr/share/nginx/html\n  links:\n    - node\n\nnode:\n  build: .\n  working_dir: /usr/src/app\n  volumes:\n   - .:/usr/src/app\n  environment:\n   BUILD_ID: 1\n\n"
  },
  {
    "path": "static-server/package.json",
    "content": "{\n  \"name\": \"app\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"build\": \"webpack\",\n    \"dev\": \"webpack --mode development\",\n    \"watch\": \"webpack --watch\"\n  },\n  \"keywords\": [],\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"dependencies\": {\n    \"babel-core\": \"^6.26.0\",\n    \"babel-loader\": \"^7.1.4\",\n    \"babel-preset-env\": \"^1.6.1\",\n    \"babel-preset-es2015\": \"^6.24.1\",\n    \"browser-cookies\": \"^1.2.0\",\n    \"webpack\": \"^4.2.0\",\n    \"webpack-cli\": \"^2.0.13\"\n  }\n}\n"
  },
  {
    "path": "static-server/public/index.html",
    "content": "<!-- Your document -->\n<h2>Hello</h2>\n<p>Last time you was here <b id=\"last_visit\">...</b></p>\n\n<!-- Javascript SDK from CDN -->\n<script type=\"text/javascript\" src=\"dist/main.js\"></script>\n<script type=\"text/javascript\">\n    // show last visit time\n    var last_visit = myApp.getLastVisit() || \"never\";\n    document.getElementById(\"last_visit\").textContent = last_visit;\n\n    // set last visit time to now\n    myApp.setLastVisit();\n</script>\n"
  },
  {
    "path": "static-server/src/index.js",
    "content": "import cookies from \"browser-cookies\";\n\nglobal.myApp = {\n    // get last visit date from cookies\n    getLastVisit: () => {\n        const last_visit = cookies.get(\"last_visit\");\n\n        return last_visit;\n    },\n\n    // set last visit value\n    setLastVisit: (value) => {\n        cookies.set(\"last_visit\", value || (new Date()).toISOString(), {\n            expires: 365\n        });\n    }\n};\n"
  },
  {
    "path": "static-server/webpack.config.js",
    "content": "var webpack = require('webpack');\n\nmodule.exports = {\n    output: {\n        path:  __dirname + \"/public/dist\",\n        filename: \"main.js\"\n    },\n    module: {\n        rules: [\n            {\n                test: /\\.js$/,\n                exclude: /node_modules/,\n                use: {\n                    loader: \"babel-loader\"\n                }\n            }\n        ]\n    },\n    plugins: [\n        new webpack.DefinePlugin({\n            'SDK_BUILD_ID': JSON.stringify(process.env.BUILD_ID),\n        })\n    ]\n};\n"
  }
]