Skip to content

Commit 1d0628e

Browse files
committed
优化docker-compose,映射目录
1 parent 58055e3 commit 1d0628e

File tree

6 files changed

+1875
-17
lines changed

6 files changed

+1875
-17
lines changed

README.md

+4-12
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@
115115
host=0.0.0.0
116116
port=20010
117117
fill_data=true
118+
[redis]
119+
addr=localredis:6379
120+
db=0
121+
password=ginadmin
118122
```
119123

120124
2. 执行命令 docker-compose up
@@ -181,18 +185,6 @@
181185

182186
2. model需要继承 BaseModle 并且实现 TableName 方法,如果需要初始化填充数据的话,需要实现 FillData() 方法,并将数据填充需要执行的代码写到函数体里。详情参照 AdminUsers
183187

184-
3. 数据库迁移,先使用`go install cmd\ginadmin-cli`安装ginadmin-cli 命令,执行命令行工具
185-
186-
```go
187-
ginadmin-cli db migrate
188-
```
189-
190-
4. 数据填充,需在相应目录下实现 `FillData()` 方法执行如下命令
191-
192-
```go
193-
ginadmin-cli db seed
194-
```
195-
196188
5. 可以通过设置 ini 配置文件中的 `fill_data``migrate_table` 分别控制程序重启时自动迁移数据表和填充数据
197189

198190
### :small_blue_diamond:<a name="定时任务">定时任务</a>

build/DockerfileRedis

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM redis:6.0
2+
3+
RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list && \
4+
sed -i "s@http://security.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list && \
5+
rm -Rf /var/lib/apt/lists/* && \
6+
apt-get update && \
7+
/bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' > /etc/timezone

build/DockerfileWeb

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ FROM golang
22
MAINTAINER gphper
33
COPY . /$GOPATH/src/ginadmin/
44
WORKDIR /$GOPATH/src/ginadmin/
5-
RUN go env -w GO111MODULE=on
6-
RUN go env -w GOPROXY=https://goproxy.cn,direct
7-
RUN go mod tidy
8-
RUN go build ./cmd/ginadmin
5+
RUN go env -w GO111MODULE=on && \
6+
go env -w GOPROXY=https://goproxy.cn,direct && \
7+
go mod tidy && \
8+
go build ./cmd/ginadmin
9+
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' > /etc/timezone
910
EXPOSE 20010
1011
ENTRYPOINT ["./ginadmin"]

deployments/conf/mysql/my.cnf

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2+
#
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation; version 2 of the License.
6+
#
7+
# This program is distributed in the hope that it will be useful,
8+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
# GNU General Public License for more details.
11+
#
12+
# You should have received a copy of the GNU General Public License
13+
# along with this program; if not, write to the Free Software
14+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15+
16+
#
17+
# The MySQL Server configuration file.
18+
#
19+
# For explanations see
20+
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
21+
22+
[mysqld]
23+
pid-file = /var/run/mysqld/mysqld.pid
24+
socket = /var/run/mysqld/mysqld.sock
25+
datadir = /var/lib/mysql
26+
secure-file-priv= NULL
27+
# Disabling symbolic-links is recommended to prevent assorted security risks
28+
symbolic-links=0
29+
30+
# Custom config should go here
31+
!includedir /etc/mysql/conf.d/

0 commit comments

Comments
 (0)