Skip to content

Commit

Permalink
docker scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
hotlong committed Sep 25, 2023
1 parent b66d4be commit 38b002a
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 1 deletion.
13 changes: 13 additions & 0 deletions deploy/dev/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
运行华炎魔方平台源码
===

## 安装前准备

- 安装 docker
- 安装 docker-compose

## 运行华炎魔方

```
docker-compose up
```
7 changes: 6 additions & 1 deletion deploy/try/Dockerfile → deploy/single/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions deploy/single/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
快速试用华炎魔方
===

## 安装前准备

- 安装 docker
- 安装 docker-compose

## 运行华炎魔方

```
docker-compose up
```
25 changes: 25 additions & 0 deletions deploy/single/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions deploy/single/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions deploy/single/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 38b002a

Please sign in to comment.