add DockerFile
This commit is contained in:
parent
ae7bd2c9a2
commit
f703b14b5e
@ -5,4 +5,6 @@ goctl api go -api .\game_open_api\app_user.api -dir .\game_open_api\ --style=go_
|
|||||||
|
|
||||||
|
|
||||||
goctl rpc protoc .\dw_server\dw_server.proto --go-grpc_out .\dw_server\ --go_out .\dw_server\ --zrpc_out .\dw_server\ -c -style go_zero
|
goctl rpc protoc .\dw_server\dw_server.proto --go-grpc_out .\dw_server\ --go_out .\dw_server\ --zrpc_out .\dw_server\ -c -style go_zero
|
||||||
|
|
||||||
|
docker exec -i mysql mysqldump -uroot -p'youtu!0113' ecpm > ecpm_backup.sql
|
||||||
```
|
```
|
@ -16,13 +16,11 @@ services:
|
|||||||
MYSQL_DATABASE: ecpm
|
MYSQL_DATABASE: ecpm
|
||||||
volumes:
|
volumes:
|
||||||
#数据目录,要确保先创建好
|
#数据目录,要确保先创建好
|
||||||
- ./data/mysql/data:/var/lib/mysql
|
- ./mysql/data:/var/lib/mysql
|
||||||
- ./data/mysql/logs:/var/log/mysql
|
- ./mysql/logs:/var/log/mysql
|
||||||
|
- ./mysql/conf:/etc/mysql/conf.d
|
||||||
##初始化的脚本,初始化我们存放的init.sql文件
|
##初始化的脚本,初始化我们存放的init.sql文件
|
||||||
- ./data/sql:/docker-entrypoint-initdb.d/
|
- ./sql:/docker-entrypoint-initdb.d/
|
||||||
- ./data/mysql/conf:/etc/mysql/conf.d
|
|
||||||
ports:
|
|
||||||
- "3306:3306"
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-uyoutu", "-pyoutu!0113" ]
|
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-uyoutu", "-pyoutu!0113" ]
|
||||||
interval: 6s
|
interval: 6s
|
||||||
@ -35,8 +33,6 @@ services:
|
|||||||
hostname: redis
|
hostname: redis
|
||||||
container_name: redis
|
container_name: redis
|
||||||
privileged: true
|
privileged: true
|
||||||
ports:
|
|
||||||
- "6379:6379"
|
|
||||||
environment:
|
environment:
|
||||||
TZ: Asia/Shanghai
|
TZ: Asia/Shanghai
|
||||||
volumes:
|
volumes:
|
||||||
@ -44,4 +40,17 @@ services:
|
|||||||
# - ./conf/redis.conf:/etc/redis/redis.conf
|
# - ./conf/redis.conf:/etc/redis/redis.conf
|
||||||
- ./data/redis/logs:/logs
|
- ./data/redis/logs:/logs
|
||||||
# command: [ "redis-server","/etc/redis/redis.conf" ]
|
# command: [ "redis-server","/etc/redis/redis.conf" ]
|
||||||
|
youtu_server:
|
||||||
|
image: youtu_server:v1
|
||||||
|
container_name: youtu_server
|
||||||
|
ports:
|
||||||
|
- "8888:8888"
|
||||||
|
environment:
|
||||||
|
TZ: Asia/Shanghai
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
- redis
|
||||||
|
volumes:
|
||||||
|
- ./server/config.yaml:/app/etc/game_open_api-api.yaml
|
||||||
|
- ./server/logs:/logs
|
33
game_open_api/Dockerfile
Normal file
33
game_open_api/Dockerfile
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
FROM golang:alpine AS builder
|
||||||
|
|
||||||
|
LABEL stage=gobuilder
|
||||||
|
|
||||||
|
ENV CGO_ENABLED=0
|
||||||
|
ENV GOPROXY=https://goproxy.cn,direct
|
||||||
|
|
||||||
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||||
|
RUN apk update --no-cache && apk add --no-cache tzdata
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
ADD go.mod .
|
||||||
|
ADD go.sum .
|
||||||
|
RUN go mod download
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN go build -ldflags="-s -w" -o /app/game_open_api ./game_open_api/game_open_api.go
|
||||||
|
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
|
||||||
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||||
|
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=builder /app/game_open_api /app/game_open_api
|
||||||
|
COPY ./game_open_api/etc /app/etc
|
||||||
|
|
||||||
|
EXPOSE 8888
|
||||||
|
|
||||||
|
CMD ["./game_open_api", "-f", "etc/game_open_api-api.yaml"]
|
22
game_open_api/etc/compose_config.yaml
Normal file
22
game_open_api/etc/compose_config.yaml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Name: game_open_api-api
|
||||||
|
Host: 0.0.0.0
|
||||||
|
Port: 8888
|
||||||
|
DB:
|
||||||
|
DataSource: root:youtu!0113@tcp(mysql:3306)/ecpm?charset=utf8mb4&parseTime=True&loc=Local
|
||||||
|
Cache:
|
||||||
|
- Host: redis:6379
|
||||||
|
type: node
|
||||||
|
|
||||||
|
Auth:
|
||||||
|
AccessSecret: youtu123!
|
||||||
|
AccessExpire: 86400
|
||||||
|
|
||||||
|
Log:
|
||||||
|
Level: info
|
||||||
|
Mode: file
|
||||||
|
Path: /logs
|
||||||
|
MaxSize: 100
|
||||||
|
|
||||||
|
DWCache:
|
||||||
|
Host: redis:6379
|
||||||
|
IdleTimeout: 60
|
Loading…
x
Reference in New Issue
Block a user