diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5dcd488..9769967 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,14 +42,6 @@ jobs: run: | go test ./... - # only on tags or the master branch - - name: Docker Login - if: success() && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master') - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - # only on tags - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 @@ -59,11 +51,3 @@ jobs: args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # only on the master branch - - name: Build and push latest docker image - if: success() && github.ref == 'refs/heads/master' - run: | - CGO_ENABLED=0 go build . - docker build . -t minetestmapserver/mapserver:latest - docker push minetestmapserver/mapserver:latest diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..801a336 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,39 @@ +name: docker + +on: + push: + branches: + - 'main' + tags: + - 'v*' + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/minetest-mapserver/mapserver + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 2261c0e..af0c36d 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,24 +1,13 @@ -before: - hooks: - - go mod tidy builds: - env: - CGO_ENABLED=0 - targets: - - linux_amd64 - - windows_amd64 - - darwin_arm64 - - linux_arm_6 + goos: + - linux + - windows + goarch: + - amd64 + - arm64 ldflags: - -s -w -X mapserver/app.Version={{.Version}} changelog: sort: asc - filters: - exclude: - - '^docs:' - - '^test:' -dockers: -- image_templates: - - "minetestmapserver/mapserver:{{ .Version }}" - - "minetestmapserver/mapserver:latest" - dockerfile: Dockerfile \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3bca46c..bc84652 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,16 @@ -FROM scratch -COPY mapserver /bin/mapserver +FROM node:20.15.0 as bundle-builder +COPY public /public +WORKDIR /public +RUN npm ci && npm run bundle + +FROM golang:1.22.4 as go-builder +COPY . /data +COPY --from=bundle-builder /public/js/bundle* /data/public/js/ +WORKDIR /data +RUN CGO_ENABLED=0 go build . + +FROM alpine:3.20.1 +COPY --from=go-builder /data/mapserver /bin/mapserver ENV MT_CONFIG_PATH "mapserver.json" ENV MT_LOGLEVEL "INFO" ENV MT_READONLY "false" diff --git a/doc/install.md b/doc/install.md index b0a8332..8694c27 100644 --- a/doc/install.md +++ b/doc/install.md @@ -14,12 +14,10 @@ For additional infos (lag,time,players => active mode) on the mapserver interfac ## Docker image -* Docker-hub: https://hub.docker.com/repository/docker/minetestmapserver/mapserver - Simple docker run example to run in the world-directory: ``` -docker run --rm --it -p 8080:8080 -v $(pwd):/minetest -w /minetest minetestmapserver/mapserver +docker run --rm --it -p 8080:8080 -v $(pwd):/minetest -w /minetest ghcr.io/minetest-mapserver/mapserver ``` ## Docker compose @@ -29,7 +27,7 @@ Examplary `docker-compose` config: ```yml services: mapserver: - image: minetesttools/mapserver + image: ghcr.io/minetest-mapserver/mapserver restart: always networks: - default