Skip to content

Commit

Permalink
Cicd overhaul (#393)
Browse files Browse the repository at this point in the history
* go mod tidy

* alpha channel temp fix

* cicd overhaul

---------

Co-authored-by: BuckarooBanzay <[email protected]>
  • Loading branch information
BuckarooBanzay and BuckarooBanzay authored Jun 28, 2024
1 parent 7219590 commit fc73039
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 117 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
39 changes: 39 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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 }}
23 changes: 6 additions & 17 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 13 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 2 additions & 4 deletions doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,7 +27,7 @@ Examplary `docker-compose` config:
```yml
services:
mapserver:
image: minetesttools/mapserver
image: ghcr.io/minetest-mapserver/mapserver
restart: always
networks:
- default
Expand Down
9 changes: 0 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,28 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.16.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
go.uber.org/atomic v1.7.0 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/tools v0.19.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
modernc.org/cc/v3 v3.41.0 // indirect
modernc.org/ccgo/v3 v3.17.0 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.52.1 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/opt v0.1.3 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
)
Expand Down
Loading

0 comments on commit fc73039

Please sign in to comment.