diff --git a/Makefile b/Makefile index 31d1e06..185c524 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,16 @@ OUT_DIR=output MOD_ZIP=$(OUT_DIR)/mapserver-mod.zip all: $(OUT_DIR) $(MOD_ZIP) - $(MAKE) -C server build-all-docker + # build the docker image with all dependencies + $(MAKE) -C docker_builder build + # build all with the docker image + sudo docker run --rm -it\ + -v $(shell pwd)/server/:/app\ + -v mapserver-volume:/root/go\ + -w /app\ + mapserver-builder\ + make test all + # copy generated files to output dir cp server/output/* $(OUT_DIR)/ $(OUT_DIR): diff --git a/doc/dev.md b/doc/dev.md index fc24cc8..df8af0e 100644 --- a/doc/dev.md +++ b/doc/dev.md @@ -15,7 +15,7 @@ Either apt-get: * gcc-5-arm-linux-gnueabihf * gcc-i686-linux-gnu -Or use the docker-builder image in `server/docker` +Or use the docker-builder image in `/docker-builder` # Development setup @@ -61,13 +61,24 @@ pgsql_player_connection = host=localhost port=5432 user=postgres password=enter * Start the server with `go run .` or with debug output: `go run . -debug` * The web files in `static/` can now be changed on the fly without restarting the server +# All platform build + +Prerequisites: +* docker +* make + +Building: +* Run `make clean all` to build for all supported targets + +The artifacts should now be in the `output` directory + # Release build Prerequisites: * docker +* go >= 1.11 +* make +* valid github token in `.releasetoken` Building: -* Build the docker-image in the `docker` directory with: `cd docker && make build` -* Run `make clean build-docker` to build for all supported targets - -The artifacts should now be in the `output` directory +* Run `./release.sh ` diff --git a/docker_builder/Dockerfile b/docker_builder/Dockerfile new file mode 100644 index 0000000..09c02f0 --- /dev/null +++ b/docker_builder/Dockerfile @@ -0,0 +1,9 @@ +FROM ubuntu:bionic + +RUN apt-get update &&\ + apt-get install -y gcc-mingw-w64 gcc-5-arm-linux-gnueabihf gcc-i686-linux-gnu &&\ + apt-get install -y software-properties-common git + +RUN add-apt-repository ppa:longsleep/golang-backports &&\ + apt-get update &&\ + apt-get install -y golang-go diff --git a/docker_builder/Makefile b/docker_builder/Makefile new file mode 100644 index 0000000..0df7c05 --- /dev/null +++ b/docker_builder/Makefile @@ -0,0 +1,4 @@ +TAG=mapserver-builder + +build: + sudo docker build . -t $(TAG) diff --git a/docker_builder/readme.md b/docker_builder/readme.md new file mode 100644 index 0000000..b8c0295 --- /dev/null +++ b/docker_builder/readme.md @@ -0,0 +1,12 @@ +Docker builder container +=============== + +Builds the mapserver with all supported architectures/platforms + + +Building the builder: +``` +make build +``` + +This creates an image with the name `mapserver-builder` diff --git a/server/Makefile b/server/Makefile index f64753e..d73e8ea 100644 --- a/server/Makefile +++ b/server/Makefile @@ -1,11 +1,14 @@ - STATIC_VFS=vfs/static.go OUT_DIR=output ENV=GO111MODULE=on GO_LDFLAGS=-ldflags "-linkmode external -extldflags -static" -all: build-all +BINARIES = $(OUT_DIR)/mapserver-linux-x86_64 +BINARIES += $(OUT_DIR)/mapserver-linux-x86 +BINARIES += $(OUT_DIR)/mapserver-windows-x86.exe +BINARIES += $(OUT_DIR)/mapserver-windows-x86-64.exe +BINARIES += $(OUT_DIR)/mapserver-linux-arm $(OUT_DIR): mkdir $@ @@ -22,34 +25,26 @@ clean: rm -rf $(STATIC_VFS) rm -rf $(OUT_DIR) -clean-all: clean - rm -rf mapserver.sqlite* - rm -rf mapserver.tiles - rm -rf mapserver.json - -build-docker: - sudo docker run --rm -it -v $(shell pwd)/:/app -v mapserver-volume:/root/go -w /app mapserver-builder make build - -build-all-docker: - sudo docker run --rm -it -v $(shell pwd)/:/app -v mapserver-volume:/root/go -w /app mapserver-builder make build-all - -build: $(OUT_DIR) +$(STATIC_VFS): go generate - # native - CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-gnu-gcc go build $(GO_LDFLAGS) -o $(OUT_DIR)/mapserver-linux-x86_64 -build-all: $(OUT_DIR) - go generate - # native - CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-gnu-gcc go build $(GO_LDFLAGS) -o $(OUT_DIR)/mapserver-linux-x86_64 +$(OUT_DIR)/mapserver-linux-x86_64: $(OUT_DIR) + # native (linux x86_64) + CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-gnu-gcc go build $(GO_LDFLAGS) -o $@ + +$(OUT_DIR)/mapserver-linux-x86: $(OUT_DIR) # apt install gcc-8-i686-linux-gnu - CGO_ENABLED=1 GOOS=linux GOARCH=386 CC=i686-linux-gnu-gcc-7 go build $(GO_LDFLAGS) -o $(OUT_DIR)/mapserver-linux-x86 - # apt install gcc-mingw-w64 - GOARCH=386 GOOS=windows CC=i686-w64-mingw32-gcc CGO_ENABLED=1 go build -o $(OUT_DIR)/mapserver-windows-x86.exe - GOARCH=amd64 GOOS=windows CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 go build -o $(OUT_DIR)/mapserver-windows-x86-64.exe - # apt install gcc-5-arm-linux-gnueabihf - GOARCH=arm GOARM=7 CC=arm-linux-gnueabihf-gcc-5 CGO_ENABLED=1 go build $(GO_LDFLAGS) -o $(OUT_DIR)/mapserver-linux-arm + CGO_ENABLED=1 GOOS=linux GOARCH=386 CC=i686-linux-gnu-gcc-7 go build $(GO_LDFLAGS) -o $@ -#go test -cpuprofile cpu.prof -memprofile mem.prof -bench . ./mapblockrenderer/ -#go tool pprof cpu.prof -#top +$(OUT_DIR)/mapserver-windows-x86.exe: $(OUT_DIR) + # apt install gcc-mingw-w64 + GOARCH=386 GOOS=windows CC=i686-w64-mingw32-gcc CGO_ENABLED=1 go build -o $@ + +$(OUT_DIR)/mapserver-windows-x86-64.exe: $(OUT_DIR) + GOARCH=amd64 GOOS=windows CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 go build -o $@ + +$(OUT_DIR)/mapserver-linux-arm: $(OUT_DIR) + # apt install gcc-5-arm-linux-gnueabihf + GOARCH=arm GOARM=7 CC=arm-linux-gnueabihf-gcc-5 CGO_ENABLED=1 go build $(GO_LDFLAGS) -o $@ + +all: $(STATIC_VFS) $(BINARIES) diff --git a/server/docker_builder/Dockerfile b/server/docker_builder/Dockerfile deleted file mode 100644 index a9a7712..0000000 --- a/server/docker_builder/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -from ubuntu - -run apt-get update &&\ - apt-get install -y gcc-mingw-w64 gcc-5-arm-linux-gnueabihf gcc-i686-linux-gnu &&\ - apt-get install -y software-properties-common git &&\ - add-apt-repository ppa:longsleep/golang-backports &&\ - apt-get update &&\ - apt-get install -y golang-go - diff --git a/server/docker_builder/Makefile b/server/docker_builder/Makefile deleted file mode 100644 index d300ef6..0000000 --- a/server/docker_builder/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -TAG=mapserver-builder - -build: - docker build . -t $(TAG)