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

Commit

Permalink
Mega 2021 Update
Browse files Browse the repository at this point in the history
1. Move to go modules
2. Update to latest Cuberite
3. Update to latest Docker
4. Use golangci-lint for linting
5. Fix lint errors
6. Profit

Signed-off-by: Dave Tucker <[email protected]>
  • Loading branch information
dave-tucker committed Jun 15, 2021
1 parent 4be6b59 commit a309133
Show file tree
Hide file tree
Showing 961 changed files with 191,786 additions and 77,567 deletions.
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
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
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
RUN apt-get update; apt-get install -y ca-certificates
COPY --from=dockercraft /go/bin/dockercraft /bin
COPY --from=docker /bin/docker /bin
Expand Down
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
2 changes: 1 addition & 1 deletion config/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ echo Starting Dockercraft
cd /srv/Server
dockercraft &
sleep 5
./Cuberite
/srv/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
)
937 changes: 937 additions & 0 deletions go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package main

import (
"flag"
log "github.com/Sirupsen/logrus"
"os"

log "github.com/sirupsen/logrus"
)

// The main purpose of this application is to connect the docker daemon
Expand Down
5 changes: 3 additions & 2 deletions setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strconv"
"strings"

log "github.com/Sirupsen/logrus"
log "github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -107,6 +107,7 @@ func compareVersions(v1 string, v2 string) (comp int, err error) {
}

func getClient(out *os.File, URL string, cp copier) error {
log.Infof("fetching %s", URL)
resp, err := http.Get(URL)
if err != nil {
return err
Expand All @@ -123,10 +124,10 @@ func copyClient(out *os.File, resp *http.Response) error {

func extractClient(out *os.File, resp *http.Response) error {
gr, err := gzip.NewReader(resp.Body)
defer gr.Close()
if err != nil {
return err
}
defer gr.Close()

tr := tar.NewReader(gr)
for {
Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/Microsoft/go-winio/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/Microsoft/go-winio/CODEOWNERS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 16 additions & 4 deletions vendor/github.com/Microsoft/go-winio/backup.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a309133

Please sign in to comment.