From 38b002aa7425b60ffc9d8e0fc60c30478884667a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=84=E5=BB=BA=E5=9B=BD?= <9340100@qq.com> Date: Mon, 25 Sep 2023 09:32:28 +0000 Subject: [PATCH] docker scripts --- deploy/dev/README.md | 13 +++++++++++++ deploy/{try => single}/Dockerfile | 7 ++++++- deploy/single/README.md | 13 +++++++++++++ deploy/single/docker-compose.yml | 25 +++++++++++++++++++++++++ deploy/single/entrypoint.sh | 8 ++++++++ deploy/single/healthcheck.sh | 27 +++++++++++++++++++++++++++ 6 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 deploy/dev/README.md rename deploy/{try => single}/Dockerfile (76%) create mode 100644 deploy/single/README.md create mode 100644 deploy/single/docker-compose.yml create mode 100644 deploy/single/entrypoint.sh create mode 100644 deploy/single/healthcheck.sh diff --git a/deploy/dev/README.md b/deploy/dev/README.md new file mode 100644 index 0000000000..26604b43d4 --- /dev/null +++ b/deploy/dev/README.md @@ -0,0 +1,13 @@ +运行华炎魔方平台源码 +=== + +## 安装前准备 + +- 安装 docker +- 安装 docker-compose + +## 运行华炎魔方 + +``` + docker-compose up +``` \ No newline at end of file diff --git a/deploy/try/Dockerfile b/deploy/single/Dockerfile similarity index 76% rename from deploy/try/Dockerfile rename to deploy/single/Dockerfile index 149736e177..511a1ef9ac 100644 --- a/deploy/try/Dockerfile +++ b/deploy/single/Dockerfile @@ -13,5 +13,10 @@ RUN curl -fsSL https://pgp.mongodb.com/server-4.4.asc | \ RUN echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-4.4.gpg ] http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list RUN sudo apt-get update \ - && sudo apt-get install -y mongodb-org=4.4.24 mongodb-org-server=4.4.24 mongodb-org-shell=4.4.24 mongodb-org-mongos=4.4.24 mongodb-org-tools=4.4.24 + && sudo apt-get install -y mongodb-org=4.4.24 mongodb-org-server=4.4.24 mongodb-org-shell=4.4.24 mongodb-org-mongos=4.4.24 mongodb-org-tools=4.4.24 \ + && sudo apt-get install -y nginx redis-server +# Install nginx && redis +RUN sudo apt-get update \ + && sudo apt-get install -y nginx redis-server \ + && sudo apt-get clean -y \ No newline at end of file diff --git a/deploy/single/README.md b/deploy/single/README.md new file mode 100644 index 0000000000..faca7c12f8 --- /dev/null +++ b/deploy/single/README.md @@ -0,0 +1,13 @@ +快速试用华炎魔方 +=== + +## 安装前准备 + +- 安装 docker +- 安装 docker-compose + +## 运行华炎魔方 + +``` + docker-compose up +``` \ No newline at end of file diff --git a/deploy/single/docker-compose.yml b/deploy/single/docker-compose.yml new file mode 100644 index 0000000000..b9d0d7abf4 --- /dev/null +++ b/deploy/single/docker-compose.yml @@ -0,0 +1,25 @@ +version: "3.9" + +services: + + steedos: + build: + context: ./ + dockerfile: ./Dockerfile + image: steedos/steedos-community:latest + ports: + - "3000:3000" + environment: + - ROOT_URL=http://127.0.0.1:3000 + volumes: + - "steedos-data:/app/storage" + - "steedos-mongo-data:/data" + - "steedos-installed-packages:/app/.steedos" + +volumes: + steedos-mongo-data: + driver: local + steedos-installed-packages: + driver: local + steedos-data: + driver: local \ No newline at end of file diff --git a/deploy/single/entrypoint.sh b/deploy/single/entrypoint.sh new file mode 100644 index 0000000000..e8fb943a23 --- /dev/null +++ b/deploy/single/entrypoint.sh @@ -0,0 +1,8 @@ +[[ -z "${REDIS_URL}" ]] && export CACHER=redis://localhost:6379 +[[ -z "${TRANSPORTER}" ]] && export TRANSPORTER=redis://localhost:6379/1 + +sudo service mongod start +redis-server --requirepass $REDIS_PASSWORD > /dev/stdout 2>&1 & + +cd /app +npm start \ No newline at end of file diff --git a/deploy/single/healthcheck.sh b/deploy/single/healthcheck.sh new file mode 100644 index 0000000000..d91f2a04b9 --- /dev/null +++ b/deploy/single/healthcheck.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +healthy=true + +if [ -f "/data/.env" ]; then + export $(cat /data/.env | xargs) +elif [ -f "/home/.env" ]; then + export $(cat /home/.env | xargs) +else + echo "No .env file found" + healthy=false +fi + +if [[ $(curl -Lfk -s -w "%{http_code}\n" http://localhost:3000/ -o /dev/null) -ne 200 ]]; then + echo 'ERROR: Steedos is not running'; + healthy=false +fi + +if [[ $(redis-cli -a $REDIS_PASSWORD --no-auth-warning ping) != 'PONG' ]]; then + echo 'ERROR: Redis is down'; + healthy=false +fi + +if [ $healthy == true ]; then + exit 0 +else + exit 1 +fi \ No newline at end of file