docker 化
This commit is contained in:
19
.docker/db/Dockerfile
Normal file
19
.docker/db/Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
FROM mysql:5.7
|
||||||
|
|
||||||
|
#设置免密登录
|
||||||
|
ENV MYSQL_ALLOW_EMPTY_PASSWORD yes
|
||||||
|
|
||||||
|
VOLUME ["/var/lib/mysql"]
|
||||||
|
|
||||||
|
RUN sed -i "s/^user.*/user = root/g" /etc/mysql/my.cnf
|
||||||
|
|
||||||
|
RUN chown -R mysql /var/lib/mysql
|
||||||
|
RUN chgrp -R mysql /var/lib/mysql
|
||||||
|
|
||||||
|
#将所需文件放到容器中
|
||||||
|
COPY .docker/db/setup.sh /var/lib/mysql/setup.sh
|
||||||
|
COPY .docker/db/ppgo_job2.sql /var/lib/mysql/ppgo_job2.sql
|
||||||
|
COPY .docker/db/privileges.sql /var/lib/mysql/privileges.sql
|
||||||
|
|
||||||
|
#设置容器启动时执行的命令
|
||||||
|
CMD ["sh", "/var/lib/mysql/setup.sh"]
|
||||||
324
.docker/db/ppgo_job2.sql
Normal file
324
.docker/db/ppgo_job2.sql
Normal file
File diff suppressed because one or more lines are too long
3
.docker/web/.env
Normal file
3
.docker/web/.env
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
CGO_ENABLED=0
|
||||||
|
GOOS=darwin
|
||||||
|
GOARCH=amd64
|
||||||
13
.docker/web/Dockerfile
Normal file
13
.docker/web/Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
FROM alpine:3.8
|
||||||
|
|
||||||
|
# Expose the application on port 8080*
|
||||||
|
EXPOSE 8080 443
|
||||||
|
RUN apk add tzdata bash --update-cache --repository http://mirrors.ustc.edu.cn/alpine/v3.8/main/ --allow-untrusted
|
||||||
|
RUN apk add --no-cache --virtual .build-deps curl tzdata --update-cache --repository http://mirrors.ustc.edu.cn/alpine/v3.8/main/ --allow-untrusted && \
|
||||||
|
curl -o wait-for-it.sh https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh && chmod +x wait-for-it.sh && \
|
||||||
|
apk del .build-deps
|
||||||
|
COPY conf/app.conf ./conf/
|
||||||
|
COPY static ./static
|
||||||
|
COPY views ./views
|
||||||
|
ADD PPGo_Job .
|
||||||
|
CMD ["./PPGo_Job"]
|
||||||
@@ -15,11 +15,11 @@ notify.type = 0
|
|||||||
|
|
||||||
|
|
||||||
# 数据库配置
|
# 数据库配置
|
||||||
db.host = 127.0.0.1
|
db.host = db
|
||||||
db.user = root
|
db.user = gotest
|
||||||
db.password = "123456"
|
db.password = "gotest"
|
||||||
db.port = 3306
|
db.port = 3306
|
||||||
db.name = ppgo_job2
|
db.name = local_gotest
|
||||||
db.prefix = pp_
|
db.prefix = pp_
|
||||||
db.timezone = Asia/Shanghai
|
db.timezone = Asia/Shanghai
|
||||||
|
|
||||||
|
|||||||
33
docker-compose.yml
Normal file
33
docker-compose.yml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: .docker/web/Dockerfile
|
||||||
|
# ports from container exposed to the docker machine and the guest machine
|
||||||
|
ports:
|
||||||
|
# 80 on the host, 8080 on the guest. Websever listens on 8080
|
||||||
|
- "8080:8080" # http
|
||||||
|
# - "443:443" # https
|
||||||
|
# file with environment declarations for the container
|
||||||
|
env_file:
|
||||||
|
- .docker/web/.env
|
||||||
|
# Link to containers in another service
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
command: ["./wait-for-it.sh", "db:3306", "--", "./PPGo_Job"]
|
||||||
|
# sync workspace folder with /go
|
||||||
|
db:
|
||||||
|
image: mysql:5.7
|
||||||
|
ports:
|
||||||
|
- "3306:3306"
|
||||||
|
environment:
|
||||||
|
MYSQL_USER: gotest
|
||||||
|
MYSQL_PASSWORD: gotest
|
||||||
|
MYSQL_ROOT_PASSWORD: gotest
|
||||||
|
MYSQL_DATABASE: local_gotest
|
||||||
|
# sync folders. MySQL data is stored outside container so that rebuilding doesn't clear db.
|
||||||
|
# folder is at workspace root.
|
||||||
|
volumes:
|
||||||
|
- .docker/_local_mysql_data:/var/lib/mysql
|
||||||
|
- .docker/db:/docker-entrypoint-initdb.d
|
||||||
Reference in New Issue
Block a user