Skip to content

Commit

Permalink
Merge pull request #31 from tantalic/dev-experience
Browse files Browse the repository at this point in the history
Reduce developer dependencies to only Docker
  • Loading branch information
tantalic authored Aug 16, 2018
2 parents 6f9ae4e + 031b4f7 commit ed9e183
Show file tree
Hide file tree
Showing 12 changed files with 502 additions and 695 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ language: go
go_import_path: github.com/bellinghamcodes/website

go:
- "1.10"
- "1.10.3"

before_script:
- make vet
- go vet $(shell go list ${PKG}/... | grep -v /vendor/)

install:
- go get -v github.com/golang/dep/cmd/dep
- dep ensure
- go generate

script:
- go build
25 changes: 17 additions & 8 deletions Gopkg.lock

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

4 changes: 1 addition & 3 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

# Gopkg.toml example

[[constraint]]
name = "github.com/codegangsta/cli"
version = "^1.20.0"

[[constraint]]
name = "github.com/elazarl/go-bindata-assetfs"
name = "github.com/shurcooL/vfsgen"

[[constraint]]
name = "github.com/mnbbrown/mailchimp"
Expand Down
31 changes: 23 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
PKG := github.com/bellinghamcodes/website
GO_VERSION := 1.10.3
DEP_VERSION := 0.5.0
COMMIT := $(strip $(shell git rev-parse --short HEAD))
VERSION := $(shell git describe --always --dirty)
.PHONY: help docker update-ca bindata-assetfs
SRC := "/go/src/$(PKG)"
.PHONY: help docker update-ca dev run generate dep
.DEFAULT_GOAL := help

run: ## Run in development mode
go-bindata-assetfs -debug assets assets/*/**
go run *.go
# Run go in Docker container
DOCKER = docker run -it --rm \
-p 3000:3000 \
-v "$(PWD)":$(SRC) \
golang:$(GO_VERSION) \
bash -c

docker: bindata-assetfs ## Builds docker image
dep: ## Install dependencies
$(DOCKER) "curl -o /usr/local/bin/dep -L https://github.com/golang/dep/releases/download/v$(DEP_VERSION)/dep-linux-amd64 && chmod a+x /usr/local/bin/dep && cd $(SRC) && dep ensure"

dev: ## Run in development mode
$(DOCKER) "cd $(SRC) && go build -tags=dev -o /tmp/bellingham-codes-website . && /tmp/bellingham-codes-website"

run: generate ## Run in production mode
$(DOCKER) "cd $(SRC) && go build -o /tmp/bellingham-codes-website . && /tmp/bellingham-codes-website"

docker: ## Builds docker image
docker build \
--build-arg VERSION=$(VERSION) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
-t tantalic/bellinghamcodes-website:$(VERSION) .

vet: ## Run tests
go vet $(shell go list ${PKG}/... | grep -v /vendor/)
$(DOCKER) "go vet $(shell go list ${PKG}/... | grep -v /vendor/)"

update-ca: ## Fetches latest root certificates
curl --time-cond certs/ca-certificates.crt -o certs/ca-certificates.crt https://curl.haxx.se/ca/cacert.pem

bindata-assetfs:
go-bindata-assetfs assets assets/*/**
generate: ## Create/update code generated files
$(DOCKER) "cd $(SRC) && go generate"

help: ## List available make commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand Down
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,31 @@ This primary purpose of this site is to make it simple for users to join the bel

## Building and Running

The website is built using [Go][go] with dependencies managed through the [dep][dep] tool. Once you have your go environment setup and dep installed you can get dependencies by running:
The website is built using [Go][go]. However, to simplify the contribution and development process for non-Go developers the site can be developed without a local Go installation. Instead the only requirement is to have a working installation of [Docker][docker]. Once you have Docker installed you can use the following commands for
development:

Install dependencies by running:

```sh
dep ensure
make dep
```

To run for development purposes run:

```sh
make dev
```

To create the code-generated files (for a production build and prior to making
a commit) run:

```sh
make generate
```

To run in production mode (always test in production mode prior to making
commits and pull requests!) run:

```sh
make run
```
Expand Down Expand Up @@ -77,5 +94,5 @@ cd kubernetes/

[coc]: http://bellingham.codes/code-of-conduct
[go]: http://www.golang.org
[dep]: https://github.com/golang/dep
[docker]: https://www.docker.com/products/docker-desktop
[k8s]: http://kubernetes.io
Loading

0 comments on commit ed9e183

Please sign in to comment.