├── .editorconfig ├── .env.template ├── .github ├── CODE_OF_CONDUCT.md └── workflows │ ├── .github-ci.yml │ └── release.yml ├── .gitignore ├── .work ├── README.md ├── config │ ├── .env.amd64 │ ├── .env.arm64 │ └── docker-compose.yml ├── extra │ ├── doc │ │ ├── 1.WHY_SPARROW_EN.md │ │ ├── 1.WHY_SPARROW_ZH.md │ │ ├── 2.USAGE_EN.md │ │ ├── 2.USAGE_ZH.md │ │ ├── 3.DEVELOPMENT_EN.md │ │ ├── 3.DEVELOPMENT_ZH.md │ │ ├── 4.HOW_TO_CONTRIBUTE_EN.md │ │ ├── 4.HOW_TO_CONTRIBUTE_ZH.md │ │ ├── 5.QA_EN.md │ │ └── 5.QA_ZH.md │ ├── ide │ │ ├── jetbrains │ │ │ └── sparrow.iml │ │ └── vscode │ │ │ ├── launch.json │ │ │ ├── setting.json │ │ │ └── vscode.code-profile │ └── service_example │ │ ├── .env │ │ ├── README.md │ │ ├── docker-compose.yml │ │ ├── hooks │ │ ├── README.md │ │ ├── after_start.sh │ │ ├── after_stop.sh │ │ ├── before_start.sh │ │ └── before_stop.sh │ │ ├── init │ │ └── README.md │ │ ├── make_app_image │ │ ├── Dockerfile │ │ ├── README.md │ │ └── run.sh │ │ ├── make_basic_image │ │ ├── Dockerfile │ │ ├── README.md │ │ └── run.sh │ │ └── templates │ │ └── README.md ├── include │ ├── internal │ │ ├── constant.sh │ │ ├── dockerhub.sh │ │ └── helper.sh │ └── sdk.sh └── test │ └── run.sh ├── CHANGELOG.md ├── LICENSE ├── README.md ├── README.zh-CN.md ├── _install.sh ├── _uninstall.sh ├── _update.sh ├── azkaban ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ └── README.md ├── difylocal ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ ├── .env_of_api │ ├── .env_of_web │ ├── README.md │ └── start_local.sh ├── django ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ └── README.md ├── elasticsearch ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ └── README.md ├── etcd ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ └── README.md ├── etcdkeeper ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ └── README.md ├── go ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ ├── README.md │ ├── go.mod │ └── main.go ├── grafana ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ └── README.md ├── jupyter ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ └── README.md ├── kafka ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ └── README.md ├── kafkaui ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ ├── README.md │ └── config.yml ├── kibana ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ ├── README.md │ └── kibana.yml ├── langchain ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ ├── README.md │ └── init.sh ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ └── README.md ├── mongodb ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ ├── README.md │ └── mongod.conf ├── mysql ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ ├── README.md │ ├── init.sh │ └── init.sql ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ ├── README.md │ └── my.cnf ├── nacos ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ ├── README.md │ └── application.properties ├── nginx ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ ├── README.md │ ├── logrotate │ └── nginx │ ├── nginx.conf │ ├── sites │ ├── goproxy.conf.template │ ├── phpproxy.conf.template │ └── pythonproxy.conf.template │ └── startup.sh ├── nodejs ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ └── README.md ├── phpfpm ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── init.sh ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ ├── README.md │ ├── composer-installer.php │ ├── php7.3.ini │ ├── xdebug.ini │ └── xhprof.ini ├── postgres ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ └── README.md ├── prometheus ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ ├── README.md │ └── prometheus.yml ├── prompthub ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ ├── README.md │ ├── deepset-zero-shot-react.md │ └── deepset-zero-shot-react.yaml ├── python ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ └── README.md ├── redis ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ ├── README.md │ └── redis.conf ├── sparrow ├── sparrowtool ├── ssdb ├── .env ├── README.md ├── docker-compose.yml ├── hooks │ ├── README.md │ ├── after_start.sh │ ├── after_stop.sh │ ├── before_start.sh │ └── before_stop.sh ├── init │ └── README.md ├── make_app_image │ ├── Dockerfile │ ├── README.md │ └── run.sh ├── make_basic_image │ ├── Dockerfile │ ├── README.md │ └── run.sh └── templates │ ├── README.md │ └── ssdb.conf └── zookeeper ├── .env ├── README.md ├── docker-compose.yml ├── hooks ├── README.md ├── after_start.sh ├── after_stop.sh ├── before_start.sh └── before_stop.sh ├── init └── README.md ├── make_app_image ├── Dockerfile ├── README.md └── run.sh ├── make_basic_image ├── Dockerfile ├── README.md └── run.sh └── templates └── README.md /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | [*] 8 | charset = utf-8 9 | 10 | [{Dockerfile,docker-compose.yml}] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. 4 | 5 | Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. 6 | 7 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. 8 | 9 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. 10 | 11 | This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/) 12 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | push: 4 | branches: 5 | - main 6 | 7 | jobs: 8 | release-please: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: GoogleCloudPlatform/release-please-action@v3 12 | id: release 13 | with: 14 | token: ${{ secrets.RELEASE_TOKEN }} 15 | release-type: node 16 | package-name: posture 17 | changelog-types: '[{"type": "types", "section":"Types", "hidden": false},{"type": "revert", "section":"Reverts", "hidden": false},{"type": "feat", "section": "Features", "hidden": false},{"type": "fix", "section": "Bug Fixes", "hidden": false},{"type": "improvement", "section": "Feature Improvements", "hidden": false},{"type": "docs", "section":"Docs", "hidden": false},{"type": "doc", "section":"Docs", "hidden": false},{"type": "style", "section":"Styling", "hidden": false},{"type": "refactor", "section":"Code Refactoring", "hidden": false},{"type": "perf", "section":"Performance Improvements", "hidden": false},{"type": "test", "section":"Tests", "hidden": false},{"type": "build", "section":"Build System", "hidden": false},{"type": "ci", "section":"CI", "hidden":false},{"type": "update", "section":"Update", "hidden":false}]' 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore system. 2 | .DS_Store 3 | .idea/ 4 | *.swp 5 | 6 | # ignore golang. 7 | go.sum 8 | 9 | # ignore nginx. 10 | nginx/templates/sites/* 11 | !nginx/templates/sites/goproxy.conf.template 12 | !nginx/templates/sites/phpproxy.conf.template 13 | !nginx/templates/sites/pythonproxy.conf.template 14 | 15 | # ignore all logs. 16 | */logs/* 17 | !*/logs/README.md 18 | 19 | # ignore all conf. 20 | */conf/* 21 | !*/conf/README.md 22 | 23 | # ignore any directory in the 'data' directory (include the sub directories). 24 | data/ 25 | 26 | # ignore /env and /docker-compose.yml file in the root directory. 27 | /.env 28 | /docker-compose.yml 29 | -------------------------------------------------------------------------------- /.work/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the workspace for sparrow project. 3 | -------------------------------------------------------------------------------- /.work/config/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | networks: 4 | backend: 5 | driver: ${NETWORKS_DRIVER} 6 | 7 | services: 8 | -------------------------------------------------------------------------------- /.work/extra/doc/3.DEVELOPMENT_ZH.md: -------------------------------------------------------------------------------- 1 |

开发文档

2 | -------------------------------------------------------------------------------- /.work/extra/doc/4.HOW_TO_CONTRIBUTE_EN.md: -------------------------------------------------------------------------------- 1 |

How to Contribute

2 | -------------------------------------------------------------------------------- /.work/extra/doc/4.HOW_TO_CONTRIBUTE_ZH.md: -------------------------------------------------------------------------------- 1 |

如何贡献

2 | -------------------------------------------------------------------------------- /.work/extra/doc/5.QA_ZH.md: -------------------------------------------------------------------------------- 1 |

常见问题

2 | -------------------------------------------------------------------------------- /.work/extra/ide/jetbrains/sparrow.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.work/extra/ide/vscode/setting.json: -------------------------------------------------------------------------------- 1 | { 2 | "workbench.colorTheme": "Default Dark Modern", 3 | "terminal.integrated.shell.linux": "/bin/zsh", 4 | "terminal.integrated.shell.osx":"/bin/zsh", 5 | "terminal.integrated.fontFamily": "", 6 | "editor.fontFamily": "Menlo, Monaco, 'Courier New', monospace,Meslo LG L for Powerline", 7 | "php.validate.executablePath": "/usr/local/bin/php7.4", 8 | "debug.allowBreakpointsEverywhere": true, 9 | "shellcheck.ignorePatterns": { 10 | "**/*.env.*": true 11 | }, 12 | "intelephense.phpdoc.propertyTemplate": { 13 | 14 | "summary": "$1", 15 | "tags": [ 16 | "@var ${1:$SYMBOL_TYPE}" 17 | ] 18 | }, 19 | "php-docblocker.author": { 20 | 21 | "name": "", 22 | "email": "" 23 | }, 24 | "php-docblocker.extra": [ 25 | "@Description" 26 | ] 27 | } -------------------------------------------------------------------------------- /.work/extra/service_example/.env: -------------------------------------------------------------------------------- 1 | ### {{SERVICE}} ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_{{SERVICE_UPPER}}_NAME=test/test 6 | IMAGE_OFFICIAL_{{SERVICE_UPPER}}_VERSION={{IMAGE_BASIC_VERSION}} 7 | # basic image 8 | IMAGE_BASIC_{{SERVICE_UPPER}}_VERSION={{IMAGE_BASIC_VERSION}} 9 | # app image 10 | IMAGE_APP_{{SERVICE_UPPER}}_VERSION={{IMAGE_APP_VERSION}} 11 | # -------------- service config -------------- 12 | {{SERVICE_UPPER}}_HOST_PORT={{SERVICE_PORT}} 13 | {{SERVICE_UPPER}}_CONTAINER_PORT={{SERVICE_PORT}} 14 | -------------------------------------------------------------------------------- /.work/extra/service_example/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### {{SERVICE}} ######################################################### 3 | {{SERVICE}}: 4 | hostname: {{SERVICE}} 5 | image: sparrow-app-{{SERVICE}}:${IMAGE_APP_{{SERVICE_UPPER}}_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_{{SERVICE}} 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./{{SERVICE}}/:/home/sparrow/{{SERVICE}}/ 15 | - ./{{SERVICE}}/data/:/var/data/{{SERVICE}}/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${{{SERVICE_UPPER}}_HOST_PORT}:${{{SERVICE_UPPER}}_CONTAINER_PORT}" 19 | networks: 20 | - backend 21 | # only for debug 22 | # command: "tail -f /dev/null" 23 | -------------------------------------------------------------------------------- /.work/extra/service_example/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /.work/extra/service_example/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /.work/extra/service_example/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /.work/extra/service_example/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /.work/extra/service_example/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /.work/extra/service_example/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /.work/extra/service_example/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_{{SERVICE_UPPER}}_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-{{SERVICE}}:${IMAGE_BASIC_{{SERVICE_UPPER}}_VERSION} 4 | -------------------------------------------------------------------------------- /.work/extra/service_example/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /.work/extra/service_example/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="{{SERVICE}}" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_{{SERVICE_UPPER}}_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_{{SERVICE_UPPER}}_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_{{SERVICE_UPPER}}_VERSION=${IMAGE_BASIC_{{SERVICE_UPPER}}_VERSION} \ 24 | \ 25 | -f ./make_app_image/Dockerfile \ 26 | -t sparrow-app-$service_name:${IMAGE_APP_{{SERVICE_UPPER}}_VERSION} . ; then 27 | print_error "build image failed" 28 | exit 1 29 | fi 30 | 31 | cd ../ 32 | -------------------------------------------------------------------------------- /.work/extra/service_example/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_{{SERVICE_UPPER}}_NAME 3 | ARG IMAGE_OFFICIAL_{{SERVICE_UPPER}}_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_{{SERVICE_UPPER}}_NAME}:${IMAGE_OFFICIAL_{{SERVICE_UPPER}}_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /.work/extra/service_example/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /.work/extra/service_example/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="{{SERVICE}}" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_{{SERVICE_UPPER}}_NAME=${IMAGE_OFFICIAL_{{SERVICE_UPPER}}_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_{{SERVICE_UPPER}}_VERSION=${IMAGE_OFFICIAL_{{SERVICE_UPPER}}_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_{{SERVICE_UPPER}}_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /.work/extra/service_example/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /.work/include/internal/constant.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # only define variables, these variables may used defined environment variables in /env file. 8 | 9 | # defined different hook type. 10 | CONST_HOOK_BEFORE_START="before_start" 11 | CONST_HOOK_AFTER_START="after_start" 12 | CONST_HOOK_BEFORE_STOP="before_stop" 13 | CONST_HOOK_AFTER_STOP="after_stop" 14 | 15 | # defined dir 16 | CONST_SERVICE_EXAMPLE_DIR=".work/extra/service_example/" 17 | 18 | # defined different config files. 19 | CONST_BASE_CONFIG_ENV_AMD64_FILE=".work/config/.env.amd64" 20 | CONST_BASE_CONFIG_ENV_ARM64_FILE=".work/config/.env.arm64" 21 | CONST_BASE_CONFIG_COMPOSE_FILE=".work/config/docker-compose.yml" 22 | CONST_SPARROW_CONFIG_ENV_FILE=".env" 23 | CONST_SPARROW_CONFIG_COMPOSE_FILE="docker-compose.yml" 24 | 25 | # define some default values 26 | CONST_DEFAULT_DOCKERHUB_REPO="docker.io/lvsid" 27 | -------------------------------------------------------------------------------- /.work/include/sdk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # only include defined variables and functions. 8 | # this is no side effects. 9 | . .work/include/internal/constant.sh 10 | . .work/include/internal/helper.sh 11 | . .work/include/internal/dockerhub.sh 12 | 13 | # update /env file and export env variables. 14 | if ! upenv; then 15 | print_error "upenv error: upenv failed" 16 | exit 1 17 | fi 18 | 19 | # update /docker-compose.yml file. 20 | if ! upcompose; then 21 | print_error "upcompose error: upcompose failed" 22 | exit 1 23 | fi 24 | -------------------------------------------------------------------------------- /.work/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # define the base path of project. 4 | CUR_PATH=$(cd "$(dirname "$0")" && cd ../../ && pwd) 5 | SPARROW_BASE_PATH=$CUR_PATH 6 | 7 | # cd base dir of project. 8 | # the process is in the same shell as the starting shell. 9 | cd $SPARROW_BASE_PATH 10 | 11 | # include sdk of sparrow. 12 | . .work/include/sdk.sh 13 | 14 | sleep_seconds 3 15 | 16 | testhttp() { 17 | if is_mac; then 18 | # open websites. 19 | open "http://127.0.0.1:${ETCDKEEPER_HOST_PORT}/etcdkeeper/" # etcdkeeper 20 | open "http://127.0.0.1:${KAFKAUI_HOST_PORT}/" # kafkaui 21 | open "http://127.0.0.1:${PROMETHEUS_HOST_PORT}/targets" # prometheus 22 | open "http://127.0.0.1:${PROMETHEUS_HOST_PORT}/graph" # prometheus 23 | open "http://127.0.0.1:${GRAFANA_HOST_PORT}/graph" # prometheus 24 | open "http://127.0.0.1:${GRAFANA_HOST_PORT}/api/v1/query" # prometheus 25 | fi 26 | } 27 | # testhttp 28 | 29 | echo "test search" 30 | for service in "${ENABLE_SERVICE_LIST[@]}"; do 31 | image="sparrow-basic-${service}" 32 | search "$DOCKERHUB_REPO/$image" 33 | image="sparrow-app-${service}" 34 | search "$DOCKERHUB_REPO/$image" 35 | done 36 | 37 | printf "UnitTest Success" 38 | exit 0 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 WGrape 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /azkaban/.env: -------------------------------------------------------------------------------- 1 | ### azkaban ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_AZKABAN_NAME=centos 6 | IMAGE_OFFICIAL_AZKABAN_VERSION=8.4.2105 7 | # basic image 8 | IMAGE_BASIC_AZKABAN_VERSION=0.0.1 9 | # app image 10 | IMAGE_APP_AZKABAN_VERSION=latest 11 | # -------------- service config -------------- 12 | AZKABAN_HOST_PORT=4500 13 | AZKABAN_CONTAINER_PORT=8081 14 | -------------------------------------------------------------------------------- /azkaban/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### azkaban ######################################################### 3 | azkaban: 4 | hostname: azkaban 5 | image: sparrow-app-azkaban:${IMAGE_APP_AZKABAN_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_azkaban 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./azkaban/:/home/sparrow/azkaban/ 15 | - ./azkaban/data/:/var/data/azkaban/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${AZKABAN_HOST_PORT}:${AZKABAN_CONTAINER_PORT}" 19 | networks: 20 | - backend 21 | # only for debug 22 | # Since it(/bin/start-solo.sh) will start a process in the background and exit directly, resulting in no program running in the foreground, you can enable a command like tail -f to ensure that it will not exit. 23 | command: "tail -f /dev/null" 24 | -------------------------------------------------------------------------------- /azkaban/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /azkaban/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | 6 | docker exec -d sparrow_container_${CONTAINER_NAMESPACE}_azkaban bash /home/azkaban/azkaban-solo-server/build/install/azkaban-solo-server/bin/start-solo.sh 7 | -------------------------------------------------------------------------------- /azkaban/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /azkaban/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /azkaban/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /azkaban/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /azkaban/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /azkaban/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="azkaban" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_AZKABAN_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_AZKABAN_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_AZKABAN_VERSION=${IMAGE_BASIC_AZKABAN_VERSION} \ 24 | \ 25 | -f ./make_app_image/Dockerfile \ 26 | -t sparrow-app-$service_name:${IMAGE_APP_AZKABAN_VERSION} . ; then 27 | print_error "build image failed" 28 | exit 1 29 | fi 30 | 31 | cd ../ 32 | -------------------------------------------------------------------------------- /azkaban/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_AZKABAN_NAME 3 | ARG IMAGE_OFFICIAL_AZKABAN_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_AZKABAN_NAME}:${IMAGE_OFFICIAL_AZKABAN_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /azkaban/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /azkaban/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="azkaban" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_AZKABAN_NAME=${IMAGE_OFFICIAL_AZKABAN_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_AZKABAN_VERSION=${IMAGE_OFFICIAL_AZKABAN_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_AZKABAN_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /azkaban/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /difylocal/.env: -------------------------------------------------------------------------------- 1 | ### difylocal ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_DIFYLOCAL_NAME=python 6 | IMAGE_OFFICIAL_DIFYLOCAL_VERSION=3.10.0 7 | # basic image 8 | IMAGE_BASIC_DIFYLOCAL_VERSION=0.0.1 9 | # app image 10 | IMAGE_APP_DIFYLOCAL_VERSION=latest 11 | # -------------- service config -------------- 12 | DIFYLOCAL_HOST_WEB_PORT=4300 13 | DIFYLOCAL_CONTAINER_WEB_PORT=3000 14 | DIFYLOCAL_HOST_API_PORT=4301 15 | DIFYLOCAL_CONTAINER_API_PORT=5001 16 | DIFYLOCAL_HOST_CODE_EXECUTION_ENDPOINT_PORT=4302 17 | DIFYLOCAL_CONTAINER_CODE_EXECUTION_ENDPOINT_PORT=8194 18 | -------------------------------------------------------------------------------- /difylocal/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### difylocal ######################################################### 3 | difylocal: 4 | hostname: difylocal 5 | image: sparrow-app-difylocal:${IMAGE_APP_DIFYLOCAL_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_difylocal 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./difylocal/:/home/sparrow/difylocal/ 15 | - ./difylocal/data/:/var/data/difylocal/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${DIFYLOCAL_HOST_WEB_PORT}:${DIFYLOCAL_CONTAINER_WEB_PORT}" 19 | - "${DIFYLOCAL_HOST_API_PORT}:${DIFYLOCAL_CONTAINER_API_PORT}" 20 | - "${DIFYLOCAL_HOST_CODE_EXECUTION_ENDPOINT_PORT}:${DIFYLOCAL_CONTAINER_CODE_EXECUTION_ENDPOINT_PORT}" 21 | networks: 22 | - backend 23 | # only for debug 24 | # a command is needed here, otherwise the container cannot be started successfully. 25 | command: "tail -f /dev/null" 26 | -------------------------------------------------------------------------------- /difylocal/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /difylocal/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /difylocal/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /difylocal/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /difylocal/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /difylocal/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /difylocal/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_DIFYLOCAL_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-difylocal:${IMAGE_BASIC_DIFYLOCAL_VERSION} AS builder 4 | 5 | # change pip source 6 | RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ 7 | 8 | # RUN sed -i 's#https://deb.nodesource.com/node_12.x/#https://mirrors.tuna.tsinghua.edu.cn/nodesource/deb_12.x/#' /etc/apt/sources.list.d/nodesource.list 9 | 10 | # RUN apt-get update && apt-get install nodejs=18.19.0 && node -v 11 | RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - 12 | RUN apt-get update && apt-get install -y nodejs && node -v 13 | 14 | RUN npm config set registry https://registry.npmmirror.com 15 | RUN npm config get registry 16 | 17 | WORKDIR /var/data/difylocal 18 | -------------------------------------------------------------------------------- /difylocal/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /difylocal/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="difylocal" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_DIFYLOCAL_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_DIFYLOCAL_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_DIFYLOCAL_VERSION=${IMAGE_BASIC_DIFYLOCAL_VERSION} \ 24 | \ 25 | -f ./make_app_image/Dockerfile \ 26 | -t sparrow-app-$service_name:${IMAGE_APP_DIFYLOCAL_VERSION} . ; then 27 | print_error "build image failed" 28 | exit 1 29 | fi 30 | 31 | cd ../ 32 | -------------------------------------------------------------------------------- /difylocal/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_DIFYLOCAL_NAME 3 | ARG IMAGE_OFFICIAL_DIFYLOCAL_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_DIFYLOCAL_NAME}:${IMAGE_OFFICIAL_DIFYLOCAL_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /difylocal/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /difylocal/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="difylocal" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_DIFYLOCAL_NAME=${IMAGE_OFFICIAL_DIFYLOCAL_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_DIFYLOCAL_VERSION=${IMAGE_OFFICIAL_DIFYLOCAL_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_DIFYLOCAL_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /difylocal/templates/.env_of_web: -------------------------------------------------------------------------------- 1 | # For production release, change this to PRODUCTION 2 | NEXT_PUBLIC_DEPLOY_ENV=DEVELOPMENT 3 | # The deployment edition, SELF_HOSTED or CLOUD 4 | NEXT_PUBLIC_EDITION=SELF_HOSTED 5 | # The base URL of console application, refers to the Console base URL of WEB service if console domain is 6 | # different from api or web app domain. 7 | # example: http://cloud.dify.ai/console/api 8 | # must use your docker expose port 9 | NEXT_PUBLIC_API_PREFIX=http://localhost:4301/console/api 10 | # The URL for Web APP, refers to the Web App base URL of WEB service if web app domain is different from 11 | # console or api domain. 12 | # example: http://udify.app/api 13 | # must use your docker expose port 14 | NEXT_PUBLIC_PUBLIC_API_PREFIX=http://localhost:4301/api 15 | 16 | # SENTRY 17 | NEXT_PUBLIC_SENTRY_DSN= 18 | -------------------------------------------------------------------------------- /difylocal/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /difylocal/templates/start_local.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # enter difylocal docker 4 | docker exec -it sparrow_container_test_difylocal /bin/sh 5 | 6 | # start api ============================== 7 | 8 | # 1. enter directory 9 | cd /var/data/difylocal/dify/api 10 | # 2. copy a env file 11 | cp .env.example .env 12 | # 3. make SECRET_KEY 13 | openssl rand -base64 42 14 | sed -i 's/SECRET_KEY=.*/SECRET_KEY=/' .env 15 | # 4. pip install 16 | pip install -r requirements.txt 17 | # 5. database migration 18 | flask db upgrade 19 | 20 | # daemon: start server 21 | flask run --host 0.0.0.0 --port=5001 --debug 22 | # daemon: start worker 23 | celery -A app.celery worker -P gevent -c 1 -Q dataset,generation,mail --loglevel INFO 24 | 25 | # start web ============================== 26 | cd /var/data/difylocal/dify/web 27 | 28 | # 1. enter directory 29 | cd /var/data/difylocal/dify/web 30 | # 2. npm install 31 | npm install 32 | # 3. copy a env file 33 | cp .env.example .env.local 34 | # 4. build your project 35 | npm run build 36 | 37 | # daemon: start server 38 | npm run start 39 | -------------------------------------------------------------------------------- /django/.env: -------------------------------------------------------------------------------- 1 | ### django ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_DJANGO_NAME=python 6 | IMAGE_OFFICIAL_DJANGO_VERSION=3.10.13 7 | # basic image 8 | IMAGE_BASIC_DJANGO_VERSION=5.0.3 9 | # app image 10 | IMAGE_APP_DJANGO_VERSION=latest 11 | # -------------- service config -------------- 12 | DJANGO_HOST_PORT=4400 13 | DJANGO_CONTAINER_PORT=8000 14 | -------------------------------------------------------------------------------- /django/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### django ######################################################### 3 | django: 4 | hostname: django 5 | image: sparrow-app-django:${IMAGE_APP_DJANGO_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_django 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./django/:/home/sparrow/django/ 15 | - ./django/data/:/var/data/django/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${DJANGO_HOST_PORT}:${DJANGO_CONTAINER_PORT}" 19 | networks: 20 | - backend 21 | # only for debug 22 | # a command is needed here, otherwise the container cannot be started successfully. 23 | command: "tail -f /dev/null" 24 | -------------------------------------------------------------------------------- /django/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /django/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /django/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /django/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /django/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /django/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /django/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_DJANGO_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-django:${IMAGE_BASIC_DJANGO_VERSION} 4 | 5 | # change source 6 | RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ 7 | 8 | # install Django 9 | RUN python -m pip install Django && python -m django --version 10 | 11 | WORKDIR /var/data/django 12 | 13 | # start project 14 | # RUN django-admin startproject demo && cd demo 15 | # default listen 127.0.0.1, it may cause error: cannot access Django server in docker container via ip:port 16 | # so must listen 0.0.0.0 17 | # RUN nohup python manage.py runserver 0.0.0.0:8000 & 18 | -------------------------------------------------------------------------------- /django/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /django/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="django" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_DJANGO_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_DJANGO_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_DJANGO_VERSION=${IMAGE_BASIC_DJANGO_VERSION} \ 24 | \ 25 | -f ./make_app_image/Dockerfile \ 26 | -t sparrow-app-$service_name:${IMAGE_APP_DJANGO_VERSION} . ; then 27 | print_error "build image failed" 28 | exit 1 29 | fi 30 | 31 | cd ../ 32 | -------------------------------------------------------------------------------- /django/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_DJANGO_NAME 3 | ARG IMAGE_OFFICIAL_DJANGO_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_DJANGO_NAME}:${IMAGE_OFFICIAL_DJANGO_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /django/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /django/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="django" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_DJANGO_NAME=${IMAGE_OFFICIAL_DJANGO_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_DJANGO_VERSION=${IMAGE_OFFICIAL_DJANGO_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_DJANGO_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /django/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /elasticsearch/.env: -------------------------------------------------------------------------------- 1 | ### elasticsearch ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_ELASTICSEARCH_NAME=elasticsearch 6 | IMAGE_OFFICIAL_ELASTICSEARCH_VERSION=7.17.18 # The version number must be consistent with ElasticSearch. 7 | # basic image 8 | IMAGE_BASIC_ELASTICSEARCH_VERSION=7.17.18 # The version number must be consistent with ElasticSearch. 9 | # app image 10 | IMAGE_APP_ELASTICSEARCH_VERSION=latest 11 | # -------------- service config -------------- 12 | ELASTICSEARCH_HOST_HTTP_PORT=3900 13 | ELASTICSEARCH_CONTAINER_HTTP_PORT=9200 14 | ELASTICSEARCH_HOST_TCP_PORT=3901 15 | ELASTICSEARCH_CONTAINER_TCP_PORT=9300 16 | # default account: username=elastic/password=elastic 17 | -------------------------------------------------------------------------------- /elasticsearch/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /elasticsearch/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /elasticsearch/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /elasticsearch/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /elasticsearch/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /elasticsearch/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /elasticsearch/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_ELASTICSEARCH_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-elasticsearch:${IMAGE_BASIC_ELASTICSEARCH_VERSION} 4 | -------------------------------------------------------------------------------- /elasticsearch/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /elasticsearch/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="elasticsearch" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_ELASTICSEARCH_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_ELASTICSEARCH_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_ELASTICSEARCH_VERSION=${IMAGE_BASIC_ELASTICSEARCH_VERSION} \ 24 | \ 25 | -f ./make_app_image/Dockerfile \ 26 | -t sparrow-app-$service_name:${IMAGE_APP_ELASTICSEARCH_VERSION} . ; then 27 | print_error "build image failed" 28 | exit 1 29 | fi 30 | 31 | cd ../ 32 | -------------------------------------------------------------------------------- /elasticsearch/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_ELASTICSEARCH_NAME 3 | ARG IMAGE_OFFICIAL_ELASTICSEARCH_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_ELASTICSEARCH_NAME}:${IMAGE_OFFICIAL_ELASTICSEARCH_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /elasticsearch/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /elasticsearch/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="elasticsearch" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_ELASTICSEARCH_NAME=${IMAGE_OFFICIAL_ELASTICSEARCH_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_ELASTICSEARCH_VERSION=${IMAGE_OFFICIAL_ELASTICSEARCH_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_ELASTICSEARCH_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /elasticsearch/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /etcd/.env: -------------------------------------------------------------------------------- 1 | ### ETCD ################################################## 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_ETCD_NAME=bitnami/etcd 6 | IMAGE_OFFICIAL_ETCD_VERSION=3.5.0 7 | # basic image 8 | IMAGE_BASIC_ETCD_VERSION=3.5.0 9 | # app image 10 | IMAGE_APP_ETCD_VERSION=latest 11 | # -------------- service config -------------- 12 | ETCD_CLIENT_HOST_PORT=2000 13 | ETCD_CLIENT_CONTAINER_PORT=2379 14 | ETCD_SERVER_HOST_PORT=2001 15 | ETCD_SERVER_CONTAINER_PORT=2380 16 | -------------------------------------------------------------------------------- /etcd/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### ETCD ####################################################### 3 | etcd: 4 | hostname: etcd 5 | image: sparrow-app-etcd:${IMAGE_APP_ETCD_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_etcd 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./etcd/:/home/sparrow/etcd/ 15 | - ./etcd/data/:/var/data/etcd/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${ETCD_CLIENT_HOST_PORT}:${ETCD_CLIENT_CONTAINER_PORT}" 19 | - "${ETCD_SERVER_HOST_PORT}:${ETCD_SERVER_CONTAINER_PORT}" 20 | networks: 21 | - backend 22 | # only for debug 23 | # command: "tail -f /dev/null" 24 | -------------------------------------------------------------------------------- /etcd/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /etcd/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /etcd/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /etcd/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /etcd/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /etcd/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /etcd/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_ETCD_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-etcd:${IMAGE_BASIC_ETCD_VERSION} 4 | 5 | ARG ETCD_CLIENT_CONTAINER_PORT 6 | ARG ETCD_SERVER_CONTAINER_PORT 7 | ENV ETCD_NAME "SparrowEtcd" 8 | ENV ALLOW_NONE_AUTHENTICATION yes 9 | ENV ETCD_ADVERTISE_CLIENT_URLS "http://etcd:${ETCD_CLIENT_CONTAINER_PORT}" 10 | ENV ETCD_LISTEN_CLIENT_URLS "http://0.0.0.0:${ETCD_CLIENT_CONTAINER_PORT}" 11 | ENV ETCD_INITIAL_ADVERTISE_PEER_URLS "http://etcd:${ETCD_SERVER_CONTAINER_PORT}" 12 | ENV ETCD_LISTEN_PEER_URLS "http://0.0.0.0:${ETCD_SERVER_CONTAINER_PORT}" 13 | CMD ["/opt/bitnami/scripts/etcd/run.sh"] 14 | # CMD ["etcd", "--name=etcd", "--initial-advertise-peer-urls=http://etcd:2380", "--advertise-client-urls=http://etcd:2379", "--listen-client-urls=http://0.0.0.0:2379", "--listen-peer-urls=http://0.0.0.0:2380", "--initial-cluster=etcd=http://etcd:2380", "--initial-cluster-token=etcd", "--initial-cluster-state=new"] 15 | # CMD ["etcd", "--name=etcd", "--initial-advertise-peer-urls=http://0.0.0.0:2380", "--advertise-client-urls=http://0.0.0.0:2379", "--listen-client-urls=http://0.0.0.0:2379", "--listen-peer-urls=http://0.0.0.0:2380", "--initial-cluster=etcd=http://0.0.0.0:2380", "--initial-cluster-token=etcd", "--initial-cluster-state=new"] 16 | -------------------------------------------------------------------------------- /etcd/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /etcd/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="etcd" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_ETCD_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_ETCD_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_ETCD_VERSION=${IMAGE_BASIC_ETCD_VERSION} \ 24 | \ 25 | --build-arg ETCD_CLIENT_CONTAINER_PORT=${ETCD_CLIENT_CONTAINER_PORT} \ 26 | --build-arg ETCD_SERVER_CONTAINER_PORT=${ETCD_SERVER_CONTAINER_PORT} \ 27 | \ 28 | -f ./make_app_image/Dockerfile \ 29 | -t sparrow-app-$service_name:${IMAGE_APP_ETCD_VERSION} . ; then 30 | print_error "build image failed" 31 | exit 1 32 | fi 33 | 34 | cd ../ 35 | -------------------------------------------------------------------------------- /etcd/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_ETCD_NAME 3 | ARG IMAGE_OFFICIAL_ETCD_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_ETCD_NAME}:${IMAGE_OFFICIAL_ETCD_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /etcd/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /etcd/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="etcd" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_ETCD_NAME=${IMAGE_OFFICIAL_ETCD_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_ETCD_VERSION=${IMAGE_OFFICIAL_ETCD_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_ETCD_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /etcd/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /etcdkeeper/.env: -------------------------------------------------------------------------------- 1 | ### ETCDKEEPER ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_ETCDKEEPER_NAME=evildecay/etcdkeeper 6 | IMAGE_OFFICIAL_ETCDKEEPER_VERSION=v0.7.6 7 | # basic image 8 | IMAGE_BASIC_ETCDKEEPER_VERSION=v0.7.6 9 | # app image 10 | IMAGE_APP_ETCDKEEPER_VERSION=latest 11 | # -------------- service config -------------- 12 | ETCDKEEPER_HOST_PORT=2100 13 | ETCDKEEPER_CONTAINER_PORT=8080 # not supporting custom configurations 14 | -------------------------------------------------------------------------------- /etcdkeeper/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### ETCDKEEPER ################################################# 3 | etcdkeeper: 4 | hostname: etcdkeeper 5 | image: sparrow-app-etcdkeeper:${IMAGE_APP_ETCDKEEPER_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_etcdkeeper 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./etcdkeeper/:/home/sparrow/etcdkeeper/ 15 | - ./etcdkeeper/data/:/var/data/etcdkeeper/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${ETCDKEEPER_HOST_PORT}:${ETCDKEEPER_CONTAINER_PORT}" 19 | networks: 20 | - backend 21 | # only for debug 22 | # command: "tail -f /dev/null" 23 | -------------------------------------------------------------------------------- /etcdkeeper/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /etcdkeeper/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /etcdkeeper/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /etcdkeeper/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /etcdkeeper/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /etcdkeeper/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /etcdkeeper/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_ETCDKEEPER_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-etcdkeeper:${IMAGE_BASIC_ETCDKEEPER_VERSION} 4 | 5 | RUN sed -i -e 's/http:/https:/' /etc/apk/repositories \ 6 | && apk update \ 7 | && apk add curl \ 8 | && apk add bash 9 | -------------------------------------------------------------------------------- /etcdkeeper/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /etcdkeeper/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="etcdkeeper" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_ETCDKEEPER_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_ETCDKEEPER_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_ETCDKEEPER_VERSION=${IMAGE_BASIC_ETCDKEEPER_VERSION} \ 24 | \ 25 | -f ./make_app_image/Dockerfile \ 26 | -t sparrow-app-$service_name:${IMAGE_APP_ETCDKEEPER_VERSION} . ; then 27 | print_error "build image failed" 28 | exit 1 29 | fi 30 | 31 | cd ../ 32 | -------------------------------------------------------------------------------- /etcdkeeper/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_ETCDKEEPER_NAME 3 | ARG IMAGE_OFFICIAL_ETCDKEEPER_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_ETCDKEEPER_NAME}:${IMAGE_OFFICIAL_ETCDKEEPER_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /etcdkeeper/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /etcdkeeper/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="etcdkeeper" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_ETCDKEEPER_NAME=${IMAGE_OFFICIAL_ETCDKEEPER_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_ETCDKEEPER_VERSION=${IMAGE_OFFICIAL_ETCDKEEPER_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_ETCDKEEPER_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /etcdkeeper/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /go/.env: -------------------------------------------------------------------------------- 1 | ### GO #################################################### 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_GO_NAME=golang 6 | IMAGE_OFFICIAL_GO_VERSION=1.21.1 7 | # basic image 8 | IMAGE_BASIC_GO_VERSION=1.21.1 9 | # app image 10 | IMAGE_APP_GO_VERSION=latest 11 | # -------------- service config -------------- 12 | GO_HOST_PORT=2200 13 | GO_CONTAINER_PORT=2200 14 | GO_PATH=~/environment/go 15 | -------------------------------------------------------------------------------- /go/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### Go ######################################################### 3 | go: 4 | hostname: go 5 | image: sparrow-app-go:${IMAGE_APP_GO_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_go 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./go/:/home/sparrow/go/ 15 | - ./go/data/:/var/data/go/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 16 | - ${GO_PATH}:/go 17 | extra_hosts: 18 | - "dockerhost:${DOCKER_HOST_IP}" 19 | - "host.docker.internal:${DOCKER_HOST_IP}" 20 | ports: 21 | # You don't need to expose the port in the Dockerfile. 22 | - "${GO_HOST_PORT}:${GO_CONTAINER_PORT}" 23 | tty: true 24 | networks: 25 | - backend 26 | # only for debug 27 | # command: "tail -f /dev/null" 28 | -------------------------------------------------------------------------------- /go/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /go/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /go/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /go/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | 7 | if [ ! -d "$GO_PATH" ]; then 8 | if ! mkdir -p "$GO_PATH"; then 9 | print_error "mkdir $GO_PATH failed" 10 | exit 1 11 | fi 12 | fi 13 | -------------------------------------------------------------------------------- /go/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /go/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /go/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_GO_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-go:${IMAGE_BASIC_GO_VERSION} 4 | 5 | ENV GO111MODULE=on \ 6 | GOPROXY=https://goproxy.cn,https://mirrors.aliyun.com/goproxy/,https://goproxy.io,direct \ 7 | CGO_ENABLED=0 \ 8 | GOOS=linux \ 9 | GOARCH=amd64 \ 10 | GOPATH=/go 11 | 12 | # install go-zero 13 | RUN go install github.com/zeromicro/go-zero/tools/goctl@latest \ 14 | && goctl env check --install --verbose --force \ 15 | && goctl env install --verbose --force \ 16 | && goctl env check --verbose 17 | 18 | # verify the go environment is deployed successfully, do not start the server. 19 | WORKDIR /dist 20 | COPY ./templates/go.mod /dist/go.mod 21 | COPY ./templates/main.go /dist/main.go 22 | RUN cd /dist/ && go mod download && go mod tidy && go build -o demoapp && rm -rf /dist 23 | # CMD ["./demoapp"] 24 | -------------------------------------------------------------------------------- /go/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /go/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="go" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_GO_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_GO_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | # bring the entire service directory into the build context. 21 | cd $service_name/ 22 | if ! docker build \ 23 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 24 | --build-arg IMAGE_BASIC_GO_VERSION=${IMAGE_BASIC_GO_VERSION} \ 25 | \ 26 | --build-arg GO_CONTAINER_PORT=${GO_CONTAINER_PORT} \ 27 | \ 28 | -f ./make_app_image/Dockerfile \ 29 | -t sparrow-app-$service_name:${IMAGE_APP_GO_VERSION} . ; then 30 | print_error "build image failed" 31 | exit 1 32 | fi 33 | 34 | cd ../ 35 | -------------------------------------------------------------------------------- /go/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_GO_NAME 3 | ARG IMAGE_OFFICIAL_GO_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_GO_NAME}:${IMAGE_OFFICIAL_GO_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /go/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /go/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="go" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_GO_NAME=${IMAGE_OFFICIAL_GO_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_GO_VERSION=${IMAGE_OFFICIAL_GO_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_GO_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /go/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /go/templates/go.mod: -------------------------------------------------------------------------------- 1 | module demo 2 | 3 | go 1.15 4 | 5 | require github.com/joho/godotenv v1.5.1 6 | -------------------------------------------------------------------------------- /go/templates/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net/http" 7 | "os" 8 | 9 | "github.com/joho/godotenv" 10 | ) 11 | 12 | func main() { 13 | // 加载环境变量 14 | err := godotenv.Load("/home/sparrow/go/.env") // 注意修改路径以适应你的实际文件结构 15 | if err != nil { 16 | log.Fatal("Error loading .env file") 17 | } 18 | 19 | // 获取环境变量 GO_CONTAINER_PORT,如果不存在则使用默认值 ":8001" 20 | port := os.Getenv("GO_CONTAINER_PORT") 21 | if port == "" { 22 | port = "8001" 23 | } 24 | 25 | http.HandleFunc("/test", func(w http.ResponseWriter, r *http.Request) { 26 | fmt.Fprintf(w, "Hello Go!") 27 | }) 28 | 29 | // start http server 30 | // listen 127.0.0.1 => only allow local requests. 31 | // listen 0.0.0.0 => allow requests from any endpoint. 32 | fmt.Printf("Server is running on port %s\n", port) 33 | err = http.ListenAndServe(fmt.Sprintf("0.0.0.0:%s", port), nil) 34 | if err != nil { 35 | log.Fatal("Error:", err) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /grafana/.env: -------------------------------------------------------------------------------- 1 | ### grafana ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_GRAFANA_NAME=grafana/grafana 6 | IMAGE_OFFICIAL_GRAFANA_VERSION=10.2.4 7 | # basic image 8 | IMAGE_BASIC_GRAFANA_VERSION=10.2.4 9 | # app image 10 | IMAGE_APP_GRAFANA_VERSION=latest 11 | # -------------- service config -------------- 12 | GRAFANA_HOST_PORT=3800 13 | GRAFANA_CONTAINER_PORT=3000 14 | # default account: username=admin/password=admin 15 | -------------------------------------------------------------------------------- /grafana/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### grafana ######################################################### 3 | grafana: 4 | hostname: grafana 5 | image: sparrow-app-grafana:${IMAGE_APP_GRAFANA_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_grafana 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./grafana/:/home/sparrow/grafana/ 15 | # https://community.grafana.com/t/grafana-docker-and-data-persistence/33702 16 | - ./grafana/data/:/var/lib/grafana # data persistence 17 | ports: 18 | # You don't need to expose the port in the Dockerfile. 19 | - "${GRAFANA_HOST_PORT}:${GRAFANA_CONTAINER_PORT}" 20 | networks: 21 | - backend 22 | # only for debug 23 | # command: "tail -f /dev/null" 24 | -------------------------------------------------------------------------------- /grafana/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /grafana/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /grafana/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /grafana/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /grafana/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /grafana/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /grafana/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_GRAFANA_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-grafana:${IMAGE_BASIC_GRAFANA_VERSION} 4 | -------------------------------------------------------------------------------- /grafana/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /grafana/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="grafana" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_GRAFANA_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_GRAFANA_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_GRAFANA_VERSION=${IMAGE_BASIC_GRAFANA_VERSION} \ 24 | \ 25 | -f ./make_app_image/Dockerfile \ 26 | -t sparrow-app-$service_name:${IMAGE_APP_GRAFANA_VERSION} . ; then 27 | print_error "build image failed" 28 | exit 1 29 | fi 30 | 31 | cd ../ 32 | -------------------------------------------------------------------------------- /grafana/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_GRAFANA_NAME 3 | ARG IMAGE_OFFICIAL_GRAFANA_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_GRAFANA_NAME}:${IMAGE_OFFICIAL_GRAFANA_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /grafana/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /grafana/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="grafana" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_GRAFANA_NAME=${IMAGE_OFFICIAL_GRAFANA_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_GRAFANA_VERSION=${IMAGE_OFFICIAL_GRAFANA_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_GRAFANA_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /grafana/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /jupyter/.env: -------------------------------------------------------------------------------- 1 | ### jupyter ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_JUPYTER_NAME=jupyter/minimal-notebook 6 | IMAGE_OFFICIAL_JUPYTER_VERSION=latest 7 | # basic image 8 | IMAGE_BASIC_JUPYTER_VERSION=latest 9 | # app image 10 | IMAGE_APP_JUPYTER_VERSION=latest 11 | # -------------- service config -------------- 12 | JUPYTER_HOST_PORT=2300 13 | JUPYTER_CONTAINER_PORT=8888 14 | JUPYTER_TOKEN=123456 15 | -------------------------------------------------------------------------------- /jupyter/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### jupyter ######################################################### 3 | jupyter: 4 | hostname: jupyter 5 | image: sparrow-app-jupyter:${IMAGE_APP_JUPYTER_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_jupyter 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./jupyter/:/home/sparrow/jupyter/ 15 | - ./jupyter/data/:/var/data/jupyter/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${JUPYTER_HOST_PORT}:${JUPYTER_CONTAINER_PORT}" 19 | networks: 20 | - backend 21 | # only for debug 22 | # command: "tail -f /dev/null" 23 | -------------------------------------------------------------------------------- /jupyter/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /jupyter/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /jupyter/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /jupyter/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /jupyter/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /jupyter/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /jupyter/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_JUPYTER_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-jupyter:${IMAGE_BASIC_JUPYTER_VERSION} 4 | 5 | ARG JUPYTER_CONTAINER_PORT 6 | ENV JUPYTER_PORT ${JUPYTER_CONTAINER_PORT} 7 | 8 | ARG JUPYTER_TOKEN 9 | ENV JUPYTER_TOKEN ${JUPYTER_TOKEN} 10 | # https://stackoverflow.com/questions/48875436/jupyter-password-and-docker 11 | 12 | # CMD ["start-notebook.sh", "--NotebookApp.token=''", "--NotebookApp.password=''", "--NotebookApp.allow_origin='*'", "--NotebookApp.notebook_dir='/var/data/jupyter/'"] 13 | CMD ["start-notebook.sh", "--NotebookApp.allow_origin='*'", "--NotebookApp.notebook_dir='/var/data/jupyter/'"] 14 | -------------------------------------------------------------------------------- /jupyter/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /jupyter/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="jupyter" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_JUPYTER_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_JUPYTER_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_JUPYTER_VERSION=${IMAGE_BASIC_JUPYTER_VERSION} \ 24 | \ 25 | --build-arg JUPYTER_CONTAINER_PORT=${JUPYTER_CONTAINER_PORT} \ 26 | --build-arg JUPYTER_TOKEN=${JUPYTER_TOKEN} \ 27 | \ 28 | -f ./make_app_image/Dockerfile \ 29 | -t sparrow-app-$service_name:${IMAGE_APP_JUPYTER_VERSION} . ; then 30 | print_error "build image failed" 31 | exit 1 32 | fi 33 | 34 | cd ../ 35 | -------------------------------------------------------------------------------- /jupyter/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_JUPYTER_NAME 3 | ARG IMAGE_OFFICIAL_JUPYTER_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_JUPYTER_NAME}:${IMAGE_OFFICIAL_JUPYTER_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /jupyter/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /jupyter/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="jupyter" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_JUPYTER_NAME=${IMAGE_OFFICIAL_JUPYTER_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_JUPYTER_VERSION=${IMAGE_OFFICIAL_JUPYTER_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_JUPYTER_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /jupyter/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /kafka/.env: -------------------------------------------------------------------------------- 1 | ### KAFKA ################################################# 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_KAFKA_NAME=wurstmeister/kafka 6 | IMAGE_OFFICIAL_KAFKA_VERSION=2.13-2.8.1 7 | # basic image 8 | IMAGE_BASIC_KAFKA_VERSION=2.13-2.8.1 9 | # app image 10 | IMAGE_APP_KAFKA_VERSION=latest 11 | # -------------- service config -------------- 12 | KAFKA_HOST_PORT=2400 13 | KAFKA_CONTAINER_PORT=9092 14 | -------------------------------------------------------------------------------- /kafka/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### KAFKA ###################################################### 3 | kafka: 4 | hostname: kafka 5 | image: sparrow-app-kafka:${IMAGE_APP_KAFKA_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_kafka 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./kafka/:/home/sparrow/kafka/ 15 | - ./kafka/data/:/var/data/kafka/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${KAFKA_HOST_PORT}:${KAFKA_CONTAINER_PORT}" 19 | networks: 20 | - backend 21 | # only for debug 22 | # command: "tail -f /dev/null" 23 | -------------------------------------------------------------------------------- /kafka/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /kafka/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | 7 | back_kafka_broker_container="sparrow_container_${CONTAINER_NAMESPACE}_kafka1" 8 | output=$(docker container ps -a | grep "$back_kafka_broker_container") 9 | if [ -n "$output" ]; then 10 | print_info "stop and remove $back_kafka_broker_container ..." 11 | docker stop $back_kafka_broker_container && docker rm $back_kafka_broker_container 12 | fi 13 | 14 | print_info "restart $back_kafka_broker_container ..." 15 | docker run -d --name $back_kafka_broker_container -p $((KAFKA_CONTAINER_PORT+1)):$((KAFKA_CONTAINER_PORT+1)) \ 16 | -e KAFKA_BROKER_ID=1 \ 17 | -e KAFKA_ZOOKEEPER_CONNECT=${DOCKER_HOST_IP}:${ZOOKEEPER_CONTAINER_PORT} \ 18 | -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://${DOCKER_HOST_IP}:$((KAFKA_CONTAINER_PORT+1)) \ 19 | -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:$((KAFKA_CONTAINER_PORT+1)) \ 20 | --platform ${FROM_PLATFORM} \ 21 | -t sparrow-basic-kafka:${IMAGE_BASIC_KAFKA_VERSION} 22 | -------------------------------------------------------------------------------- /kafka/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | 7 | output=$(docker container ps -a | grep 'sparrow_container_${CONTAINER_NAMESPACE}_kafka1') 8 | if [ -n "$output" ]; then 9 | docker stop sparrow_container_${CONTAINER_NAMESPACE}_kafka1 && docker rm sparrow_container_${CONTAINER_NAMESPACE}_kafka1 10 | fi 11 | -------------------------------------------------------------------------------- /kafka/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | 7 | # Due to the dependency of the Kafka service on the ZooKeeper service, it is necessary to start ZooKeeper first. 8 | if docker container inspect -f '{{.State.Running}}' "sparrow_container_${CONTAINER_NAMESPACE}_zookeeper" &> /dev/null; then 9 | print_info "zookeeper container is running, allowed to continue." 10 | else 11 | print_error "zookeeper container is not running, it is necessary to start ZooKeeper first." 12 | exit 1 13 | fi 14 | 15 | -------------------------------------------------------------------------------- /kafka/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /kafka/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /kafka/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_KAFKA_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-kafka:${IMAGE_BASIC_KAFKA_VERSION} 4 | 5 | ARG DOCKER_HOST_IP 6 | ARG ZOOKEEPER_PORT 7 | ARG KAFKA_CONTAINER_PORT 8 | ENV KAFKA_BROKER_ID=0 \ 9 | KAFKA_ZOOKEEPER_CONNECT=${DOCKER_HOST_IP}:${ZOOKEEPER_PORT} \ 10 | KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://${DOCKER_HOST_IP}:${KAFKA_CONTAINER_PORT} \ 11 | KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:${KAFKA_CONTAINER_PORT} 12 | 13 | ARG IMAGE_BASIC_KAFKA_VERSION 14 | WORKDIR /opt/kafka_${IMAGE_BASIC_KAFKA_VERSION}/bin/ 15 | -------------------------------------------------------------------------------- /kafka/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /kafka/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="kafka" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_KAFKA_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_KAFKA_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_KAFKA_VERSION=${IMAGE_BASIC_KAFKA_VERSION} \ 24 | --build-arg KAFKA_CONTAINER_PORT=${KAFKA_CONTAINER_PORT} \ 25 | \ 26 | -f ./make_app_image/Dockerfile \ 27 | -t sparrow-app-$service_name:${IMAGE_APP_KAFKA_VERSION} . ; then 28 | print_error "build image failed" 29 | exit 1 30 | fi 31 | 32 | cd ../ 33 | -------------------------------------------------------------------------------- /kafka/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_KAFKA_NAME 3 | ARG IMAGE_OFFICIAL_KAFKA_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_KAFKA_NAME}:${IMAGE_OFFICIAL_KAFKA_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /kafka/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /kafka/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="kafka" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_KAFKA_NAME=${IMAGE_OFFICIAL_KAFKA_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_KAFKA_VERSION=${IMAGE_OFFICIAL_KAFKA_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_KAFKA_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /kafka/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /kafkaui/.env: -------------------------------------------------------------------------------- 1 | ### KAFKAUI ############################################### 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_KAFKAUI_NAME=provectuslabs/kafka-ui 6 | IMAGE_OFFICIAL_KAFKAUI_VERSION=latest 7 | # basic image 8 | IMAGE_BASIC_KAFKAUI_VERSION=latest 9 | # app image 10 | IMAGE_APP_KAFKAUI_VERSION=latest 11 | # -------------- service config -------------- 12 | KAFKAUI_HOST_PORT=2500 13 | KAFKAUI_CONTAINER_PORT=8080 # not supporting custom configurations 14 | -------------------------------------------------------------------------------- /kafkaui/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### KAFKAUI #################################################### 3 | kafkaui: 4 | hostname: kafkaui 5 | image: sparrow-app-kafkaui:${IMAGE_APP_KAFKAUI_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_kafkaui 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./kafkaui/:/home/sparrow/kafkaui/ 15 | - ./kafkaui/templates/config.yml:/etc/kafkaui/dynamic_config.yaml 16 | - ./kafkaui/data/:/var/data/kafkaui/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 17 | ports: 18 | # You don't need to expose the port in the Dockerfile. 19 | - "${KAFKAUI_HOST_PORT}:${KAFKAUI_CONTAINER_PORT}" 20 | networks: 21 | - backend 22 | # only for debug 23 | # command: "tail -f /dev/null" 24 | -------------------------------------------------------------------------------- /kafkaui/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /kafkaui/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /kafkaui/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /kafkaui/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /kafkaui/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /kafkaui/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /kafkaui/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_KAFKAUI_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-kafkaui:${IMAGE_BASIC_KAFKAUI_VERSION} 4 | 5 | ENV DYNAMIC_CONFIG_ENABLED true 6 | -------------------------------------------------------------------------------- /kafkaui/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /kafkaui/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="kafkaui" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_KAFKAUI_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_KAFKAUI_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_KAFKAUI_VERSION=${IMAGE_BASIC_KAFKAUI_VERSION} \ 24 | \ 25 | -f ./make_app_image/Dockerfile \ 26 | -t sparrow-app-$service_name:${IMAGE_APP_KAFKAUI_VERSION} . ; then 27 | print_error "build image failed" 28 | exit 1 29 | fi 30 | 31 | cd ../ 32 | -------------------------------------------------------------------------------- /kafkaui/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_KAFKAUI_NAME 3 | ARG IMAGE_OFFICIAL_KAFKAUI_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_KAFKAUI_NAME}:${IMAGE_OFFICIAL_KAFKAUI_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /kafkaui/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /kafkaui/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="kafkaui" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_KAFKAUI_NAME=${IMAGE_OFFICIAL_KAFKAUI_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_KAFKAUI_VERSION=${IMAGE_OFFICIAL_KAFKAUI_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_KAFKAUI_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /kafkaui/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /kafkaui/templates/config.yml: -------------------------------------------------------------------------------- 1 | auth: 2 | type: DISABLED 3 | kafka: 4 | clusters: 5 | - bootstrapServers: 192.168.0.168:9092,192.168.0.168:9093 6 | name: sparrow-app-kafka 7 | properties: {} 8 | readOnly: false 9 | rbac: 10 | roles: [] 11 | webclient: {} 12 | -------------------------------------------------------------------------------- /kibana/.env: -------------------------------------------------------------------------------- 1 | ### kibana ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_KIBANA_NAME=kibana 6 | IMAGE_OFFICIAL_KIBANA_VERSION=7.17.18 # The version number must be consistent with ElasticSearch. # don't use 8.12.0, the higher 8+ version don't support super account: elastic 7 | # basic image 8 | IMAGE_BASIC_KIBANA_VERSION=7.17.18 # The version number must be consistent with ElasticSearch. # don't use 8.12.0, the higher 8+ version don't support super account: elastic 9 | # app image 10 | IMAGE_APP_KIBANA_VERSION=latest 11 | # -------------- service config -------------- 12 | KIBANA_HOST_PORT=4000 13 | KIBANA_CONTAINER_PORT=5601 14 | -------------------------------------------------------------------------------- /kibana/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### kibana ######################################################### 3 | kibana: 4 | hostname: kibana 5 | image: sparrow-app-kibana:${IMAGE_APP_KIBANA_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_kibana 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./kibana/:/home/sparrow/kibana/ 15 | # Based on this question, it looks like it saves into elasticsearch, so you don't need to mount a shared volume. 16 | # https://stackoverflow.com/questions/42874034/kibana-running-on-docker-how-to-save-dashboard 17 | - ./kibana/data/:/var/data/kibana/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 18 | ports: 19 | # You don't need to expose the port in the Dockerfile. 20 | - "${KIBANA_HOST_PORT}:${KIBANA_CONTAINER_PORT}" 21 | networks: 22 | - backend 23 | # only for debug 24 | # command: "tail -f /dev/null" 25 | -------------------------------------------------------------------------------- /kibana/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /kibana/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /kibana/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /kibana/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /kibana/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /kibana/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /kibana/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_KIBANA_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-kibana:${IMAGE_BASIC_KIBANA_VERSION} 4 | 5 | COPY ./templates/kibana.yml /usr/share/kibana/config/kibana.yml 6 | 7 | ARG DOCKER_HOST_IP 8 | ARG ELASTICSEARCH_HOST_HTTP_PORT 9 | RUN sed -i "s/DOCKER_HOST_IP/${DOCKER_HOST_IP}/g" /usr/share/kibana/config/kibana.yml 10 | RUN sed -i "s/ELASTICSEARCH_HOST_HTTP_PORT/${ELASTICSEARCH_HOST_HTTP_PORT}/g" /usr/share/kibana/config/kibana.yml 11 | 12 | CMD ["/usr/local/bin/kibana-docker"] 13 | -------------------------------------------------------------------------------- /kibana/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /kibana/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="kibana" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_KIBANA_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_KIBANA_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_KIBANA_VERSION=${IMAGE_BASIC_KIBANA_VERSION} \ 24 | --build-arg ELASTICSEARCH_HOST_HTTP_PORT=${ELASTICSEARCH_HOST_HTTP_PORT} \ 25 | --build-arg DOCKER_HOST_IP=${DOCKER_HOST_IP} \ 26 | \ 27 | -f ./make_app_image/Dockerfile \ 28 | -t sparrow-app-$service_name:${IMAGE_APP_KIBANA_VERSION} . ; then 29 | print_error "build image failed" 30 | exit 1 31 | fi 32 | 33 | cd ../ 34 | -------------------------------------------------------------------------------- /kibana/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_KIBANA_NAME 3 | ARG IMAGE_OFFICIAL_KIBANA_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_KIBANA_NAME}:${IMAGE_OFFICIAL_KIBANA_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /kibana/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /kibana/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="kibana" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_KIBANA_NAME=${IMAGE_OFFICIAL_KIBANA_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_KIBANA_VERSION=${IMAGE_OFFICIAL_KIBANA_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_KIBANA_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /kibana/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /kibana/templates/kibana.yml: -------------------------------------------------------------------------------- 1 | # Default Kibana configuration for docker target 2 | server.host: "0.0.0.0" 3 | server.shutdownTimeout: "5s" 4 | elasticsearch.hosts: [ "http://DOCKER_HOST_IP:ELASTICSEARCH_HOST_HTTP_PORT" ] 5 | monitoring.ui.container.elasticsearch.enabled: true 6 | 7 | # fix the error: missing authentication credentials for REST request 8 | # xpack.security.enabled: false 9 | # elasticsearch.username: elastic 10 | # elasticsearch.password: elastic 11 | -------------------------------------------------------------------------------- /langchain/.env: -------------------------------------------------------------------------------- 1 | ### langchain ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_LANGCHAIN_NAME=langchain/langchain 6 | IMAGE_OFFICIAL_LANGCHAIN_VERSION=0.1.0 7 | # basic image 8 | IMAGE_BASIC_LANGCHAIN_VERSION=0.1.0 9 | # app image 10 | IMAGE_APP_LANGCHAIN_VERSION=latest 11 | # -------------- service config -------------- 12 | LANGCHAIN_HOST_PORT=3300 13 | LANGCHAIN_CONTAINER_PORT=3300 14 | -------------------------------------------------------------------------------- /langchain/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### langchain ######################################################### 3 | langchain: 4 | hostname: langchain 5 | image: sparrow-app-langchain:${IMAGE_APP_LANGCHAIN_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_langchain 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./langchain/:/home/sparrow/langchain/ 15 | - ./langchain/data/:/var/data/langchain/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${LANGCHAIN_HOST_PORT}:${LANGCHAIN_CONTAINER_PORT}" 19 | networks: 20 | - backend 21 | # only for debug 22 | # command: "tail -f /dev/null" 23 | command: "tail -f /dev/null" # Because there is no startup command for the langchain service, use this command to ensure it can be started successfully. 24 | -------------------------------------------------------------------------------- /langchain/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /langchain/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | 7 | echo "after start, please reset your OPENAI_API_KEY inside the container manually: export OPENAI_API_KEY=''" 8 | docker exec -d sparrow_container_${CONTAINER_NAMESPACE}_langchain bash /home/sparrow/langchain/init/init.sh 9 | -------------------------------------------------------------------------------- /langchain/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /langchain/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /langchain/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /langchain/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /langchain/init/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # no source command, so use `. ~/.bashrc` to reload refresh. 4 | if grep -qF 'export OPENAI_API_KEY=' ~/.bashrc; then 5 | sed -i 's/^export OPENAI_API_KEY=.*$/export OPENAI_API_KEY="sk-please-reset-OPENAI_API_KEY-variable-inside-the-container-manually"/' /etc/profile; 6 | . /etc/profile 7 | else 8 | echo 'export OPENAI_API_KEY="sk-please-reset-OPENAI_API_KEY-variable-inside-the-container-manually"' >> /etc/profile 9 | . /etc/profile 10 | fi 11 | -------------------------------------------------------------------------------- /langchain/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_LANGCHAIN_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-langchain:${IMAGE_BASIC_LANGCHAIN_VERSION} 4 | 5 | RUN pip install langchain-openai 6 | -------------------------------------------------------------------------------- /langchain/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /langchain/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="langchain" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_LANGCHAIN_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_LANGCHAIN_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_LANGCHAIN_VERSION=${IMAGE_BASIC_LANGCHAIN_VERSION} \ 24 | \ 25 | -f ./make_app_image/Dockerfile \ 26 | -t sparrow-app-$service_name:${IMAGE_APP_LANGCHAIN_VERSION} . ; then 27 | print_error "build image failed" 28 | exit 1 29 | fi 30 | 31 | cd ../ 32 | -------------------------------------------------------------------------------- /langchain/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_LANGCHAIN_NAME 3 | ARG IMAGE_OFFICIAL_LANGCHAIN_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_LANGCHAIN_NAME}:${IMAGE_OFFICIAL_LANGCHAIN_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /langchain/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /langchain/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="langchain" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_LANGCHAIN_NAME=${IMAGE_OFFICIAL_LANGCHAIN_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_LANGCHAIN_VERSION=${IMAGE_OFFICIAL_LANGCHAIN_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_LANGCHAIN_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /langchain/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /mongodb/.env: -------------------------------------------------------------------------------- 1 | ### mongodb ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_MONGODB_NAME=mongo 6 | IMAGE_OFFICIAL_MONGODB_VERSION=4.4.29 # 5.0+ need newer cpu, https://stackoverflow.com/questions/68392064/error-when-running-mongo-image-docker-entrypoint-sh-line-381 7 | # basic image 8 | IMAGE_BASIC_MONGODB_VERSION=4.4.29 9 | # app image 10 | IMAGE_APP_MONGODB_VERSION=latest 11 | # -------------- service config -------------- 12 | MONGODB_HOST_PORT=3500 13 | MONGODB_CONTAINER_PORT=27017 14 | MONGODB_INITDB_ROOT_USERNAME=root # mongo -u root -p mongo123 15 | MONGODB_INITDB_ROOT_PASSWORD=mongo123 16 | -------------------------------------------------------------------------------- /mongodb/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### mongodb ######################################################### 3 | mongodb: 4 | hostname: mongodb 5 | image: sparrow-app-mongodb:${IMAGE_APP_MONGODB_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_mongodb 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./mongodb/:/home/sparrow/mongodb/ 15 | - ./mongodb/templates/mongod.conf:/etc/mongod.conf 16 | - ./mongodb/data/:/data/db # data persistence 17 | ports: 18 | # You don't need to expose the port in the Dockerfile. 19 | - "${MONGODB_HOST_PORT}:${MONGODB_CONTAINER_PORT}" 20 | networks: 21 | - backend 22 | # only for debug 23 | # command: "tail -f /dev/null" 24 | -------------------------------------------------------------------------------- /mongodb/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /mongodb/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /mongodb/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /mongodb/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /mongodb/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /mongodb/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /mongodb/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_MONGODB_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-mongodb:${IMAGE_BASIC_MONGODB_VERSION} 4 | 5 | # https://hub.docker.com/_/mongo 6 | ARG MONGODB_INITDB_ROOT_USERNAME 7 | ARG MONGODB_INITDB_ROOT_PASSWORD 8 | ENV MONGO_INITDB_ROOT_USERNAME ${MONGODB_INITDB_ROOT_USERNAME} 9 | ENV MONGO_INITDB_ROOT_PASSWORD ${MONGODB_INITDB_ROOT_PASSWORD} 10 | 11 | # https://stackoverflow.com/questions/59274734/where-is-mongodb-config-file-located-when-running-not-as-an-ubuntu-service 12 | # https://stackoverflow.com/questions/34559557/how-to-enable-authentication-on-mongodb-through-docker 13 | # https://stackoverflow.com/questions/4881208/how-to-secure-mongodb-with-username-and-password 14 | # https://stackoverflow.com/questions/37372684/mongodb-3-2-authentication-failed 15 | # https://stackoverflow.com/questions/60394290/mongo-db-docker-image-authentication-failed 16 | # CMD ["mongod"] 17 | CMD ["mongod", "--config", "/etc/mongod.conf"] 18 | -------------------------------------------------------------------------------- /mongodb/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /mongodb/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="mongodb" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_MONGODB_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_MONGODB_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_MONGODB_VERSION=${IMAGE_BASIC_MONGODB_VERSION} \ 24 | \ 25 | --build-arg MONGODB_INITDB_ROOT_USERNAME=${MONGODB_INITDB_ROOT_USERNAME} \ 26 | --build-arg MONGODB_INITDB_ROOT_PASSWORD=${MONGODB_INITDB_ROOT_PASSWORD} \ 27 | -f ./make_app_image/Dockerfile \ 28 | -t sparrow-app-$service_name:${IMAGE_APP_MONGODB_VERSION} . ; then 29 | print_error "build image failed" 30 | exit 1 31 | fi 32 | 33 | cd ../ 34 | -------------------------------------------------------------------------------- /mongodb/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_MONGODB_NAME 3 | ARG IMAGE_OFFICIAL_MONGODB_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_MONGODB_NAME}:${IMAGE_OFFICIAL_MONGODB_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /mongodb/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /mongodb/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="mongodb" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_MONGODB_NAME=${IMAGE_OFFICIAL_MONGODB_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_MONGODB_VERSION=${IMAGE_OFFICIAL_MONGODB_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_MONGODB_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /mongodb/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /mongodb/templates/mongod.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WGrape/sparrow/4d273e1aef0b160050df9138578c7078198b2c79/mongodb/templates/mongod.conf -------------------------------------------------------------------------------- /mysql/.env: -------------------------------------------------------------------------------- 1 | ### MYSQL ################################################# 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_MYSQL_NAME=mysql 6 | IMAGE_OFFICIAL_MYSQL_VERSION=8.0 7 | # basic image 8 | IMAGE_BASIC_MYSQL_VERSION=8.0 9 | # app image 10 | IMAGE_APP_MYSQL_VERSION=latest 11 | # -------------- service config -------------- 12 | MYSQL_USER=sparrow 13 | MYSQL_PASSWORD=sparrow 14 | MYSQL_ROOT_USER=root 15 | MYSQL_ROOT_PASSWORD=root 16 | MYSQL_DATABASE=sparrow 17 | MYSQL_HOST_PORT=2600 18 | MYSQL_CONTAINER_PORT=3306 19 | -------------------------------------------------------------------------------- /mysql/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### MYSQL ###################################################### 3 | mysql: 4 | hostname: mysql 5 | image: sparrow-app-mysql:${IMAGE_APP_MYSQL_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_mysql 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./mysql/:/home/sparrow/mysql/ 15 | - ./mysql/templates/my.cnf:/etc/my.cnf 16 | - ./mysql/data/:/var/lib/mysql/ # data persistence 17 | ports: 18 | # You don't need to expose the port in the Dockerfile. 19 | - "${MYSQL_HOST_PORT}:${MYSQL_CONTAINER_PORT}" 20 | networks: 21 | - backend 22 | # only for debug 23 | # command: "tail -f /dev/null" 24 | -------------------------------------------------------------------------------- /mysql/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /mysql/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | 7 | docker exec -d sparrow_container_${CONTAINER_NAMESPACE}_mysql bash /home/sparrow/mysql/init/init.sh 8 | -------------------------------------------------------------------------------- /mysql/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /mysql/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /mysql/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /mysql/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /mysql/init/init.sh: -------------------------------------------------------------------------------- 1 | 2 | #!/bin/sh 3 | 4 | # You can choose any one of the ways of db building. 5 | 6 | # exec sql 7 | # 1. You must wait for 10 seconds as the container may not have been fully created yet. 8 | # 2. You must use root account to do some initialization things. Otherwise, it may be failed. 9 | sleep_seconds 10 10 | mysql --default-character-set=utf8mb4 -u${MYSQL_ROOT_USER} -h localhost -P 3306 -p${MYSQL_ROOT_USER} < /home/sparrow/mysql/init/init.sql 11 | 12 | # upload db 13 | # mysql --default-character-set=utf8mb4 -usparrow -h localhost -P 3306 -psparrow -Dsparrow < exam.db 14 | -------------------------------------------------------------------------------- /mysql/init/init.sql: -------------------------------------------------------------------------------- 1 | -- Input the db.sql 2 | 3 | CREATE DATABASE IF NOT EXISTS sparrow; 4 | 5 | USE sparrow; 6 | CREATE TABLE IF NOT EXISTS test ( 7 | `id` BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, 8 | `timestamp` INT NOT NULL DEFAULT 0 COMMENT '时间戳' 9 | ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; 10 | 11 | -------------------------------------------------------------------------------- /mysql/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_MYSQL_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-mysql:${IMAGE_BASIC_MYSQL_VERSION} 4 | 5 | # ARG TZ 6 | # ENV TZ ${TZ} 7 | # RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && chown -R mysql:root /var/lib/mysql/ 8 | RUN chown -R mysql:root /var/lib/mysql/ 9 | 10 | ARG MYSQL_USER 11 | ARG MYSQL_PASSWORD 12 | ARG MYSQL_ROOT_USER 13 | ARG MYSQL_ROOT_PASSWORD 14 | ARG MYSQL_DATABASE 15 | ENV MYSQL_USER ${MYSQL_USER} 16 | ENV MYSQL_PASSWORD ${MYSQL_PASSWORD} 17 | ENV MYSQL_ROOT_USER ${MYSQL_ROOT_USER} 18 | ENV MYSQL_ROOT_PASSWORD ${MYSQL_ROOT_PASSWORD} 19 | ENV MYSQL_DATABASE ${MYSQL_DATABASE} 20 | 21 | ARG MYSQL_CONTAINER_PORT 22 | ENV MYSQL_TCP_PORT ${MYSQL_CONTAINER_PORT} 23 | # MYSQL_TCP_PORT: https://dev.mysql.com/doc/refman/8.0/en/setting-environment-variables.html 24 | 25 | CMD ["mysqld"] 26 | -------------------------------------------------------------------------------- /mysql/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /mysql/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="mysql" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_MYSQL_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_MYSQL_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_MYSQL_VERSION=${IMAGE_BASIC_MYSQL_VERSION} \ 24 | \ 25 | --build-arg MYSQL_USER=${MYSQL_USER} \ 26 | --build-arg MYSQL_PASSWORD=${MYSQL_PASSWORD} \ 27 | --build-arg MYSQL_ROOT_USER=${MYSQL_ROOT_USER} \ 28 | --build-arg MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \ 29 | --build-arg MYSQL_DATABASE=${MYSQL_DATABASE} \ 30 | --build-arg MYSQL_CONTAINER_PORT=${MYSQL_CONTAINER_PORT} \ 31 | \ 32 | -f ./make_app_image/Dockerfile \ 33 | -t sparrow-app-$service_name:${IMAGE_APP_MYSQL_VERSION} . ; then 34 | print_error "build image failed" 35 | exit 1 36 | fi 37 | 38 | cd ../ 39 | -------------------------------------------------------------------------------- /mysql/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_MYSQL_NAME 3 | ARG IMAGE_OFFICIAL_MYSQL_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_MYSQL_NAME}:${IMAGE_OFFICIAL_MYSQL_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /mysql/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /mysql/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="mysql" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_MYSQL_NAME=${IMAGE_OFFICIAL_MYSQL_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_MYSQL_VERSION=${IMAGE_OFFICIAL_MYSQL_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_MYSQL_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /mysql/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /mysql/templates/my.cnf: -------------------------------------------------------------------------------- 1 | # For advice on how to change settings please see 2 | # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html 3 | 4 | [mysqld] 5 | # 6 | # Remove leading # and set to the amount of RAM for the most important data 7 | # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. 8 | # innodb_buffer_pool_size = 128M 9 | # 10 | # Remove leading # to turn on a very important data integrity option: logging 11 | # changes to the binary log between backups. 12 | # log_bin 13 | # 14 | # Remove leading # to set options mainly useful for reporting servers. 15 | # The server defaults are faster for transactions and fast SELECTs. 16 | # Adjust sizes as needed, experiment to find the optimal values. 17 | # join_buffer_size = 128M 18 | # sort_buffer_size = 2M 19 | # read_rnd_buffer_size = 2M 20 | skip-host-cache 21 | skip-name-resolve 22 | datadir=/var/lib/mysql 23 | socket=/var/run/mysqld/mysqld.sock 24 | secure-file-priv=/var/lib/mysql-files 25 | user=mysql 26 | 27 | # Disabling symbolic-links is recommended to prevent assorted security risks 28 | symbolic-links=0 29 | 30 | #log-error=/var/log/mysqld.log 31 | pid-file=/var/run/mysqld/mysqld.pid 32 | [client] 33 | socket=/var/run/mysqld/mysqld.sock 34 | -------------------------------------------------------------------------------- /nacos/.env: -------------------------------------------------------------------------------- 1 | ### nacos ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_NACOS_NAME=nacos/nacos-server 6 | IMAGE_OFFICIAL_NACOS_VERSION=v2.3.0 7 | # basic image 8 | IMAGE_BASIC_NACOS_VERSION=v2.3.0 9 | # app image 10 | IMAGE_APP_NACOS_VERSION=latest 11 | # -------------- service config -------------- 12 | NACOS_HOST_PORT=4200 13 | NACOS_CONTAINER_PORT=8848 14 | NACOS_MODE=standalone 15 | NACOS_AUTH_ENABLE=true 16 | NACOS_AUTH_TOKEN=P4U1T2dbyghyfusssbufyeeur723dfsazqwbjhdkajdhNf3WNEQTM5Mg # auth_token need use: https://zhuanlan.zhihu.com/p/602021283 17 | NACOS_AUTH_IDENTITY_KEY=sparrow 18 | NACOS_AUTH_IDENTITY_VALUE=sparrow 19 | -------------------------------------------------------------------------------- /nacos/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### nacos ######################################################### 3 | nacos: 4 | hostname: nacos 5 | image: sparrow-app-nacos:${IMAGE_APP_NACOS_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_nacos 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./nacos/:/home/sparrow/nacos/ 15 | - ./nacos/data/:/home/nacos/data/ # data persistence 16 | # - ./nacos/data/conf/application.properties:/home/nacos/conf/application.properties # data persistence 17 | ports: 18 | # You don't need to expose the port in the Dockerfile. 19 | - "${NACOS_HOST_PORT}:${NACOS_CONTAINER_PORT}" 20 | networks: 21 | - backend 22 | # only for debug 23 | # command: "tail -f /dev/null" 24 | -------------------------------------------------------------------------------- /nacos/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /nacos/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /nacos/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /nacos/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /nacos/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /nacos/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /nacos/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_NACOS_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-nacos:${IMAGE_BASIC_NACOS_VERSION} 4 | 5 | ARG NACOS_MODE 6 | ENV MODE ${NACOS_MODE} 7 | 8 | ARG NACOS_AUTH_ENABLE 9 | ENV NACOS_AUTH_ENABLE ${NACOS_AUTH_ENABLE} 10 | 11 | ARG NACOS_AUTH_TOKEN 12 | ENV NACOS_AUTH_TOKEN "${NACOS_AUTH_TOKEN}" 13 | 14 | ARG NACOS_AUTH_IDENTITY_KEY 15 | ENV NACOS_AUTH_IDENTITY_KEY ${NACOS_AUTH_IDENTITY_KEY} 16 | 17 | ARG NACOS_AUTH_IDENTITY_VALUE 18 | ENV NACOS_AUTH_IDENTITY_VALUE ${NACOS_AUTH_IDENTITY_VALUE} 19 | 20 | COPY ./templates/application.properties /home/nacos/conf/application.properties 21 | -------------------------------------------------------------------------------- /nacos/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /nacos/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="nacos" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_NACOS_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_NACOS_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_NACOS_VERSION=${IMAGE_BASIC_NACOS_VERSION} \ 24 | --build-arg NACOS_MODE=${NACOS_MODE} \ 25 | --build-arg NACOS_AUTH_ENABLE=${NACOS_AUTH_ENABLE} \ 26 | --build-arg NACOS_AUTH_TOKEN="${NACOS_AUTH_TOKEN}" \ 27 | --build-arg NACOS_AUTH_IDENTITY_KEY=${NACOS_AUTH_IDENTITY_KEY} \ 28 | --build-arg NACOS_AUTH_IDENTITY_VALUE=${NACOS_AUTH_IDENTITY_VALUE} \ 29 | \ 30 | -f ./make_app_image/Dockerfile \ 31 | -t sparrow-app-$service_name:${IMAGE_APP_NACOS_VERSION} . ; then 32 | print_error "build image failed" 33 | exit 1 34 | fi 35 | 36 | cd ../ 37 | -------------------------------------------------------------------------------- /nacos/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_NACOS_NAME 3 | ARG IMAGE_OFFICIAL_NACOS_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_NACOS_NAME}:${IMAGE_OFFICIAL_NACOS_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /nacos/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /nacos/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="nacos" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_NACOS_NAME=${IMAGE_OFFICIAL_NACOS_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_NACOS_VERSION=${IMAGE_OFFICIAL_NACOS_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_NACOS_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /nacos/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /nginx/.env: -------------------------------------------------------------------------------- 1 | ### NGINX ################################################# 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_NGINX_NAME=nginx 6 | IMAGE_OFFICIAL_NGINX_VERSION=alpine 7 | # basic image 8 | IMAGE_BASIC_NGINX_VERSION=alpine 9 | # app image 10 | IMAGE_APP_NGINX_VERSION=latest 11 | # -------------- service config -------------- 12 | NGINX_HOST_HTTP_PORT=80 13 | NGINX_CONTAINER_HTTP_PORT=80 14 | NGINX_HOST_HTTPS_PORT=443 15 | NGINX_CONTAINER_HTTPS_PORT=443 # not supporting custom configurations 16 | NGINX_HOST_GO_PROXY_PORT=2700 17 | NGINX_CONTAINER_GO_PROXY_PORT=2700 # you'd better set go server bind 0.0.0.0 18 | NGINX_HOST_PHPFPM_PROXY_PORT=2701 19 | NGINX_CONTAINER_PHPFPM_PROXY_PORT=2701 # you'd better set phpfpm server bind 0.0.0.0 20 | NGINX_HOST_PYTHON_PROXY_PORT=2702 21 | NGINX_CONTAINER_PYTHON_PROXY_PORT=2702 # you'd better set python server bind 0.0.0.0 22 | NGINX_APK_CHINA_SOURCE=true 23 | NGINX_LOG_PATH=./nginx/logs/ 24 | NGINX_SITES_PATH=./nginx/templates/sites/ 25 | -------------------------------------------------------------------------------- /nginx/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /nginx/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /nginx/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /nginx/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /nginx/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /nginx/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /nginx/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_NGINX_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-nginx:${IMAGE_BASIC_NGINX_VERSION} 4 | 5 | ARG NGINX_APK_CHINA_SOURCE=false 6 | RUN if [ ${NGINX_APK_CHINA_SOURCE} = true ]; then \ 7 | # this source may cause some errors. 8 | # sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \ 9 | # so use this source. 10 | sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ 11 | ;fi 12 | 13 | RUN apk update \ 14 | && apk upgrade \ 15 | && apk --update add logrotate \ 16 | && apk add --no-cache openssl \ 17 | && apk add --no-cache bash 18 | 19 | RUN apk add --no-cache curl 20 | 21 | RUN set -x ; \ 22 | addgroup -g 82 -S www-data ; \ 23 | adduser -u 82 -D -S -G www-data www-data && exit 0 ; exit 1 24 | 25 | # Create 'messages' file used from 'logrotate' 26 | RUN touch /var/log/messages 27 | 28 | # Copy 'logrotate' config file 29 | COPY ./templates/logrotate/nginx /etc/logrotate.d/ 30 | 31 | ARG NGINX_CONTAINER_HTTP_PORT 32 | ENV NGINX_PORT ${NGINX_CONTAINER_HTTP_PORT} 33 | 34 | COPY ./templates/nginx.conf /etc/nginx/nginx.conf 35 | COPY ./templates/startup.sh /opt/startup.sh 36 | RUN sed -i 's/\r//g' /opt/startup.sh 37 | 38 | CMD ["/bin/bash", "/opt/startup.sh"] 39 | -------------------------------------------------------------------------------- /nginx/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /nginx/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="nginx" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_NGINX_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_NGINX_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_NGINX_VERSION=${IMAGE_BASIC_NGINX_VERSION} \ 24 | \ 25 | --build-arg NGINX_APK_CHINA_SOURCE=${NGINX_APK_CHINA_SOURCE} \ 26 | \ 27 | --build-arg NGINX_PHPFPM_UPSTREAM_PORT=${NGINX_PHPFPM_UPSTREAM_PORT} \ 28 | --build-arg NGINX_PHPFPM_UPSTREAM_CONTAINER=${NGINX_PHPFPM_UPSTREAM_CONTAINER} \ 29 | \ 30 | -f ./make_app_image/Dockerfile \ 31 | -t sparrow-app-$service_name:${IMAGE_APP_NGINX_VERSION} . ; then 32 | print_error "build image failed" 33 | exit 1 34 | fi 35 | 36 | cd ../ 37 | -------------------------------------------------------------------------------- /nginx/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_NGINX_NAME 3 | ARG IMAGE_OFFICIAL_NGINX_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_NGINX_NAME}:${IMAGE_OFFICIAL_NGINX_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /nginx/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /nginx/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="nginx" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_NGINX_NAME=${IMAGE_OFFICIAL_NGINX_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_NGINX_VERSION=${IMAGE_OFFICIAL_NGINX_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_NGINX_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /nginx/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /nginx/templates/logrotate/nginx: -------------------------------------------------------------------------------- 1 | /var/log/nginx/*.log { 2 | daily 3 | missingok 4 | rotate 32 5 | compress 6 | delaycompress 7 | nodateext 8 | notifempty 9 | create 644 www-data root 10 | sharedscripts 11 | postrotate 12 | [ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` 13 | endscript 14 | } 15 | -------------------------------------------------------------------------------- /nginx/templates/sites/phpproxy.conf.template: -------------------------------------------------------------------------------- 1 | server { 2 | listen {{php_proxy_port}}; 3 | 4 | location / { 5 | proxy_pass http://{{php_server_addr}}:{{php_server_port}}; 6 | proxy_set_header Host $host; 7 | proxy_set_header X-Real-IP $remote_addr; 8 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 9 | proxy_set_header X-Forwarded-Proto $scheme; 10 | } 11 | 12 | error_log /var/log/nginx/nginx_error.log; 13 | access_log /var/log/nginx/phpproxy_access.log; 14 | } 15 | 16 | # server { 17 | # listen 8003; 18 | # 19 | # location / { 20 | # proxy_pass http://172.24.0.1:8002; # notice not use the 127.0.0.1, must use the ip of the container 21 | # proxy_set_header Host $host; 22 | # proxy_set_header X-Real-IP $remote_addr; 23 | # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 24 | # proxy_set_header X-Forwarded-Proto $scheme; 25 | # } 26 | # 27 | # error_log /var/log/nginx/nginx_error.log; 28 | # access_log /var/log/nginx/server_access.log; 29 | # } 30 | -------------------------------------------------------------------------------- /nginx/templates/sites/pythonproxy.conf.template: -------------------------------------------------------------------------------- 1 | server { 2 | listen {{python_proxy_port}}; 3 | 4 | location / { 5 | proxy_pass http://{{python_server_addr}}:{{python_server_port}}; 6 | proxy_set_header Host $host; 7 | proxy_set_header X-Real-IP $remote_addr; 8 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 9 | proxy_set_header X-Forwarded-Proto $scheme; 10 | } 11 | 12 | error_log /var/log/nginx/nginx_error.log; 13 | access_log /var/log/nginx/pythonproxy_access.log; 14 | } 15 | 16 | # server { 17 | # listen 8003; 18 | # 19 | # location / { 20 | # proxy_pass http://172.24.0.1:8002; # notice not use the 127.0.0.1, must use the ip of the container 21 | # proxy_set_header Host $host; 22 | # proxy_set_header X-Real-IP $remote_addr; 23 | # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 24 | # proxy_set_header X-Forwarded-Proto $scheme; 25 | # } 26 | # 27 | # error_log /var/log/nginx/nginx_error.log; 28 | # access_log /var/log/nginx/server_access.log; 29 | # } 30 | -------------------------------------------------------------------------------- /nginx/templates/startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -f /etc/nginx/ssl/default.crt ]; then 4 | mkdir -p "/etc/nginx/ssl/" 5 | openssl genrsa -out "/etc/nginx/ssl/default.key" 2048 6 | openssl req -new -key "/etc/nginx/ssl/default.key" -out "/etc/nginx/ssl/default.csr" -subj "/CN=default/O=default/C=UK" 7 | openssl x509 -req -days 365 -in "/etc/nginx/ssl/default.csr" -signkey "/etc/nginx/ssl/default.key" -out "/etc/nginx/ssl/default.crt" 8 | chmod 644 /etc/nginx/ssl/default.key 9 | fi 10 | 11 | # Start crond in background 12 | crond -l 2 -b 13 | 14 | # Start nginx in foreground 15 | nginx 16 | -------------------------------------------------------------------------------- /nodejs/.env: -------------------------------------------------------------------------------- 1 | ### nodejs ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_NODEJS_NAME=node 6 | IMAGE_OFFICIAL_NODEJS_VERSION=18.19.0 7 | # basic image 8 | IMAGE_BASIC_NODEJS_VERSION=18.19.0 9 | # app image 10 | IMAGE_APP_NODEJS_VERSION=latest 11 | # -------------- service config -------------- 12 | NODEJS_HOST_PORT=3400 13 | NODEJS_CONTAINER_PORT=3400 14 | -------------------------------------------------------------------------------- /nodejs/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### nodejs ######################################################### 3 | nodejs: 4 | hostname: nodejs 5 | image: sparrow-app-nodejs:${IMAGE_APP_NODEJS_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_nodejs 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./nodejs/:/home/sparrow/nodejs/ 15 | - ./nodejs/data/:/var/data/nodejs/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${NODEJS_HOST_PORT}:${NODEJS_CONTAINER_PORT}" 19 | networks: 20 | - backend 21 | # only for debug 22 | # command: "tail -f /dev/null" 23 | command: "tail -f /dev/null" # Because there is no startup command for the nodejs service, use this command to ensure it can be started successfully. 24 | -------------------------------------------------------------------------------- /nodejs/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /nodejs/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /nodejs/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /nodejs/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /nodejs/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /nodejs/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /nodejs/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_NODEJS_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-nodejs:${IMAGE_BASIC_NODEJS_VERSION} 4 | -------------------------------------------------------------------------------- /nodejs/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /nodejs/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="nodejs" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_NODEJS_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_NODEJS_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_NODEJS_VERSION=${IMAGE_BASIC_NODEJS_VERSION} \ 24 | \ 25 | -f ./make_app_image/Dockerfile \ 26 | -t sparrow-app-$service_name:${IMAGE_APP_NODEJS_VERSION} . ; then 27 | print_error "build image failed" 28 | exit 1 29 | fi 30 | 31 | cd ../ 32 | -------------------------------------------------------------------------------- /nodejs/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_NODEJS_NAME 3 | ARG IMAGE_OFFICIAL_NODEJS_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_NODEJS_NAME}:${IMAGE_OFFICIAL_NODEJS_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /nodejs/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /nodejs/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="nodejs" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_NODEJS_NAME=${IMAGE_OFFICIAL_NODEJS_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_NODEJS_VERSION=${IMAGE_OFFICIAL_NODEJS_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_NODEJS_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /nodejs/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /phpfpm/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### PHPFPM ##################################################### 3 | phpfpm: 4 | hostname: phpfpm 5 | image: sparrow-app-phpfpm:${IMAGE_APP_PHPFPM_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_phpfpm 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./phpfpm/:/home/sparrow/phpfpm/ 15 | - ./phpfpm/data/:/var/data/phpfpm/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 16 | - ${PHPFPM_LOCALHOST_LARAVEL_APP_LOG_PATH}:${PHPFPM_LARAVEL_APP_LOG_PATH} 17 | extra_hosts: 18 | - "dockerhost:${DOCKER_HOST_IP}" 19 | - "host.docker.internal:${DOCKER_HOST_IP}" 20 | ports: 21 | # You don't need to expose the port in the Dockerfile. 22 | - "${PHPFPM_HOST_PORT}:${PHPFPM_CONTAINER_PORT}" 23 | - "${PHPFPM_HOST_XDEBUG_PORT}:${PHPFPM_CONTAINER_XDEBUG_PORT}" 24 | networks: 25 | - backend 26 | # only for debug 27 | # command: "tail -f /dev/null" 28 | -------------------------------------------------------------------------------- /phpfpm/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /phpfpm/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | 7 | docker exec -e PHPFPM_LARAVEL_APP_LOG_PATH=$PHPFPM_LARAVEL_APP_LOG_PATH -d sparrow_container_${CONTAINER_NAMESPACE}_phpfpm bash /home/sparrow/phpfpm/init/init.sh 8 | -------------------------------------------------------------------------------- /phpfpm/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /phpfpm/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /phpfpm/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /phpfpm/init/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | current_dir=$(pwd) 4 | 5 | printf "init phpfpm ...\n\n" 6 | printf "\n" 7 | printf "sleep 10 seconds ...\n\n" 8 | sleep 10 9 | 10 | # Switch the composer mirror to avoid some errors. 11 | # Such as the network error, the authentication required error. 12 | composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ 13 | 14 | # Traverse all php-fpm project directories under /var/data/phpfpm/ and execute composer install 15 | auto_composer_install=false 16 | if [ "${auto_composer_install}" = "true" ]; then 17 | for dir in /var/data/phpfpm/*; do 18 | # Check if the directory is a directory and contains a composer.json file 19 | if [[ -d "$dir" && -f "$dir/composer.json" ]]; then 20 | # Change to the project directory 21 | cd "$dir" 22 | 23 | # Execute composer install command 24 | # It will take long times ... just wait for a while 25 | composer install 26 | fi 27 | done 28 | fi 29 | 30 | # Create some must directories 31 | if [ "${PHPFPM_LARAVEL_APP_LOG_PATH}" != "" ]; then 32 | mkdir -p ${PHPFPM_LARAVEL_APP_LOG_PATH} 33 | chmod -R 777 ${PHPFPM_LARAVEL_APP_LOG_PATH} 34 | fi 35 | 36 | cd ${current_dir} 37 | -------------------------------------------------------------------------------- /phpfpm/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /phpfpm/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_PHPFPM_NAME 3 | ARG IMAGE_OFFICIAL_PHPFPM_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_PHPFPM_NAME}:${IMAGE_OFFICIAL_PHPFPM_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /phpfpm/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /phpfpm/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="phpfpm" 9 | 10 | cd $service_name/ 11 | docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_PHPFPM_NAME=${IMAGE_OFFICIAL_PHPFPM_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_PHPFPM_VERSION=${IMAGE_OFFICIAL_PHPFPM_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_PHPFPM_VERSION} . 18 | 19 | cd ../ 20 | -------------------------------------------------------------------------------- /phpfpm/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /phpfpm/templates/xdebug.ini: -------------------------------------------------------------------------------- 1 | ; NOTE: The actual debug.so extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini) 2 | zend_extension=xdebug.so 3 | 4 | xdebug.remote_host="host.docker.internal" 5 | xdebug.remote_connect_back=0 6 | xdebug.remote_port=9000 7 | xdebug.idekey=PHPSTORM 8 | 9 | xdebug.remote_autostart=0 10 | xdebug.remote_enable=0 11 | xdebug.cli_color=0 12 | xdebug.profiler_enable=0 13 | xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling" 14 | 15 | xdebug.remote_handler=dbgp 16 | xdebug.remote_mode=req 17 | 18 | xdebug.var_display_max_children=-1 19 | xdebug.var_display_max_data=-1 20 | xdebug.var_display_max_depth=-1 21 | 22 | xdebug.log=/tmp/xdebug_remote.log 23 | -------------------------------------------------------------------------------- /phpfpm/templates/xhprof.ini: -------------------------------------------------------------------------------- 1 | [xhprof] 2 | ; extension=xhprof.so 不需要再开启xhprof, 因为phpfpm镜像文件中已经使用`docker-php-ext-enable xhprof;`开启过了 3 | ; extension=tideways_xhprof.so 开启这个文件应该使用xhprof.so不能叫tideways_xhprof.so, 因为文件名是xhprof.so, 由于之前已经开启了xhprof.so, 所以这里就不再次开启xhprof.so所以注释掉 4 | xhprof.output_dir=/tmp/ 5 | ; no need to autoload, control in the program 6 | tideways.auto_prepend_library=0 7 | ; set default rate 8 | tideways.sample_rate=100 9 | -------------------------------------------------------------------------------- /postgres/.env: -------------------------------------------------------------------------------- 1 | ### POSTGRES ############################################## 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_POSTGRES_NAME=postgres 6 | IMAGE_OFFICIAL_POSTGRES_VERSION=15-alpine 7 | # basic image 8 | IMAGE_BASIC_POSTGRES_VERSION=15-alpine 9 | # app image 10 | IMAGE_APP_POSTGRES_VERSION=latest 11 | # -------------- service config -------------- 12 | POSTGRES_DB=default 13 | POSTGRES_USER=default 14 | POSTGRES_PASSWORD=secret 15 | POSTGRES_HOST_PORT=2900 16 | POSTGRES_CONTAINER_PORT=5432 # not supporting custom configurations 17 | -------------------------------------------------------------------------------- /postgres/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### POSTGRES ################################################### 3 | postgres: 4 | hostname: postgres 5 | image: sparrow-app-postgres:${IMAGE_APP_POSTGRES_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_postgres 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./postgres/:/home/sparrow/postgres/ 15 | - ./postgres/data/:/var/lib/postgresql/data/ # data persistence 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${POSTGRES_HOST_PORT}:${POSTGRES_CONTAINER_PORT}" 19 | networks: 20 | - backend 21 | # only for debug 22 | # command: "tail -f /dev/null" 23 | -------------------------------------------------------------------------------- /postgres/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /postgres/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /postgres/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /postgres/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /postgres/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /postgres/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /postgres/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_POSTGRES_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-postgres:${IMAGE_BASIC_POSTGRES_VERSION} 4 | 5 | ARG POSTGRES_DB 6 | ARG POSTGRES_USER 7 | ARG POSTGRES_PASSWORD 8 | ENV POSTGRES_DB ${POSTGRES_DB} 9 | ENV POSTGRES_USER ${POSTGRES_USER} 10 | ENV POSTGRES_PASSWORD ${POSTGRES_PASSWORD} 11 | 12 | CMD ["postgres"] 13 | -------------------------------------------------------------------------------- /postgres/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /postgres/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="postgres" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_POSTGRES_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_POSTGRES_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_POSTGRES_VERSION=${IMAGE_BASIC_POSTGRES_VERSION} \ 24 | \ 25 | --build-arg POSTGRES_DB=${POSTGRES_DB} \ 26 | --build-arg POSTGRES_USER=${POSTGRES_USER} \ 27 | --build-arg POSTGRES_PASSWORD=${POSTGRES_PASSWORD} \ 28 | --build-arg POSTGRES_CONTAINER_PORT=${POSTGRES_CONTAINER_PORT} \ 29 | \ 30 | -f ./make_app_image/Dockerfile \ 31 | -t sparrow-app-$service_name:${IMAGE_APP_POSTGRES_VERSION} . 32 | 33 | cd ../ 34 | -------------------------------------------------------------------------------- /postgres/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_POSTGRES_NAME 3 | ARG IMAGE_OFFICIAL_POSTGRES_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_POSTGRES_NAME}:${IMAGE_OFFICIAL_POSTGRES_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /postgres/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /postgres/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="postgres" 9 | 10 | cd $service_name/ 11 | docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_POSTGRES_NAME=${IMAGE_OFFICIAL_POSTGRES_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_POSTGRES_VERSION=${IMAGE_OFFICIAL_POSTGRES_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_POSTGRES_VERSION} . 18 | 19 | cd ../ 20 | -------------------------------------------------------------------------------- /postgres/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /prometheus/.env: -------------------------------------------------------------------------------- 1 | ### prometheus ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_PROMETHEUS_NAME=prom/prometheus 6 | IMAGE_OFFICIAL_PROMETHEUS_VERSION=v2.48.0 7 | # basic image 8 | IMAGE_BASIC_PROMETHEUS_VERSION=v2.48.0 9 | # app image 10 | IMAGE_APP_PROMETHEUS_VERSION=latest 11 | # -------------- service config -------------- 12 | PROMETHEUS_HOST_PORT=3700 13 | PROMETHEUS_CONTAINER_PORT=9090 14 | -------------------------------------------------------------------------------- /prometheus/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### prometheus ######################################################### 3 | prometheus: 4 | hostname: prometheus 5 | image: sparrow-app-prometheus:${IMAGE_APP_PROMETHEUS_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_prometheus 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./prometheus/:/home/sparrow/prometheus/ 15 | # https://stackoverflow.com/questions/50009065/how-to-persist-data-in-prometheus-running-in-a-docker-container 16 | - ./prometheus/data/:/prometheus # data persistence 17 | ports: 18 | # You don't need to expose the port in the Dockerfile. 19 | - "${PROMETHEUS_HOST_PORT}:${PROMETHEUS_CONTAINER_PORT}" 20 | networks: 21 | - backend 22 | # only for debug 23 | # command: "tail -f /dev/null" 24 | -------------------------------------------------------------------------------- /prometheus/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /prometheus/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /prometheus/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /prometheus/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /prometheus/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /prometheus/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /prometheus/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_PROMETHEUS_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-prometheus:${IMAGE_BASIC_PROMETHEUS_VERSION} 4 | 5 | # https://hub.docker.com/r/prom/prometheus 6 | 7 | COPY ./templates/prometheus.yml /etc/prometheus/prometheus.yml 8 | -------------------------------------------------------------------------------- /prometheus/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /prometheus/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="prometheus" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_PROMETHEUS_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_PROMETHEUS_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_PROMETHEUS_VERSION=${IMAGE_BASIC_PROMETHEUS_VERSION} \ 24 | \ 25 | -f ./make_app_image/Dockerfile \ 26 | -t sparrow-app-$service_name:${IMAGE_APP_PROMETHEUS_VERSION} . ; then 27 | print_error "build image failed" 28 | exit 1 29 | fi 30 | 31 | cd ../ 32 | -------------------------------------------------------------------------------- /prometheus/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_PROMETHEUS_NAME 3 | ARG IMAGE_OFFICIAL_PROMETHEUS_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_PROMETHEUS_NAME}:${IMAGE_OFFICIAL_PROMETHEUS_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /prometheus/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /prometheus/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="prometheus" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_PROMETHEUS_NAME=${IMAGE_OFFICIAL_PROMETHEUS_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_PROMETHEUS_VERSION=${IMAGE_OFFICIAL_PROMETHEUS_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_PROMETHEUS_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /prometheus/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /prometheus/templates/prometheus.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WGrape/sparrow/4d273e1aef0b160050df9138578c7078198b2c79/prometheus/templates/prometheus.yml -------------------------------------------------------------------------------- /prompthub/.env: -------------------------------------------------------------------------------- 1 | ### prompthub ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_PROMPTHUB_NAME=deepset/prompthub 6 | IMAGE_OFFICIAL_PROMPTHUB_VERSION=v0.17 7 | # basic image 8 | IMAGE_BASIC_PROMPTHUB_VERSION=v0.17 9 | # app image 10 | IMAGE_APP_PROMPTHUB_VERSION=latest 11 | # -------------- service config -------------- 12 | PROMPTHUB_HOST_PORT=4100 13 | PROMPTHUB_CONTAINER_PORT=80 14 | -------------------------------------------------------------------------------- /prompthub/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### prompthub ######################################################### 3 | prompthub: 4 | hostname: prompthub 5 | image: sparrow-app-prompthub:${IMAGE_APP_PROMPTHUB_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_prompthub 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./prompthub/:/home/sparrow/prompthub/ 15 | - ./prompthub/data/:/prompts/ # data persistence 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${PROMPTHUB_HOST_PORT}:${PROMPTHUB_CONTAINER_PORT}" 19 | networks: 20 | - backend 21 | # only for debug 22 | # command: "tail -f /dev/null" 23 | -------------------------------------------------------------------------------- /prompthub/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /prompthub/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /prompthub/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /prompthub/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /prompthub/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /prompthub/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /prompthub/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_PROMPTHUB_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-prompthub:${IMAGE_BASIC_PROMPTHUB_VERSION} 4 | -------------------------------------------------------------------------------- /prompthub/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /prompthub/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="prompthub" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_PROMPTHUB_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_PROMPTHUB_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_PROMPTHUB_VERSION=${IMAGE_BASIC_PROMPTHUB_VERSION} \ 24 | \ 25 | -f ./make_app_image/Dockerfile \ 26 | -t sparrow-app-$service_name:${IMAGE_APP_PROMPTHUB_VERSION} . ; then 27 | print_error "build image failed" 28 | exit 1 29 | fi 30 | 31 | cd ../ 32 | -------------------------------------------------------------------------------- /prompthub/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_PROMPTHUB_NAME 3 | ARG IMAGE_OFFICIAL_PROMPTHUB_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_PROMPTHUB_NAME}:${IMAGE_OFFICIAL_PROMPTHUB_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /prompthub/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /prompthub/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="prompthub" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_PROMPTHUB_NAME=${IMAGE_OFFICIAL_PROMPTHUB_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_PROMPTHUB_VERSION=${IMAGE_OFFICIAL_PROMPTHUB_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_PROMPTHUB_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /prompthub/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | -------------------------------------------------------------------------------- /prompthub/templates/deepset-zero-shot-react.md: -------------------------------------------------------------------------------- 1 | This prompt is intended to be used with a Haystack `Agent`. It's the backbone of an LLM powered `Agent` and expects to be provided `Tools`. 2 | 3 | To learn how to use this prompt and an `Agent` check out our [Answering Multihop Questions with Agents Tutorial](https://haystack.deepset.ai/tutorials/23_answering_multihop_questions_with_agents). 4 | 5 | ## How to use in Haystack 6 | 7 | To use this prompt from the PromptHub in an Agent: 8 | 9 | ```python 10 | import os 11 | 12 | from haystack.agents import Agent 13 | from haystack.nodes import PromptNode, PromptTemplate 14 | 15 | zero_shot_agent_template = PromptTemplate("deepset/zero-shot-react") 16 | 17 | prompt_node = PromptNode(model_name_or_path="text-davinci-003", api_key=os.environ.get("OPENAI_API_KEY"), stop_words=["Observation:"]) 18 | agent = Agent(prompt_node=prompt_node, prompt_template=zero_shot_agent_template) 19 | 20 | agent.run("Your query") 21 | ``` 22 | -------------------------------------------------------------------------------- /python/.env: -------------------------------------------------------------------------------- 1 | ### PYTHON ################################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_PYTHON_NAME=python 6 | IMAGE_OFFICIAL_PYTHON_VERSION=3.10.13 7 | # basic image 8 | IMAGE_BASIC_PYTHON_VERSION=3.10.13 9 | # app image 10 | IMAGE_APP_PYTHON_VERSION=latest 11 | # -------------- service config -------------- 12 | PYTHON_HOST_PORT=3000 13 | PYTHON_CONTAINER_PORT=3000 14 | -------------------------------------------------------------------------------- /python/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### PYTHON ##################################################### 3 | python: 4 | hostname: python 5 | image: sparrow-app-python:${IMAGE_APP_PYTHON_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_python 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./python/:/home/sparrow/python/ 15 | - ./python/data/:/var/data/python/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${PYTHON_HOST_PORT}:${PYTHON_CONTAINER_PORT}" 19 | tty: true # must set the field 20 | # command: "tail -f /dev/null" # only for debug 21 | networks: 22 | - backend 23 | # only for debug 24 | # command: "tail -f /dev/null" 25 | -------------------------------------------------------------------------------- /python/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /python/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /python/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /python/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /python/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /python/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /python/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_PYTHON_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-python:${IMAGE_BASIC_PYTHON_VERSION} 4 | 5 | # change source 6 | RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ 7 | # download dependences 8 | RUN pip install openai && pip install mysql-connector-python && pip install pyyaml && pip install pytz && pip install flask && pip install pandas && pip install requests 9 | -------------------------------------------------------------------------------- /python/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /python/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="python" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_PYTHON_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_PYTHON_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_PYTHON_VERSION=${IMAGE_BASIC_PYTHON_VERSION} \ 24 | \ 25 | --build-arg PYTHON_CONTAINER_PORT=${PYTHON_CONTAINER_PORT} \ 26 | \ 27 | -f ./make_app_image/Dockerfile \ 28 | -t sparrow-app-$service_name:${IMAGE_APP_PYTHON_VERSION} . 29 | 30 | cd ../ 31 | -------------------------------------------------------------------------------- /python/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_PYTHON_NAME 3 | ARG IMAGE_OFFICIAL_PYTHON_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_PYTHON_NAME}:${IMAGE_OFFICIAL_PYTHON_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /python/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /python/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="python" 9 | 10 | cd $service_name/ 11 | docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_PYTHON_NAME=${IMAGE_OFFICIAL_PYTHON_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_PYTHON_VERSION=${IMAGE_OFFICIAL_PYTHON_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_PYTHON_VERSION} . 18 | 19 | cd ../ 20 | -------------------------------------------------------------------------------- /python/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /redis/.env: -------------------------------------------------------------------------------- 1 | ### Redis ################################################# 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_REDIS_NAME=redis 6 | IMAGE_OFFICIAL_REDIS_VERSION=5.0 7 | # basic image 8 | IMAGE_BASIC_REDIS_VERSION=5.0 9 | # app image 10 | IMAGE_APP_REDIS_VERSION=latest 11 | # -------------- service config -------------- 12 | REDIS_HOST_PORT=3100 13 | REDIS_CONTAINER_PORT=6379 # not supporting custom configurations 14 | REDIS_PASSWORD=secret_redis 15 | -------------------------------------------------------------------------------- /redis/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### REDIS ###################################################### 3 | redis: 4 | hostname: redis 5 | image: sparrow-app-redis:${IMAGE_APP_REDIS_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_redis 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./redis/:/home/sparrow/redis/ 15 | - ./redis/data/:/var/data/redis/ # data persistence, use a common data persistence directory /var/data/{SERVICE} 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${REDIS_HOST_PORT}:${REDIS_CONTAINER_PORT}" 19 | networks: 20 | - backend 21 | # only for debug 22 | # command: "tail -f /dev/null" 23 | -------------------------------------------------------------------------------- /redis/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /redis/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /redis/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /redis/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /redis/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /redis/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /redis/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_REDIS_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-redis:${IMAGE_BASIC_REDIS_VERSION} 4 | 5 | ARG REDIS_PASSWORD 6 | ARG REDIS_PERSISTENCE_DIR="\/var\/data\/redis\/" 7 | COPY ./templates/redis.conf /etc/redis.conf 8 | RUN sed -i "s/REDIS_PASSWORD/${REDIS_PASSWORD}/g" /etc/redis.conf 9 | RUN sed -i "s/REDIS_PERSISTENCE_DIR/${REDIS_PERSISTENCE_DIR}/g" /etc/redis.conf 10 | 11 | CMD ["redis-server", "/etc/redis.conf"] 12 | -------------------------------------------------------------------------------- /redis/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /redis/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="redis" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_REDIS_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_REDIS_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_REDIS_VERSION=${IMAGE_BASIC_REDIS_VERSION} \ 24 | \ 25 | --build-arg REDIS_PORT=${REDIS_PORT} \ 26 | --build-arg REDIS_CONTAINER_PORT=${REDIS_CONTAINER_PORT} \ 27 | --build-arg REDIS_PASSWORD=${REDIS_PASSWORD} \ 28 | \ 29 | -f ./make_app_image/Dockerfile \ 30 | -t sparrow-app-$service_name:${IMAGE_APP_REDIS_VERSION} . 31 | 32 | cd ../ 33 | -------------------------------------------------------------------------------- /redis/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_REDIS_NAME 3 | ARG IMAGE_OFFICIAL_REDIS_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_REDIS_NAME}:${IMAGE_OFFICIAL_REDIS_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /redis/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /redis/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="redis" 9 | 10 | cd $service_name/ 11 | docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_REDIS_NAME=${IMAGE_OFFICIAL_REDIS_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_REDIS_VERSION=${IMAGE_OFFICIAL_REDIS_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_REDIS_VERSION} . 18 | 19 | cd ../ 20 | -------------------------------------------------------------------------------- /redis/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /ssdb/.env: -------------------------------------------------------------------------------- 1 | ### ssdb ############################################ 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_SSDB_NAME=cleardevice/ssdb # ssdb don't have official image: https://hub.docker.com/r/cleardevice/ssdb/tags 6 | IMAGE_OFFICIAL_SSDB_VERSION=latest 7 | # basic image 8 | IMAGE_BASIC_SSDB_VERSION=latest 9 | # app image 10 | IMAGE_APP_SSDB_VERSION=latest 11 | # -------------- service config -------------- 12 | SSDB_HOST_PORT=3600 13 | SSDB_CONTAINER_PORT=8888 14 | -------------------------------------------------------------------------------- /ssdb/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### ssdb ######################################################### 3 | ssdb: 4 | hostname: ssdb 5 | image: sparrow-app-ssdb:${IMAGE_APP_SSDB_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_ssdb 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./ssdb/:/home/sparrow/ssdb/ 15 | - ./ssdb/data/:/ssdb/data # data persistence 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${SSDB_HOST_PORT}:${SSDB_CONTAINER_PORT}" 19 | networks: 20 | - backend 21 | # only for debug 22 | # command: "tail -f /dev/null" 23 | -------------------------------------------------------------------------------- /ssdb/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /ssdb/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /ssdb/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /ssdb/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /ssdb/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # include sdk of sparrow. 4 | . .work/include/sdk.sh 5 | -------------------------------------------------------------------------------- /ssdb/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /ssdb/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_SSDB_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-ssdb:${IMAGE_BASIC_SSDB_VERSION} 4 | 5 | # Not Found File Error: RUN cp ./templates/ssdb.conf /ssdb/conf/ssdb.conf 6 | COPY ./templates/ssdb.conf /ssdb/conf/ssdb.conf 7 | 8 | CMD ["/bin/sh", "-c", "/ssdb/ssdb-server /ssdb/conf/ssdb.conf"] 9 | -------------------------------------------------------------------------------- /ssdb/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /ssdb/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="ssdb" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_SSDB_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_SSDB_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | if ! docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_SSDB_VERSION=${IMAGE_BASIC_SSDB_VERSION} \ 24 | \ 25 | -f ./make_app_image/Dockerfile \ 26 | -t sparrow-app-$service_name:${IMAGE_APP_SSDB_VERSION} . ; then 27 | print_error "build image failed" 28 | exit 1 29 | fi 30 | 31 | cd ../ 32 | -------------------------------------------------------------------------------- /ssdb/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_SSDB_NAME 3 | ARG IMAGE_OFFICIAL_SSDB_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_SSDB_NAME}:${IMAGE_OFFICIAL_SSDB_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /ssdb/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /ssdb/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="ssdb" 9 | 10 | cd $service_name/ 11 | if ! docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_SSDB_NAME=${IMAGE_OFFICIAL_SSDB_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_SSDB_VERSION=${IMAGE_OFFICIAL_SSDB_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_SSDB_VERSION} . ; then 18 | print_error "build image failed" 19 | exit 1 20 | fi 21 | 22 | cd ../ 23 | -------------------------------------------------------------------------------- /ssdb/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | -------------------------------------------------------------------------------- /ssdb/templates/ssdb.conf: -------------------------------------------------------------------------------- 1 | # ssdb-server config 2 | # MUST indent by TAB! 3 | 4 | # absolute path, or relative to path of this file, directory must exists 5 | work_dir = /ssdb 6 | pidfile = /ssdb/ssdb.pid 7 | 8 | server: 9 | # specify an ipv6 address to enable ipv6 support 10 | # ip: ::1 11 | ip: 127.0.0.1 12 | port: 8888 13 | # bind to public ip 14 | #ip: 0.0.0.0 15 | # format: allow|deny: all|ip_prefix 16 | # multiple allows or denys is supported 17 | #deny: all 18 | #allow: 127.0.0.1 19 | #allow: 192.168 20 | # auth password must be at least 32 characters 21 | #auth: very-strong-password 22 | #readonly: yes 23 | # in ms, to log slowlog with WARN level 24 | #slowlog_timeout: 5 25 | 26 | replication: 27 | binlog: yes 28 | # Limit sync speed to *MB/s, -1: no limit 29 | sync_speed: -1 30 | slaveof: 31 | # to identify a master even if it moved(ip, port changed) 32 | # if set to empty or not defined, ip:port will be used. 33 | #id: svc_2 34 | # sync|mirror, default is sync 35 | #type: sync 36 | #host: localhost 37 | #port: 8889 38 | 39 | logger: 40 | level: debug 41 | output: log.txt 42 | rotate: 43 | size: 1000000000 44 | 45 | leveldb: 46 | # in MB 47 | cache_size: 500 48 | # in MB 49 | write_buffer_size: 64 50 | # in MB/s 51 | compaction_speed: 1000 52 | # yes|no 53 | compression: yes 54 | -------------------------------------------------------------------------------- /zookeeper/.env: -------------------------------------------------------------------------------- 1 | ### ZOOKEEPER ############################################# 2 | 3 | # -------------- image config --------------- 4 | # official image 5 | IMAGE_OFFICIAL_ZOOKEEPER_NAME=wurstmeister/zookeeper 6 | IMAGE_OFFICIAL_ZOOKEEPER_VERSION=3.4.6 7 | # basic image 8 | IMAGE_BASIC_ZOOKEEPER_VERSION=3.4.6 9 | # app image 10 | IMAGE_APP_ZOOKEEPER_VERSION=latest 11 | # -------------- service config -------------- 12 | ZOOKEEPER_HOST_PORT=3200 13 | ZOOKEEPER_CONTAINER_PORT=2181 # not supporting custom configurations 14 | -------------------------------------------------------------------------------- /zookeeper/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | ### ZOOKEEPER ################################################## 3 | zookeeper: 4 | hostname: zookeeper 5 | image: sparrow-app-zookeeper:${IMAGE_APP_ZOOKEEPER_VERSION} # pull_or_build_app_image(local image=>remote image=>build image) 6 | container_name: sparrow_container_${CONTAINER_NAMESPACE}_zookeeper 7 | platform: ${FROM_PLATFORM} 8 | restart: always 9 | environment: 10 | TZ: ${TZ} 11 | LANG: C.UTF-8 12 | volumes: 13 | - /etc/localtime:/etc/localtime:ro 14 | - ./zookeeper/:/home/sparrow/zookeeper/ 15 | - ./zookeeper/data/:/opt/zookeeper-${IMAGE_OFFICIAL_ZOOKEEPER_VERSION}/data/ # data persistence 16 | ports: 17 | # You don't need to expose the port in the Dockerfile. 18 | - "${ZOOKEEPER_HOST_PORT}:${ZOOKEEPER_CONTAINER_PORT}" 19 | networks: 20 | - backend 21 | # only for debug 22 | # command: "tail -f /dev/null" 23 | -------------------------------------------------------------------------------- /zookeeper/hooks/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the hook actions while the service/container start/stop. 3 | -------------------------------------------------------------------------------- /zookeeper/hooks/after_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /zookeeper/hooks/after_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /zookeeper/hooks/before_start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /zookeeper/hooks/before_stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # not need to include sdk of sparrow. 4 | # because the execution of hook scripts must be within the sparrow script, sdk.sh has already been imported at this point. 5 | # . .work/include/sdk.sh 6 | -------------------------------------------------------------------------------- /zookeeper/init/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is init scripts after the container created, is executed by ```./hooks/after_start.sh```. 3 | -------------------------------------------------------------------------------- /zookeeper/make_app_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_BASIC_ZOOKEEPER_VERSION 3 | FROM --platform=${FROM_PLATFORM} sparrow-basic-zookeeper:${IMAGE_BASIC_ZOOKEEPER_VERSION} 4 | 5 | RUN mkdir -p /var/run/sshd 6 | -------------------------------------------------------------------------------- /zookeeper/make_app_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-app-*``` image making directory. 3 | -------------------------------------------------------------------------------- /zookeeper/make_app_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="zookeeper" 9 | 10 | print_stage "try to pull/build sparrow-basic-${service_name} $IMAGE_BASIC_ZOOKEEPER_VERSION" 11 | if pull basic $service_name $IMAGE_BASIC_ZOOKEEPER_VERSION; then 12 | print_info "pull success" 13 | elif . "./${service_name}/make_basic_image/run.sh"; then 14 | print_info "build success" 15 | else 16 | print_error "pull/build failed" 17 | exit 1 18 | fi 19 | 20 | cd $service_name/ 21 | docker build \ 22 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 23 | --build-arg IMAGE_BASIC_ZOOKEEPER_VERSION=${IMAGE_BASIC_ZOOKEEPER_VERSION} \ 24 | \ 25 | -f ./make_app_image/Dockerfile \ 26 | -t sparrow-app-$service_name:${IMAGE_APP_ZOOKEEPER_VERSION} . 27 | 28 | cd ../ 29 | -------------------------------------------------------------------------------- /zookeeper/make_basic_image/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FROM_PLATFORM 2 | ARG IMAGE_OFFICIAL_ZOOKEEPER_NAME 3 | ARG IMAGE_OFFICIAL_ZOOKEEPER_VERSION 4 | FROM --platform=${FROM_PLATFORM} ${IMAGE_OFFICIAL_ZOOKEEPER_NAME}:${IMAGE_OFFICIAL_ZOOKEEPER_VERSION} AS builder 5 | -------------------------------------------------------------------------------- /zookeeper/make_basic_image/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the ```sparrow-basic-*``` image making directory. 3 | -------------------------------------------------------------------------------- /zookeeper/make_basic_image/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # cd base dir of project. 4 | # the process is in the same shell as the starting shell. 5 | cd $SPARROW_BASE_PATH 6 | 7 | # define this service. 8 | service_name="zookeeper" 9 | 10 | cd $service_name/ 11 | docker build \ 12 | --build-arg FROM_PLATFORM=${FROM_PLATFORM} \ 13 | --build-arg IMAGE_OFFICIAL_ZOOKEEPER_NAME=${IMAGE_OFFICIAL_ZOOKEEPER_NAME} \ 14 | --build-arg IMAGE_OFFICIAL_ZOOKEEPER_VERSION=${IMAGE_OFFICIAL_ZOOKEEPER_VERSION} \ 15 | \ 16 | -f ./make_basic_image/Dockerfile \ 17 | -t sparrow-basic-$service_name:${IMAGE_BASIC_ZOOKEEPER_VERSION} . 18 | 19 | cd ../ 20 | -------------------------------------------------------------------------------- /zookeeper/templates/README.md: -------------------------------------------------------------------------------- 1 | ## What is this directory 2 | This is the template directory for the service, the ```template``` means all static and unchanging files. 3 | 4 | --------------------------------------------------------------------------------