Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix docker file, add docker usage to readme.md #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .dockerignore

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
46 changes: 32 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
FROM node:6 as frontend
COPY ./Frontend /usr/src/Frontend
WORKDIR /usr/src/Frontend
RUN npm install && \
# 前端
FROM node:14.17.0 as frontend
COPY . /aoi
WORKDIR /aoi/Frontend
RUN npm config set registry https://registry.npm.taobao.org &&\
npm install && \
npm run build

# 后端
FROM php:7.2-cli
COPY ./AoiAWD /usr/src/AoiAWD
WORKDIR /usr/src/AoiAWD
RUN pecl install mongodb && \
docker-php-ext-enable mongodb && \
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \
COPY --from=frontend /aoi /aoi
WORKDIR /aoi/AoiAWD
# 基本配置
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \
echo "phar.readonly=Off" > "$PHP_INI_DIR/conf.d/phar.ini" && \
rm -rf ./src/public/static/*
COPY --from=frontend /usr/src/Frontend/dist/* ./src/public/static/
RUN mv ./src/public/static/index.html ./src/public/index.html
RUN php ./compile.php
cp -r /aoi/Frontend/dist/static/ /aoi/AoiAWD/src/public/ && \
cp /aoi/Frontend/dist/index.html /aoi/AoiAWD/src/public/index.html
# 编译phar和影子文件(inotify-tools 从 github 搬运到码云)
RUN cd .. && cd TapeWorm && php compile.php &&\
cd .. && cd Guardian && php compile.php &&\
cd .. && cd RoundWorm &&\
sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list && \
sed -i 's|security.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list && \
apt update && apt install -y wget &&\
wget https://gitee.com/slug01sh/inotify-tools/attach_files/764348/download/inotify-tools-3.14.tar.gz && \
tar zxf inotify-tools-3.14.tar.gz && cd inotify-tools-3.14/ && \
./configure && make && make install &&\
cd .. && make

WORKDIR /aoi/AoiAWD
RUN pecl install mongodb && \
docker-php-ext-enable mongodb && \
php ./compile.php

ENTRYPOINT [ "sh", "/aoi/entrypoint.sh"]


ENTRYPOINT [ "php", "./aoiawd.phar" ]
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,18 @@ Usage: ./roundworm [OPTIONS]
-i [MSECOND] Process watch interval. Default: 100
-h This help info
```

## Docker 使用

```bash
# 构建镜像
docker-compose build

# 部署镜像(不建议直接使用 -d,需要查看网站密钥和运行情况)
docker-compose up

# 关闭并清理
docker-compose down
```

> Note:guardian.phar、tapeworm.phar、roundworm等文件将会在部署时保存到当前目录下的 tmp 文件夹中。
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ services:
restart: always
aoiawd:
build: .
depends_on:
links:
- mongodb
volumes:
- ./tmp:/output
restart: always
command: -m mongodb://mongodb:27017
ports:
- 1337:1337
- 8023:8023
62 changes: 0 additions & 62 deletions docker_AoiAWD_Start.sh

This file was deleted.

5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cp /aoi/Guardian/guardian.phar /output
cp /aoi/TapeWorm/tapeworm.phar /output
cp /aoi/RoundWorm/roundworm /output
cd /aoi/AoiAWD/
php /aoi/AoiAWD/aoiawd.phar -m mongodb://mongodb:27017