Dockerfile, CONF_NS and fix sqlite3 under alpine
This commit is contained in:
parent
0d3526221d
commit
516809cd02
15
server/Dockerfile
Normal file
15
server/Dockerfile
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
RUN apk update
|
||||||
|
RUN apk add --no-cache libc6-compat tzdata ca-certificates sqlite
|
||||||
|
|
||||||
|
COPY _build/scn_backend /app/scnserver
|
||||||
|
COPY DOCKER_GIT_INFO /app/DOCKER_GIT_INFO
|
||||||
|
|
||||||
|
RUN mkdir /data
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD ["/app/scnserver"]
|
@ -7,13 +7,13 @@ HASH=$(shell git rev-parse HEAD)
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
rm -f ./_build/scn_backend
|
rm -f ./_build/scn_backend
|
||||||
go build -v -o _build/scn_backend ./cmd/scnserver
|
CGO_ENABLED=1 go build -v -ldflags "-linkmode external -extldflags -static" -o _build/scn_backend ./cmd/scnserver
|
||||||
|
|
||||||
run: build
|
run: build
|
||||||
mkdir -p .run-data
|
mkdir -p .run-data
|
||||||
_build/scn_backend
|
_build/scn_backend
|
||||||
|
|
||||||
build-docker:
|
docker:
|
||||||
[ ! -f "DOCKER_GIT_INFO" ] || rm DOCKER_GIT_INFO
|
[ ! -f "DOCKER_GIT_INFO" ] || rm DOCKER_GIT_INFO
|
||||||
git rev-parse --abbrev-ref HEAD >> DOCKER_GIT_INFO
|
git rev-parse --abbrev-ref HEAD >> DOCKER_GIT_INFO
|
||||||
git rev-parse HEAD >> DOCKER_GIT_INFO
|
git rev-parse HEAD >> DOCKER_GIT_INFO
|
||||||
@ -37,9 +37,9 @@ run-docker-local:
|
|||||||
mkdir -p .run-data
|
mkdir -p .run-data
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
--init \
|
--init \
|
||||||
--env "CONF_NS=local" \
|
--env "CONF_NS=local-docker" \
|
||||||
--volume "$(shell pwd)/.run-data/docker-local:/data" \
|
--volume "$(shell pwd)/.run-data/docker-local:/data" \
|
||||||
--network host \
|
--publish "8080:80" \
|
||||||
$(DOCKER_NAME):latest
|
$(DOCKER_NAME):latest
|
||||||
|
|
||||||
inspect-docker:
|
inspect-docker:
|
||||||
|
@ -18,8 +18,8 @@ type Config struct {
|
|||||||
|
|
||||||
var Conf Config
|
var Conf Config
|
||||||
|
|
||||||
var configLoc = Config{
|
var configLocHost = Config{
|
||||||
Namespace: "local",
|
Namespace: "local-host",
|
||||||
GinDebug: true,
|
GinDebug: true,
|
||||||
ServerIP: "0.0.0.0",
|
ServerIP: "0.0.0.0",
|
||||||
ServerPort: "8080",
|
ServerPort: "8080",
|
||||||
@ -28,6 +28,16 @@ var configLoc = Config{
|
|||||||
ReturnRawErrors: true,
|
ReturnRawErrors: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var configLocDocker = Config{
|
||||||
|
Namespace: "local-docker",
|
||||||
|
GinDebug: true,
|
||||||
|
ServerIP: "0.0.0.0",
|
||||||
|
ServerPort: "80",
|
||||||
|
DBFile: "/data/scn_docker.sqlite3",
|
||||||
|
RequestTimeout: 16 * time.Second,
|
||||||
|
ReturnRawErrors: true,
|
||||||
|
}
|
||||||
|
|
||||||
var configDev = Config{
|
var configDev = Config{
|
||||||
Namespace: "develop",
|
Namespace: "develop",
|
||||||
GinDebug: true,
|
GinDebug: true,
|
||||||
@ -59,7 +69,8 @@ var configProd = Config{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var allConfig = []Config{
|
var allConfig = []Config{
|
||||||
configLoc,
|
configLocHost,
|
||||||
|
configLocDocker,
|
||||||
configDev,
|
configDev,
|
||||||
configStag,
|
configStag,
|
||||||
configProd,
|
configProd,
|
||||||
@ -67,7 +78,7 @@ var allConfig = []Config{
|
|||||||
|
|
||||||
func getConfig(ns string) (Config, bool) {
|
func getConfig(ns string) (Config, bool) {
|
||||||
if ns == "" {
|
if ns == "" {
|
||||||
return configLoc, true
|
return configLocHost, true
|
||||||
}
|
}
|
||||||
for _, c := range allConfig {
|
for _, c := range allConfig {
|
||||||
if c.Namespace == ns {
|
if c.Namespace == ns {
|
||||||
|
Loading…
Reference in New Issue
Block a user