mirror of
https://github.com/Cernobor/oko-server.git
synced 2025-02-24 08:27:17 +00:00
Dockerfile, settable port
* added Dockerfile * server listenting port is configurable via CLI argument
This commit is contained in:
parent
859d9c93ed
commit
e2aa0d1aea
19
Dockerfile
Normal file
19
Dockerfile
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
FROM alpine:3.15.0
|
||||||
|
|
||||||
|
RUN apk add --no-cache git go && \
|
||||||
|
mkdir /oko-server && \
|
||||||
|
cd /oko-server && \
|
||||||
|
git clone https://github.com/Cernobor/oko-server.git /oko-server/git && \
|
||||||
|
cd /oko-server/git && \
|
||||||
|
go build && \
|
||||||
|
cp /oko-server/git/oko-server /oko-server/ && \
|
||||||
|
cd /oko-server && \
|
||||||
|
rm -rf /oko-server/git && \
|
||||||
|
mkdir /data && \
|
||||||
|
apk del git go && \
|
||||||
|
rm -rf /root/go && \
|
||||||
|
echo -e '#!/bin/sh\n/oko-server/oko-server "$@"' > /oko-server/entrypoint.sh && \
|
||||||
|
chmod +x /oko-server/entrypoint.sh
|
||||||
|
VOLUME ["/data"]
|
||||||
|
|
||||||
|
ENTRYPOINT ["/oko-server/entrypoint.sh"]
|
4
main.go
4
main.go
@ -14,8 +14,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
dbFileArg := flag.String("dbfile", "./data.sqlite3", "File that holds the server's sqlite3 database. Will be created if it does not exist. Default is \"./data.sqlite3\".")
|
|
||||||
tilepackFileArg := flag.String("tilepack", "", "File that will be sent to clients when they request a tile pack, also used to serve tiles in online mode. Required.")
|
tilepackFileArg := flag.String("tilepack", "", "File that will be sent to clients when they request a tile pack, also used to serve tiles in online mode. Required.")
|
||||||
|
portArg := flag.Int("port", 8080, "Port where the server will listen to. Default is 8080.")
|
||||||
|
dbFileArg := flag.String("dbfile", "./data.sqlite3", "File that holds the server's sqlite3 database. Will be created if it does not exist. Default is \"./data.sqlite3\".")
|
||||||
apkFileArg := flag.String("apk", "", "APK file with the client app. If not specified, no APK will be available (404).")
|
apkFileArg := flag.String("apk", "", "APK file with the client app. If not specified, no APK will be available (404).")
|
||||||
reinitDBArg := flag.Bool("reinit-db", false, "Reinitializes the DB, which means all the tables will be recreated, deleting all data.")
|
reinitDBArg := flag.Bool("reinit-db", false, "Reinitializes the DB, which means all the tables will be recreated, deleting all data.")
|
||||||
minZoomArg := flag.Int("min-zoom", 1, "Minimum zoom that will be sent to clients.")
|
minZoomArg := flag.Int("min-zoom", 1, "Minimum zoom that will be sent to clients.")
|
||||||
@ -31,6 +32,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s := server.New(server.ServerConfig{
|
s := server.New(server.ServerConfig{
|
||||||
|
Port: *portArg,
|
||||||
DbPath: *dbFileArg,
|
DbPath: *dbFileArg,
|
||||||
TilepackPath: *tilepackFileArg,
|
TilepackPath: *tilepackFileArg,
|
||||||
ApkPath: *apkFileArg,
|
ApkPath: *apkFileArg,
|
||||||
|
@ -34,6 +34,7 @@ type Server struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ServerConfig struct {
|
type ServerConfig struct {
|
||||||
|
Port int
|
||||||
DbPath string
|
DbPath string
|
||||||
TilepackPath string
|
TilepackPath string
|
||||||
ApkPath string
|
ApkPath string
|
||||||
@ -59,7 +60,7 @@ func (s *Server) Run(ctx context.Context) {
|
|||||||
router := s.setupRouter()
|
router := s.setupRouter()
|
||||||
|
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
Addr: fmt.Sprintf(":%d", 8080),
|
Addr: fmt.Sprintf(":%d", s.config.Port),
|
||||||
Handler: router,
|
Handler: router,
|
||||||
}
|
}
|
||||||
s.log.Infof("Running on %s", server.Addr)
|
s.log.Infof("Running on %s", server.Addr)
|
||||||
|
Loading…
Reference in New Issue
Block a user