-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from dyweb/errors/categorization/init
[errors] Error inspection - implemented error inspection based on go 2 proposal - deprecated requests package - add banner
- Loading branch information
Showing
95 changed files
with
3,194 additions
and
457 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# ignore vendor folder because we install it using dep | ||
build | ||
legacy | ||
doc | ||
playground | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Contribution Guidelines | ||
|
||
Format and test the code locally | ||
TODO | ||
|
||
- `make fmt` | ||
- `make test` | ||
- [ ] add instruction for setup go environment and fork set upstream etc. (actually this is no longer a problem with go mod) | ||
|
||
- Read the [style guide](../doc/style.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# TODO: add issue templates https://help.github.com/articles/creating-issue-templates-for-your-repository/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# This Dockerfile is a demo of using go-dev to build a go binary using multi stage build | ||
# It is based on | ||
# https://docs.docker.com/v17.09/engine/userguide/eng-image/dockerfile_best-practices/#use-multi-stage-builds | ||
FROM dyweb/go-dev:1.11.4 as builder | ||
|
||
LABEL maintainer="[email protected]" | ||
|
||
ARG PROJECT_ROOT=/go/src/github.com/dyweb/gommon/ | ||
|
||
WORKDIR $PROJECT_ROOT | ||
|
||
# Gopkg.toml and Gopkg.lock lists project dependencies | ||
# These layers will only be re-built when Gopkg files are updated | ||
COPY Gopkg.lock Gopkg.toml $PROJECT_ROOT | ||
RUN dep ensure -v -vendor-only | ||
|
||
# Copy all project and build it | ||
COPY . $PROJECT_ROOT | ||
RUN make install | ||
|
||
# NOTE: use ubuntu instead of alphine | ||
# | ||
# When using alpine I saw standard_init_linux.go:190: exec user process caused "no such file or directory", | ||
# because I didn't compile go with static flag | ||
# https://stackoverflow.com/questions/49535379/binary-compiled-in-prestage-doesnt-work-in-scratch-container | ||
FROM ubuntu:18.04 as runner | ||
LABEL maintainer="[email protected]" | ||
LABEL github="github.com/dyweb/gommon" | ||
WORKDIR /usr/bin | ||
COPY --from=builder /go/bin/gommon . | ||
ENTRYPOINT ["gommon"] | ||
CMD ["help"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
ARG BASE_IMAGE=ubuntu:18.04 | ||
FROM $BASE_IMAGE | ||
|
||
LABEL maintainer="[email protected]" | ||
|
||
# https://github.com/dyweb/gommon/issues/98 | ||
RUN \ | ||
export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get update \ | ||
&& apt-get upgrade -y --no-install-recommends \ | ||
&& apt-get install -y --no-install-recommends \ | ||
bash \ | ||
build-essential \ | ||
ca-certificates \ | ||
curl \ | ||
wget \ | ||
git-core \ | ||
ssh-client \ | ||
man \ | ||
vim \ | ||
zip \ | ||
unzip \ | ||
tmux \ | ||
netcat \ | ||
telnet \ | ||
tree \ | ||
strace \ | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean -y \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
ENV GOPATH=/go | ||
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH | ||
# TODO: do we need chmod -R 777 like https://github.com/docker-library/golang/blob/master/Dockerfile-debian.template | ||
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" | ||
|
||
ARG BUILD_GO_VERSION=1.11.2 | ||
|
||
# glide no longer have release, just hard code it to latest version | ||
ENV GO_VERSION=$BUILD_GO_VERSION \ | ||
GLIDE_VERSION=v0.13.1 | ||
|
||
# TODO: might put glide under GOPATH/bin | ||
RUN \ | ||
curl -L https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz | tar -C /usr/local -xz \ | ||
&& curl -sSL https://github.com/Masterminds/glide/releases/download/$GLIDE_VERSION/glide-$GLIDE_VERSION-linux-amd64.tar.gz \ | ||
| tar -vxz -C /usr/local/bin --strip=1 \ | ||
&& rm /usr/local/bin/README.md /usr/local/bin/LICENSE | ||
|
||
# TODO: install dep may have problem when go mod is enabled ... | ||
# dep releases are way behind master, so we install from source | ||
RUN go get -u -v github.com/golang/dep/cmd/dep \ | ||
&& go get -u -v golang.org/x/tools/cmd/goimports | ||
|
||
WORKDIR $GOPATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
DOCKER_REPO = dyweb/go-dev | ||
GO_VERSIONS = 1.10.7 1.11.4 | ||
BUILDS = $(addprefix build-, $(GO_VERSIONS)) | ||
PUSHS = $(addprefix push-, $(GO_VERSIONS)) | ||
|
||
.PHONY: build push | ||
|
||
$(BUILDS): | ||
docker build -t $(DOCKER_REPO):$(subst build-,,$@) --build-arg BUILD_GO_VERSION=$(subst build-,,$@) . | ||
|
||
$(PUSHS): | ||
docker push $(DOCKER_REPO):$(subst push-,,$@) | ||
|
||
build: $(BUILDS) | ||
|
||
push: $(PUSHS) | ||
|
||
run: | ||
docker run --rm -it --entrypoint /bin/bash $(DOCKER_REPO):1.11.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# go-dev | ||
|
||
go-dev is a base image for building go code | ||
|
||
See [#98](https://github.com/dyweb/gommon/issues/98) | ||
|
||
- Docker Hub https://hub.docker.com/r/dyweb/go-dev | ||
|
||
## Use | ||
|
||
Use it as base in you multi stage build, the image is big, you don't want to use it directly unless | ||
you need a full go environment to run your code (looking at ginkgo) | ||
|
||
TODO: example using multi stage build using dep and go mods | ||
|
||
Use it as a playground, run the container in interactive mode and remove it after you are done | ||
|
||
````bash | ||
docker run --rm -it --entrypoint /bin/bash dyweb/go-dev:1.11.4 | ||
```` | ||
|
||
## Build | ||
|
||
````bash | ||
make build | ||
# need to login to dockerhub and be member | ||
make push | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.