Skip to content

Commit

Permalink
(Chore) Upgrade golang version + docker build (#13)
Browse files Browse the repository at this point in the history
Upgrade golang version + docker build

- Remove accidental binary checkin
- go mod tidy
  • Loading branch information
gavinelder authored Mar 27, 2020
1 parent be6fe7e commit eedb0e5
Show file tree
Hide file tree
Showing 9 changed files with 380 additions and 232 deletions.
9 changes: 3 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
version: 2
jobs:
build-go1.9:
build-go1.14:
docker:
- image: golang:1.9
- image: golang:1.14
working_directory: /go/src/github.com/micromdm/squirrel
steps: &steps
- checkout
- run: make deps
- run: make test
- run: make

workflows:
version: 2
build:
jobs:
- build-go1.9

- build-go1.14
18 changes: 16 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
FROM alpine:3.4
FROM golang:latest as builder

WORKDIR /go/src/github.com/micromdm/squirrel/

ENV CGO_ENABLED=0 \
GOARCH=amd64 \
GOOS=linux

COPY . .

RUN make deps
RUN make


FROM alpine:3.11.5
RUN apk --update add \
ca-certificates

COPY ./build/squirrel-linux-amd64 /squirrel
COPY --from=builder /go/src/github.com/micromdm/squirrel/build/linux/squirrel /usr/bin/

CMD ["/squirrel", "serve"]

134 changes: 0 additions & 134 deletions Gopkg.lock

This file was deleted.

30 changes: 0 additions & 30 deletions Gopkg.toml

This file was deleted.

50 changes: 20 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ all: build

.PHONY: build

ifndef ($(GOPATH))
GOPATH = $(HOME)/go
ifeq ($(GOPATH),)
PATH := $(HOME)/go/bin:$(PATH)
else
PATH := $(GOPATH)/bin:$(PATH)
endif

export GO111MODULE=on

PATH := $(GOPATH)/bin:$(PATH)
VERSION = $(shell git describe --tags --always --dirty)
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
Expand All @@ -27,34 +31,22 @@ else
endif

BUILD_VERSION = "\
-X github.com/micromdm/squirrel/vendor/github.com/micromdm/go4/version.appName=${APP_NAME} \
-X github.com/micromdm/squirrel/vendor/github.com/micromdm/go4/version.version=${VERSION} \
-X github.com/micromdm/squirrel/vendor/github.com/micromdm/go4/version.branch=${BRANCH} \
-X github.com/micromdm/squirrel/vendor/github.com/micromdm/go4/version.buildUser=${USER} \
-X github.com/micromdm/squirrel/vendor/github.com/micromdm/go4/version.buildDate=${NOW} \
-X github.com/micromdm/squirrel/vendor/github.com/micromdm/go4/version.revision=${REVISION} \
-X github.com/micromdm/squirrel/vendor/github.com/micromdm/go4/version.goVersion=${GOVERSION}"

WORKSPACE = ${GOPATH}/src/github.com/micromdm/squirrel
check-deps:
ifneq ($(shell test -e ${WORKSPACE}/Gopkg.lock && echo -n yes), yes)
@echo "folder is clonded in the wrong place, copying to a Go Workspace"
@echo "See: https://golang.org/doc/code.html#Workspaces"
@git clone [email protected]:micromdm/squirrel ${WORKSPACE}
@echo "cd to ${WORKSPACE} and run make deps again."
@exit 1
endif
ifneq ($(shell pwd), $(WORKSPACE))
@echo "cd to ${WORKSPACE} and run make deps again."
@exit 1
endif
-X github.com/micromdm/go4/version.appName=${APP_NAME} \
-X github.com/micromdm/go4/version.version=${VERSION} \
-X github.com/micromdm/go4/version.branch=${BRANCH} \
-X github.com/micromdm/go4/version.buildUser=${USER} \
-X github.com/micromdm/go4/version.buildDate=${NOW} \
-X github.com/micromdm/go4/version.revision=${REVISION} \
-X github.com/micromdm/go4/version.goVersion=${GOVERSION}"

gomodcheck:
@go help mod > /dev/null || (@echo micromdm requires Go version 1.11 or higher && exit 1)

deps: check-deps
go get -u github.com/golang/dep/...
dep ensure -vendor-only
deps: gomodcheck
@go mod download

test:
go test -cover -race -v $(shell go list ./... | grep -v /vendor/)
go test -cover -race ./...

build: squirrel

Expand All @@ -66,11 +58,9 @@ clean:
mkdir -p build/darwin
mkdir -p build/linux

INSTALL_STEPS := \
install-local: \
install-squirrel

install-local: $(INSTALL_STEPS)

.pre-squirrel:
$(eval APP_NAME = squirrel)

Expand Down
2 changes: 1 addition & 1 deletion cmd/squirrel/serve.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package main

import (
"crypto/subtle"
"encoding/base64"
"flag"
"fmt"
"log"
"net/http"
"os"
"strings"
"crypto/subtle"

kitlog "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
Expand Down
18 changes: 18 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module github.com/micromdm/squirrel

go 1.14

require (
cloud.google.com/go v0.55.0 // indirect
cloud.google.com/go/storage v1.6.0
github.com/aws/aws-sdk-go v1.29.30
github.com/go-kit/kit v0.6.0
github.com/go-logfmt/logfmt v0.3.0 // indirect
github.com/go-stack/stack v1.6.0 // indirect
github.com/groob/finalizer v0.0.0-20170707115354-4c2ed49aabda
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 // indirect
github.com/micromdm/go4 v0.0.0-20171021052028-032f15f8a872
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.5.1 // indirect
google.golang.org/api v0.20.0
)
Loading

0 comments on commit eedb0e5

Please sign in to comment.