From cdb4f626092a1b9ddfdb58903bfa9c8b0f379af3 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Tue, 1 Feb 2022 14:22:48 +0100 Subject: [PATCH] dev/cross cleanup --- .github/workflows/docker.yml | 26 -------------- .github/workflows/release.yml | 22 ------------ .goreleaser.yaml | 20 +++++------ Dockerfile | 22 ++---------- Makefile | 64 ----------------------------------- doc/dev.md | 38 +++++---------------- docker_builder/Dockerfile | 18 ---------- docker_builder/Makefile | 4 --- docker_builder/readme.md | 12 ------- 9 files changed, 21 insertions(+), 205 deletions(-) delete mode 100644 .github/workflows/docker.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 Makefile delete mode 100644 docker_builder/Dockerfile delete mode 100644 docker_builder/Makefile delete mode 100644 docker_builder/readme.md diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 666ab8d..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: docker - -on: - push: - branches-ignore: - - 'renovate/*' - - 'dependabot/*' - tags: - - '*' - -jobs: - build: - runs-on: ubuntu-20.04 - timeout-minutes: 10 - - steps: - - uses: actions/checkout@master - - - name: docker publish - uses: elgohr/Publish-Docker-Github-Action@master - with: - name: minetestmapserver/mapserver - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - tag_names: true - cache: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 996d005..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: release - -on: - release: - types: [created] - -jobs: - build: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v2 - - - name: build - run: make release - - - name: upload - uses: skx/github-action-publish-binaries@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - args: 'output/mapserver-*' diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 228f884..a0633db 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -8,20 +8,18 @@ builds: - linux - windows - darwin -archives: - - replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 -checksum: - name_template: 'checksums.txt' -snapshot: - name_template: "{{ incpatch .Version }}-next" + goarch: + - amd64 + - arm64 + - arm + ldflags: + - -s -w -X mapserver/app.Version={{.Version}} changelog: sort: asc filters: exclude: - '^docs:' - '^test:' +dockers: +- image_templates: ["minetestmapserver/mapserver:{{ .Version }}"] + dockerfile: Dockerfile \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index dc19887..9919d75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,4 @@ -FROM golang:1.17.6-alpine as builder - -RUN apk --no-cache add ca-certificates gcc libc-dev nodejs npm git make - -VOLUME /root/go -COPY ./ /server -RUN cd /server &&\ - npm install -g jshint rollup &&\ - make test jshint all - -FROM alpine:3.15.0 -RUN apk --no-cache add ca-certificates curl -WORKDIR /app -COPY --from=builder /server/output/mapserver-linux-x86_64 /bin/mapserver - -HEALTHCHECK --interval=5s --timeout=3s \ - CMD curl -f http://localhost:8080/api/config || exit 1 - +FROM scratch +COPY mapserver /bin/mapserver EXPOSE 8080 -CMD ["/bin/mapserver"] +ENTRYPOINT ["/bin/mapserver"] diff --git a/Makefile b/Makefile deleted file mode 100644 index 267f50c..0000000 --- a/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -OUT_DIR=output -VERSION=git-$(shell git rev-parse HEAD) - - -# -ldflags="-X mapserver/app.Version=1.0" -GO_LDFLAGS=-ldflags "-linkmode external -extldflags -static -X mapserver/app.Version=$(VERSION)" -GO_LDFLAGS_WIN=-ldflags "-X mapserver/app.Version=$(VERSION)" -GO_BUILD=CGO_ENABLED=1 go build - -BINARIES = $(OUT_DIR)/mapserver-linux-x86_64 -BINARIES += $(OUT_DIR)/mapserver-windows-x86-64.exe -BINARIES += $(OUT_DIR)/mapserver-linux-arm - -JS_BUNDLE = public/js/bundle.js - -all: $(JS_BUNDLE) $(OUT_DIR)/mapserver-linux-x86_64 - -$(OUT_DIR): - mkdir $@ - -fmt: - go fmt ./... - -test: $(OUT_DIR) - go vet ./... - go test ./... - -clean: - rm -rf $(JS_BUNDLE) test-output - rm -rf $(OUT_DIR) - -jshint: - cd public/js && jshint . - -$(JS_BUNDLE): - cd public/js && rollup -c rollup.config.js - -$(OUT_DIR)/mapserver-linux-x86_64: $(OUT_DIR) - # native (linux x86_64) - GOOS=linux GOARCH=amd64 CC=gcc $(GO_BUILD) $(GO_LDFLAGS) -o $@ - -$(OUT_DIR)/mapserver-windows-x86-64.exe: $(OUT_DIR) - GOARCH=amd64 GOOS=windows CC=x86_64-w64-mingw32-gcc $(GO_BUILD) $(GO_LDFLAGS_WIN) -o $@ - -$(OUT_DIR)/mapserver-linux-arm: $(OUT_DIR) - # apt install gcc-5-arm-linux-gnueabihf - GOARCH=arm GOARM=7 CC=arm-linux-gnueabihf-gcc-8 $(GO_BUILD) $(GO_LDFLAGS) -o $@ - - -release: builder_image $(OUT_DIR) $(MOD_ZIP) - # build all with the docker image - sudo docker run --rm -i \ - -v $(shell pwd):/app \ - -v mapserver-volume:/root/go \ - -w /app \ - mapserver-builder \ - make test jshint release-all VERSION=$(VERSION) - # copy generated files to output dir - -builder_image: - # build the docker image with all dependencies - $(MAKE) -C docker_builder build - -release-all: $(JS_BUNDLE) $(BINARIES) diff --git a/doc/dev.md b/doc/dev.md index e240cd8..36673a7 100644 --- a/doc/dev.md +++ b/doc/dev.md @@ -5,17 +5,17 @@ # Build dependencies -## Basic -* go >= 1.11 -* make +* go >= 1.16 +* nodejs >= v17.4.0 +* npm >= 8.3.0 -## With crosscompiling (optional) -Either apt-get: -* gcc-mingw-w64 -* gcc-5-arm-linux-gnueabihf -* gcc-i686-linux-gnu +# Create the frontend bundle -Or use the docker-builder image in `/docker-builder` +```bash +cd public +npm ci +npm run bundle +``` # Development setup @@ -56,23 +56,3 @@ pgsql_player_connection = host=localhost port=5432 user=postgres password=enter * Change the value `webdev` in the `mapserver.json` to `true` * Start the server with `go run .` or with debug output: `go run . -debug` * The web files in `public/` 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 -* make - -Building: -* Run `make all VERSION=X.Y.Z` in the root directory diff --git a/docker_builder/Dockerfile b/docker_builder/Dockerfile deleted file mode 100644 index bd9fb7c..0000000 --- a/docker_builder/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM ubuntu:hirsute - -# for tzdata -ENV DEBIAN_FRONTEND=noninteractive - -RUN apt-get update - -# cross compile and go stuff -RUN apt-get install -y gcc-mingw-w64 gcc-8-arm-linux-gnueabihf gcc-i686-linux-gnu &&\ - apt-get install -y software-properties-common git golang-go - -# TODO: move this to a separate package.json and docker container -# jshint -RUN apt-get install -y nodejs npm -RUN npm install -g jshint@2.12.0 - -# rollup -RUN npm install -g rollup@2.35.1 diff --git a/docker_builder/Makefile b/docker_builder/Makefile deleted file mode 100644 index 0df7c05..0000000 --- a/docker_builder/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -TAG=mapserver-builder - -build: - sudo docker build . -t $(TAG) diff --git a/docker_builder/readme.md b/docker_builder/readme.md deleted file mode 100644 index b8c0295..0000000 --- a/docker_builder/readme.md +++ /dev/null @@ -1,12 +0,0 @@ -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`