docker
This commit is contained in:
parent
fa79c9ed10
commit
2489d0bb53
21
Dockerfile
21
Dockerfile
@ -1,16 +1,19 @@
|
||||
FROM alpine:latest
|
||||
|
||||
ENV APP_VERSION=1.0.0 \
|
||||
APP_HOME=/service \
|
||||
APP_NAME=overflow_gateway_web \
|
||||
APP_CONF_PATH="/opt/conf" \
|
||||
PATH="$PATH:/opt/bin"
|
||||
APP_HOME=/opt \
|
||||
APP_NAME=overflow_gateway_web
|
||||
|
||||
ADD dist/${APP_NAME} ${APP_HOME}/
|
||||
ADD _docker/bin/*.sh /opt/bin/
|
||||
ENV APP_CONFIG_PATH="${APP_HOME}/config" \
|
||||
APP_LOGS_PATH="${APP_HOME}/logs" \
|
||||
PATH="$PATH:${APP_HOME}/bin"
|
||||
|
||||
ADD dist/${APP_NAME} ${APP_HOME}/bin/
|
||||
ADD _docker/bin/*.sh ${APP_HOME}/bin/
|
||||
|
||||
RUN apk add --no-cache curl \
|
||||
&& chmod +x /opt/bin/*.sh
|
||||
&& chmod +x ${APP_HOME}/bin/*.sh \
|
||||
&& mkdir -p ${APP_LOGS_PATH}
|
||||
|
||||
ENV TINI_VERSION='0.15.0' \
|
||||
TINI_SHA='4007655082f573603c02bc1d2137443c8e153af047ffd088d02ccc01e6f06170'
|
||||
@ -20,9 +23,9 @@ RUN curl -fsSL https://github.com/krallin/tini/releases/download/v${TINI_VERSION
|
||||
&& chmod +x /bin/tini \
|
||||
&& echo "$TINI_SHA /bin/tini" | sha256sum -c -
|
||||
|
||||
WORKDIR ${APP_HOME}
|
||||
VOLUME ${APP_CONFIG_PATH}
|
||||
VOLUME ${APP_LOGS_PATH}
|
||||
|
||||
VOLUME ${APP_CONF_PATH}
|
||||
EXPOSE 80 443
|
||||
|
||||
ENTRYPOINT ["/bin/tini", "--"]
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
set -e
|
||||
|
||||
cd /service
|
||||
|
||||
/usr/bin/java -classpath ${APP_CONF_PATH}/:${APP_FILENAME}:lib/* ${APP_MAIN_CLASS} 50006
|
||||
/opt/bin/overflow_gateway_web -config=/opt/config/
|
||||
|
||||
exec "$@"
|
89
_docker/config/config.json
Normal file
89
_docker/config/config.json
Normal file
@ -0,0 +1,89 @@
|
||||
{
|
||||
"server": {
|
||||
"addr": ":80",
|
||||
"tls": false
|
||||
},
|
||||
"auth": {
|
||||
"signingKey": "tWB0lUXiCwX4U3qsJZcZ10mKvEH793RHkTJDbDuZVshQTk4uNB6ck59UQ96lhsRi4XNUiEnlIbP8XYQMPabeNtERX3iyHeDcwocgUVAor1nkAajYeq1gNyJszGpMhEOT"
|
||||
},
|
||||
"websocket": {
|
||||
"HandshakeTimeout": 0,
|
||||
"ReadBufferSize": 8192,
|
||||
"WriteBufferSize": 8192,
|
||||
"EnableCompression": false
|
||||
},
|
||||
"grpc": {
|
||||
"addr": "192.168.1.50:50006",
|
||||
"tls": false,
|
||||
"pool": {
|
||||
"MaxIdle": 1,
|
||||
"MaxCapacity": 3,
|
||||
"increaseCapacity": 10
|
||||
}
|
||||
},
|
||||
"redis": {
|
||||
"network": "tcp",
|
||||
"addr": "192.168.1.50:6379",
|
||||
"tls": false,
|
||||
"pool": {
|
||||
"MaxIdle": 3,
|
||||
"IdleTimeout": 240,
|
||||
"increaseCapacity": 10
|
||||
}
|
||||
},
|
||||
"handlers": {
|
||||
"web": {
|
||||
"entry": "/web",
|
||||
"socket": {
|
||||
"MaxMessageSize": 8192,
|
||||
"WriteTimeout": 0,
|
||||
"ReadTimeout": 0,
|
||||
"PongTimeout": 60,
|
||||
"PingTimeout": 10,
|
||||
"PingPeriod": 10,
|
||||
"BinaryMessage": false
|
||||
}
|
||||
},
|
||||
"file": {
|
||||
"entry": "/file",
|
||||
"socket": {
|
||||
"MaxMessageSize": 8192,
|
||||
"WriteTimeout": 0,
|
||||
"ReadTimeout": 0,
|
||||
"PongTimeout": 60,
|
||||
"PingTimeout": 10,
|
||||
"PingPeriod": 10,
|
||||
"BinaryMessage": false
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
"logging": {
|
||||
"level": "debug",
|
||||
"development": true,
|
||||
"disableCaller": true,
|
||||
"disableStacktrace": true,
|
||||
"sampling": {
|
||||
"initial": 100,
|
||||
"thereafter": 100
|
||||
},
|
||||
"encoding": "console",
|
||||
"encoderConfig": {
|
||||
"messageKey": "message",
|
||||
"levelKey": "level",
|
||||
"timeKey": "time",
|
||||
"nameKey": "name",
|
||||
"callerKey": "caller",
|
||||
"stacktraceKey": "stacktrace",
|
||||
"lineEnding": "\n",
|
||||
"levelEncoder": "color",
|
||||
"timeEncoder": "ISO8601",
|
||||
"durationEncoder": "string",
|
||||
"callerEncoder": "full",
|
||||
"nameEncoder": "full"
|
||||
},
|
||||
"outputPaths": ["/opt/logs/log"],
|
||||
"errorOutputPaths": ["stderr"]
|
||||
}
|
||||
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
"EnableCompression": false
|
||||
},
|
||||
"grpc": {
|
||||
"addr": "127.0.0.1:50006",
|
||||
"addr": "192.168.1.50:50006",
|
||||
"tls": false,
|
||||
"pool": {
|
||||
"MaxIdle": 1,
|
||||
|
33
docker-compose.yml
Normal file
33
docker-compose.yml
Normal file
@ -0,0 +1,33 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
overFlow-server:
|
||||
restart: always
|
||||
image: docker.loafle.net/overflow/overflow_gateway_web:1.0.0-SNAPSHOT
|
||||
container_name: overflow_gateway_web
|
||||
volumes:
|
||||
# - /service/overflow_gateway_web/data/opt/config:/opt/config
|
||||
# - /service/overflow_gateway_web/data/opt/logs:/opt/logs
|
||||
- /home/crusader/Temp/docker/overflow_gateway_web/config:/opt/config
|
||||
- /home/crusader/Temp/docker/overflow_gateway_web/logs:/opt/logs
|
||||
ports:
|
||||
- "20080:80"
|
||||
- "20443:443"
|
||||
|
||||
# postgresql:
|
||||
# restart: always
|
||||
# image: postgres:9.6-alpine
|
||||
# container_name: overFlow-dao-postgres
|
||||
# environment:
|
||||
# - POSTGRES_DB=overflow
|
||||
# - POSTGRES_USER=overflow
|
||||
# - POSTGRES_PASSWORD=qwer5795
|
||||
# # - POSTGRES_INITDB_ARGS="--data-checksums"
|
||||
# ports:
|
||||
# - "5432:5432"
|
||||
|
||||
# docker-compose up -d
|
||||
# docker-compose stop
|
||||
# docker-compose rm
|
||||
# or
|
||||
# docker-compose -f ./docker-compose.yml up -d
|
11
main.go
11
main.go
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"log"
|
||||
|
||||
"go.uber.org/zap"
|
||||
@ -19,7 +20,11 @@ import (
|
||||
var logger *zap.Logger
|
||||
|
||||
func main() {
|
||||
loadConfig()
|
||||
configPath := flag.String("config", ".", "The path of config file")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
loadConfig(*configPath)
|
||||
ctx := newContext()
|
||||
|
||||
defer logger.Sync()
|
||||
@ -37,9 +42,9 @@ func main() {
|
||||
s.ListenAndServe(config.GetString("server.addr"))
|
||||
}
|
||||
|
||||
func loadConfig() {
|
||||
func loadConfig(path string) {
|
||||
config.SetConfigName("config")
|
||||
config.AddConfigPath(".")
|
||||
config.AddConfigPath(path)
|
||||
err := config.ReadInConfig()
|
||||
if nil != err {
|
||||
log.Fatalf("config error: %v", err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user