Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Mega 2021 Update #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 16 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
linters:
disable-all: true
enable:
- deadcode
- errcheck
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- revive
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
4 changes: 2 additions & 2 deletions Docker/container.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ function Container:destroy(running)
local Z = self.z+2
LOG("Exploding at X:" .. X .. " Y:" .. Y .. " Z:" .. Z)
local World = cRoot:Get():GetDefaultWorld()
World:BroadcastSoundEffect("random.explode", X, Y, Z, 1, 1)
World:BroadcastParticleEffect("hugeexplosion",X, Y, Z, 0, 0, 0, 1, 1)
World:BroadcastSoundEffect("entity.generic.explode", Vector3d(X, Y, Z), 1, 1)
World:BroadcastParticleEffect("hugeexplosion",Vector3f(X, Y, Z), Vector3f(), 1, 1)

-- if a block is removed before it's button/lever/sign, that object will drop
-- and the player can collect it. Remove these first
Expand Down
4 changes: 2 additions & 2 deletions Docker/update.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ function NewUpdateQueue()
function update:exec()
if self.op == UPDATE_SET
then
cRoot:Get():GetDefaultWorld():SetBlock(self.x,self.y,self.z,self.blockID,self.meta)
cRoot:Get():GetDefaultWorld():SetBlock(Vector3i(self.x, self.y, self.z),self.blockID,self.meta)
elseif self.op == UPDATE_DIG
then
cRoot:Get():GetDefaultWorld():DigBlock(self.x,self.y,self.z)
cRoot:Get():GetDefaultWorld():DigBlock(Vector3i(self.x,self.y,self.z))
elseif self.op == UPDATE_SIGN
then
cRoot:Get():GetDefaultWorld():SetSignLines(self.x,self.y,self.z,self.meta.line1,self.meta.line2,self.meta.line3,self.meta.line4)
Expand Down
20 changes: 10 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
FROM alpine:3.6 AS wget
FROM alpine:3.13 AS wget
RUN apk add --no-cache ca-certificates wget tar

FROM wget AS docker
ARG DOCKER_VERSION=17.09.0-ce
ARG DOCKER_VERSION=20.10.7
RUN wget -qO- https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz | \
tar -xvz --strip-components=1 -C /bin

FROM wget AS cuberite
ARG CUBERITE_BUILD=905
ARG CUBERITE_BUILD=239
WORKDIR /srv
RUN wget -qO- "https://builds.cuberite.org/job/Cuberite Linux x64 Master/${CUBERITE_BUILD}/artifact/Cuberite.tar.gz" |\
RUN wget -qO- "https://builds.cuberite.org/job/linux-x86_64/${CUBERITE_BUILD}/artifact/Cuberite.tar.gz" |\
tar -xzf -

FROM golang:1.9 AS dockercraft
FROM golang:1.16 AS dockercraft
WORKDIR /go/src/github.com/docker/dockercraft
COPY . .
RUN go install

FROM debian:jessie
FROM debian:buster-slim
RUN apt-get update; apt-get install -y ca-certificates
COPY --from=dockercraft /go/bin/dockercraft /bin
COPY --from=docker /bin/docker /bin
COPY --from=cuberite /srv /srv

# Copy Dockercraft config and plugin
COPY ./config /srv/Server
COPY ./docs/img/logo64x64.png /srv/Server/favicon.png
COPY ./Docker /srv/Server/Plugins/Docker
COPY ./config /srv
COPY ./docs/img/logo64x64.png /srv/favicon.png
COPY ./Docker /srv/Plugins/Docker

EXPOSE 25565
ENTRYPOINT ["/srv/Server/start.sh"]
ENTRYPOINT ["/srv/start.sh"]
22 changes: 5 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,23 @@
REPO_NAME = dockercraft
REPO_OWNER = docker
PKG_NAME = github.com/${REPO_OWNER}/${REPO_NAME}
IMAGE = golang:1.8
IMAGE = golang:1.16
IMAGE_NAME = dockercraft-dev
CONTAINER_NAME = dockercraft-dev-container
PACKAGES=$(shell go list ./... | grep -v vendor)

all: test

test-local: install-deps fmt lint vet
test-local:
@echo "+ $@"
@go test -v .

test:
@docker run -v ${shell pwd}:/go/src/${PKG_NAME} -w /go/src/${PKG_NAME} ${IMAGE} make test-local

install-deps:
@echo "+ $@"
@go get -u github.com/golang/lint/golint
test: lint
@docker run -v $(CURDIR):/go/src/${PKG_NAME} -w /go/src/${PKG_NAME} ${IMAGE} make test-local

lint:
@echo "+ $@"
@test -z "$$(golint $(PACKAGES) | tee /dev/stderr)"

fmt:
@echo "+ $@"
@test -z "$$(gofmt -s -l *.go | tee /dev/stderr)"

vet:
@echo "+ $@"
go vet $(PACKAGES)
@docker run --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:v1.40.1 golangci-lint run -v

build:
@echo "+ $@"
Expand Down
6 changes: 3 additions & 3 deletions config/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ if [ -n "$4" ]; then
finishers="$4"
fi

sed -i "s/@BIOME@/${biome}/g;s/@GROUNDLEVEL@/${groundlevel}/g;s/@SEALEVEL@/${sealevel}/g;s/@FINISHERS@/${finishers}/g" /srv/Server/world/world.ini
sed -i "s/@BIOME@/${biome}/g;s/@GROUNDLEVEL@/${groundlevel}/g;s/@SEALEVEL@/${sealevel}/g;s/@FINISHERS@/${finishers}/g" /srv/world/world.ini

echo Starting Dockercraft
cd /srv/Server
cd /srv
dockercraft &
sleep 5
./Cuberite
./Cuberite
10 changes: 6 additions & 4 deletions daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"sync"
"time"

log "github.com/Sirupsen/logrus"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/client"
log "github.com/sirupsen/logrus"
)

// TCPMessage defines what a message that can be
Expand Down Expand Up @@ -90,7 +90,7 @@ type CPUStats struct {
// Init initializes a Daemon
func (d *Daemon) Init() error {
var err error
d.Client, err = client.NewEnvClient()
d.Client, err = client.NewClientWithOpts(client.FromEnv)
if err != nil {
return err
}
Expand All @@ -112,7 +112,9 @@ func (d *Daemon) Init() error {
func (d *Daemon) Serve() {

tcpAddr, err := net.ResolveTCPAddr("tcp", ":25566")

if err != nil {
panic(err)
}
ln, err := net.ListenTCP("tcp", tcpAddr)
if err != nil {
log.Fatalln("listen tcp error:", err)
Expand Down Expand Up @@ -322,7 +324,7 @@ func (d *Daemon) eventCallback(event events.Message) {

default:
// Ignoring
log.Debug("Ignoring event: %s", event.Status)
log.Debugf("Ignoring event: %s", event.Status)
}
}

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ dockercraft:
- "/var/run/docker.sock:/var/run/docker.sock"
ports:
- "25565:25565"
tty: true
tty: true
15 changes: 15 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module github.com/docker/dockercraft

go 1.16

require (
github.com/containerd/containerd v1.5.2 // indirect
github.com/docker/docker v20.10.7+incompatible
github.com/docker/go-connections v0.4.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/moby/term v0.0.0-20210610120745-9d4ed1856297 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/sirupsen/logrus v1.8.1
golang.org/x/time v0.0.0-20210611083556-38a9dc6acbc6 // indirect
google.golang.org/grpc v1.38.0 // indirect
)
Loading