diff --git a/.gitattributes b/.gitattributes index 5f9e9e73..46f6011d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ *.js linguist-language=Go -*.css linguist-language=Go \ No newline at end of file +*.css linguist-language=Go +./.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1e0c6ca9..92d63653 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,19 @@ FROM golang:1.8.3-alpine3.6 +# add china aliyun repo 新增了 alpine 3.6 的阿里源 +RUN cp /etc/apk/repositories /etc/apk/repositories.back && \ + echo "https://mirrors.aliyun.com/alpine/v3.6/main/" > /etc/apk/repositories && \ + echo "https://mirrors.aliyun.com/alpine/v3.6/community/" >> /etc/apk/repositories RUN apk add --update bash git make gcc g++ ADD . /go/src/github.com/lifei6671/mindoc - WORKDIR /go/src/github.com/lifei6671/mindoc RUN chmod +x start.sh -RUN go get -d ./... && \ - go get github.com/mitchellh/gox && \ +#RUN go get -d ./... && \ # 这行 docker build 不过去,所以注释掉了 +RUN go get github.com/mitchellh/gox && \ gox -os "windows linux darwin" -arch amd64 - - CMD ["./start.sh"] diff --git a/README.md b/README.md index c6991dea..caba93a9 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,6 @@ mail_expired=30 # 使用Docker部署 - 如果是Docker用户,可参考项目内置的Dockerfile文件编译镜像。 在启动镜像时需要提供如下的环境变量: @@ -127,6 +126,28 @@ HTTP_PORT 程序监听的端口号 ```bash docker run -p 8181:8181 -e MYSQL_PORT_3306_TCP_ADDR=127.0.0.1 -e MYSQL_PORT_3306_TCP_PORT=3306 -e MYSQL_INSTANCE_NAME=mindoc_db -e MYSQL_USERNAME=root -e MYSQL_PASSWORD=123456 -e httpport=8181 -d daocloud.io/lifei6671/mindoc:latest ``` +### docker-compose 一键安装 +1. 生成配置文件 + > cp env-example .env + + 按照自己的环境填写配置信息到.env文件中 +2. 一键完成所有环境搭建 + > docker-compose up -d mindoc +3. 浏览器访问 + > http://localhost:8181/ + + 整个部署完成了 +4. 常用命令参考 + - 启动 + > docker-compose up -d mindoc + - 停止 + > docker-compose stop mindoc + - 重启 + > docker-compose restart mindoc + - 停止删除容器,释放所有资源 + > docker-compose down + + 更多 docker-compose 的使用相关的内容 请查看官网文档或百度 # 项目截图 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..8c27ac91 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,37 @@ +version: '2' + +services: + +### Applications Code Container ############################# + + applications: + image: tianon/true +### Workspace Utilities Container ########################### + + mindoc: + build: + context: ./ + env_file: .env + environment: + - MYSQL_PORT_3306_TCP_ADDR=${MYSQL_PORT_3306_TCP_ADDR} + - MYSQL_PORT_3306_TCP_PORT=${MYSQL_PORT_3306_TCP_PORT} + - MYSQL_INSTANCE_NAME=${MYSQL_INSTANCE_NAME} + - MYSQL_USERNAME=${MYSQL_USERNAME} + - MYSQL_PASSWORD=${MYSQL_PASSWORD} + - HTTP_PORT=${HTTP_PORT} + ports: + - "${HTTP_PORT}:8181" + volumes_from: + - applications + tty: true + networks: + - backend + + +### Networks Setup ############################################ + +networks: + backend: + driver: "bridge" + + diff --git a/env-example b/env-example new file mode 100644 index 00000000..96e01f1f --- /dev/null +++ b/env-example @@ -0,0 +1,21 @@ +########################################################### +# General Setup +########################################################### + +### Application Path ################################################################################################### +# Point to your code, will be available at `/var/www/mindoc`. + +APPLICATION=../mindoc_volume/ + +### GLOBAL ENVIRONMENT ################################################################################################# + +### 数据库配置 ,如果你的数据库不在容器内或没有用 --link过 那必须要写外部数据库ip +MYSQL_PORT_3306_TCP_ADDR=192.168.4.25 +MYSQL_PORT_3306_TCP_PORT=3306 +MYSQL_INSTANCE_NAME=mindoc_db +MYSQL_USERNAME=root +MYSQL_PASSWORD=root +# expose port +HTTP_PORT=8181 + +