Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #129 from grammarly/release-1.3.0
Browse files Browse the repository at this point in the history
Release 1.3.0
  • Loading branch information
Yuriy Bogdanov committed Jul 20, 2016
2 parents b691c09 + 3bd05c1 commit 9444404
Show file tree
Hide file tree
Showing 576 changed files with 47,143 additions and 100,618 deletions.
25 changes: 23 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,29 @@ sudo: required
services:
- docker
go:
- 1.5
- 1.6.2
env:
- GOARCH=amd64
matrix:
- DOCKER_VERSION=1.11.2-0 DOCKER_FS=overlay
- DOCKER_VERSION=1.11.2-0 DOCKER_FS=aufs
- DOCKER_VERSION=1.12.0~rc3-0 DOCKER_FS=overlay
- DOCKER_VERSION=1.12.0~rc3-0 DOCKER_FS=aufs
global:
secure: MPs87X+op4xhB/TSwbCUAfYlx1XuqznyaJsWuT5ob1m0oBYKpFRG1317DaEaGEJxYqvIlpDPFg030ua6X0JER7h6qoyC71Mv4Xt7x3JVxca3vTpHd98RuGNjKrk4mBlUnegb2HJU/6nopVyP451YeDJX2wgDsQmVAmJUlfYU3kf/QNp/PPEky9WyhQy6Muy4goE8+K/vrdbuRuYu+8SKwDWsXcKLCvXqK6/0Xu+N5vjlmiWaMHk3zN3nS/DrK+odUr/j0qOvHqHgHOILtT7UY2KT4dzLJA/qHEsmvzkM+QNRfqI4LNHrNqpROzjIbLRZKJ8pDAlcQlhthmvAT2WTwEu+scEy+BJExSVcwt7zWnKjkFFXsiR5VwmLC/o6fUJGQ17VczEiPRC7hBcPvt966Up9pa0XSIR6SRo5iVfoen+5DqOyDTku5uL9CM8sGQseBL86R5fjVfisYXj5X8RstxLlO61sU/0cpPTUQ8zR2gb4fPjvhiDQ4uvzGMUPna1S4hdc0v7MrFVNALCRM73usbzIh0FguhiHLJ2MUnQIanqfhjImiteLN/6zVjsIrCh0j5oEYFU6dwF33IpGqjcOsl6QvA47L0Qa0yGVhgTi4w6OcAf10FDAvtSh2Sz3m2zH6R8olQMqIJCJusy0LYurppsB1JLpLYIt4poFtBQBGRU=
before_install:
- sudo sh -c 'echo "deb https://apt.dockerproject.org/repo ubuntu-precise main" > /etc/apt/sources.list.d/docker.list'
- sudo sh -c 'echo "deb https://apt.dockerproject.org/repo ubuntu-precise experimental" >> /etc/apt/sources.list.d/docker.list'
- sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
- sudo apt-get update
- sudo apt-get -qqy -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install docker-engine=${DOCKER_VERSION}~precise
- echo 'DOCKER_OPTS="-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock -s '${DOCKER_FS}'"' | sudo tee /etc/default/docker > /dev/null
- sudo service docker restart
- while ! nc -q 1 127.0.0.1 2375 </dev/null; do sleep 1; done
- docker info
script:
- set -e
- docker login -u testrocker -p ${DOCKER_KEY}
- make test
- make install
- make test_integration
- set +e
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Change Log

## [1.3.0](https://github.com/grammarly/rocker/tree/1.3.0)

[Full Changelog](https://github.com/grammarly/rocker/compare/1.2.0...1.3.0)

**Merged pull requests:**

- Refactor commands to use composition [\#128](https://github.com/grammarly/rocker/pull/128) ([ybogdanov](https://github.com/ybogdanov))
- Implement ARG command and --build-arg flag [\#126](https://github.com/grammarly/rocker/pull/126) ([ybogdanov](https://github.com/ybogdanov))
- Support different regions for AWS ECR, fixes \#105 [\#124](https://github.com/grammarly/rocker/pull/124) ([ybogdanov](https://github.com/ybogdanov))
- Rocker to print command if env variable is present [\#123](https://github.com/grammarly/rocker/pull/123) ([ybogdanov](https://github.com/ybogdanov))
- Refactor integration tests, so they run on TravisCI [\#122](https://github.com/grammarly/rocker/pull/122) ([ybogdanov](https://github.com/ybogdanov))
- Fix mount loop processing to avoid crash on invalid path [\#121](https://github.com/grammarly/rocker/pull/121) ([aacebedo](https://github.com/aacebedo))
- Docker 1.12 compatibility, make integration tests run under Docker for Mac [\#118](https://github.com/grammarly/rocker/pull/118) ([ybogdanov](https://github.com/ybogdanov))
- Warn about implicit contextDir change [\#117](https://github.com/grammarly/rocker/pull/117) ([ctrlok](https://github.com/ctrlok))
- Rockerfile.tmLanguage: highlight `LABEL` [\#107](https://github.com/grammarly/rocker/pull/107) ([igrayson](https://github.com/igrayson))

## [1.2.0](https://github.com/grammarly/rocker/tree/1.2.0)

[Full Changelog](https://github.com/grammarly/rocker/compare/1.1.2...1.2.0)
Expand Down Expand Up @@ -147,4 +163,13 @@
## [0.2.0](https://github.com/grammarly/rocker/tree/0.2.0) (2015-09-08)


\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*


\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*


\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*


\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ PKGS := $(foreach pkg, $(sort $(dir $(SRCS))), $(pkg))

TESTARGS ?=

export GO15VENDOREXPERIMENT := 1

default:
GO15VENDOREXPERIMENT=1 go build -v
go build -v

install:
cp rocker /usr/local/bin/rocker
chmod +x /usr/local/bin/rocker
go install -v

dist_dir:
mkdir -p ./dist/linux_amd64
mkdir -p ./dist/darwin_amd64


cross: dist_dir
docker run --rm -ti -v $(shell pwd):/go/src/github.com/grammarly/rocker \
-e GOOS=linux -e GOARCH=amd64 -e GO15VENDOREXPERIMENT=1 \
-e GOOS=linux -e GOARCH=amd64 \
-w /go/src/github.com/grammarly/rocker \
dockerhub.grammarly.io/golang-1.6.2-cross:v1 go build \
-ldflags "-X main.Version=$(VERSION) -X main.GitCommit=$(GITCOMMIT) -X main.GitBranch=$(GITBRANCH) -X main.BuildTime=$(BUILDTIME)" \
-v -o ./dist/linux_amd64/rocker

docker run --rm -ti -v $(shell pwd):/go/src/github.com/grammarly/rocker \
-e GOOS=darwin -e GOARCH=amd64 -e GO15VENDOREXPERIMENT=1 \
-e GOOS=darwin -e GOARCH=amd64 \
-w /go/src/github.com/grammarly/rocker \
dockerhub.grammarly.io/golang-1.6.2-cross:v1 go build \
-ldflags "-X main.Version=$(VERSION) -X main.GitCommit=$(GITCOMMIT) -X main.GitBranch=$(GITBRANCH) -X main.BuildTime=$(BUILDTIME)" \
Expand All @@ -50,7 +50,7 @@ fmtcheck:
$(foreach file,$(SRCS),gofmt $(file) | diff -u $(file) - || exit;)

lint:
@ go get github.com/golang/lint/golint
@ go get -u github.com/golang/lint/golint
$(foreach file,$(SRCS),fgt golint $(file) || exit;)

vet:
Expand All @@ -61,9 +61,9 @@ gocyclo:
gocyclo -over 25 ./src

test: testdeps fmtcheck vet lint
GO15VENDOREXPERIMENT=1 go test ./src/... $(TESTARGS)
go test ./src/... $(TESTARGS)

test_integration:
GO15VENDOREXPERIMENT=1 go test -v ./test/... --args -verbosity=0
go test -v ./test/... --args -verbosity=0

.PHONY: clean test fmtcheck lint vet gocyclo default
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ PUSH grammarly/rocker:1

# Templating

`rocker` uses Go's [text/template](http://golang.org/pkg/text/template/) to pre-process Rockerfiles prior to execution. We extend it with additional helpers from [rocker/template](/src/rocker/template) package that is shared with [rocker-compose](https://github.com/grammarly/rocker-compose) as well.
`rocker` uses Go's [text/template](http://golang.org/pkg/text/template/) to pre-process Rockerfiles prior to execution. We extend it with additional helpers from [rocker/template](/src/template) package that is shared with [rocker-compose](https://github.com/grammarly/rocker-compose) as well.

Example:

Expand Down Expand Up @@ -445,49 +445,48 @@ PUSH 12345.dkr.ecr.us-east-1.amazonaws.com/my-web-app

### Dependencies

Use [gb](http://getgb.io/) to test and build. We vendor all dependencies, you can find them under `/vendor` directory.
Rocker uses GO15VENDOREXPERIMENT, so all dependencies are vendored and I'm afraid you will need at least Golang v1.5 to be able to compile.

Please, use [gofmt](https://golang.org/cmd/gofmt/) in order to automatically re-format Go code into vendor standardized convention. Ideally, you have to set it on post-save action in your IDE. For SublimeText3, the [GoSublime](https://github.com/DisposaBoy/GoSublime) package does the right thing. Also, [solution for Intellij IDEA](http://marcesher.com/2014/03/30/intellij-idea-run-goimports-on-file-save/).

### Build

(will produce the binary into the `bin/` directory)
You can build Rocker as any other Golang package. Rocker is also go-gettable.
```bash
gb build
go build
```

or build for all platforms:
or
```bash
make all
go install
```

If you have a github access token, you can also do a github release:
or
```bash
make release
go get -u github.com/grammarly/rocker
```

Also a useful thing to have:
or build for all platforms:
```bash
echo "make test" > .git/hooks/pre-push && chmod +x .git/hooks/pre-push
make cross
```

### Test

To run unit tests you should run:
```bash
make test
```

or
And for integration tests:
```bash
gb test rocker/...
make test_integration
```

### Test something particular

Also a useful thing to have:
```bash
gb test rocker/... -run TestMyFunction
echo "make test" > .git/hooks/pre-push && chmod +x .git/hooks/pre-push
```

Don't be afraid of looking under the hood of Makefile to figure out how to run particular test cases.

# TODO

```bash
Expand Down
8 changes: 6 additions & 2 deletions Rockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
FROM golang:1.6-alpine

{{ $commit := (or .Env.GIT_COMMIT "") }}
{{ $branch := (or .Env.GIT_BRANCH "none") }}
{{ $version:= (or .Version "local") }}

FROM golang:1.6-alpine

# Golang build cache
MOUNT /go/pkg/linux_amd64 /usr/local/go/pkg/linux_amd64

ADD . /go/src/github.com/grammarly/rocker
WORKDIR /go/src/github.com/grammarly/rocker

Expand All @@ -15,6 +18,7 @@ RUN go install \

{{ if .test }}
MOUNT /var/run/docker.sock:/var/run/docker.sock
MOUNT ~/.docker:/root/.docker
RUN apk --update add make git bash docker

{{ if .TestArgs }}
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.0
1.3.0
48 changes: 0 additions & 48 deletions cli.md

This file was deleted.

37 changes: 22 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/fsouza/go-dockerclient"

log "github.com/Sirupsen/logrus"
runconfigopts "github.com/docker/docker/runconfig/opts"
)

var (
Expand Down Expand Up @@ -91,8 +92,9 @@ func main() {
Usage: "Make output colored",
},
cli.BoolFlag{
Name: "cmd, C",
Usage: "Print command-line that was used to exec",
Name: "cmd, C",
EnvVar: "ROCKER_PRINT_COMMAND",
Usage: "Print command-line that was used to exec",
},
}, dockerclient.GlobalCliParams()...)

Expand All @@ -107,6 +109,11 @@ func main() {
Value: "",
Usage: "Username and password in user:password format",
},
cli.StringSliceFlag{
Name: "build-arg",
Value: &cli.StringSlice{},
Usage: "Set build-time variables, can pass multiple of those, format is key=value (default [])",
},
cli.StringSliceFlag{
Name: "var",
Value: &cli.StringSlice{},
Expand Down Expand Up @@ -182,7 +189,6 @@ func main() {
Usage: "launches a build for the specified Rockerfile",
Action: buildCommand,
Flags: buildFlags,
Before: globalBefore,
},
{
Name: "pull",
Expand All @@ -205,11 +211,20 @@ func main() {
Usage: "Set the directory where the cache will be stored",
},
},
Before: globalBefore,
},
dockerclient.InfoCommandSpec(),
}

app.Before = func(c *cli.Context) error {
initLogs(c)

if c.GlobalBool("cmd") {
log.Infof("rocker %s | Cmd: %s\n", HumanVersion, strings.Join(os.Args, " "))
}

return nil
}

app.CommandNotFound = func(ctx *cli.Context, command string) {
fmt.Printf("Command not found: %v\n", command)
os.Exit(1)
Expand All @@ -221,22 +236,13 @@ func main() {
}
}

func globalBefore(c *cli.Context) error {
if c.GlobalBool("cmd") {
log.Infof("Rocker %s | Cmd: %s", HumanVersion, strings.Join(os.Args, " "))
}
return nil
}

func buildCommand(c *cli.Context) {

var (
rockerfile *build.Rockerfile
err error
)

initLogs(c)

// We don't want info level for 'print' mode
// So log only errors unless 'debug' is on
if c.Bool("print") && log.StandardLogger().Level != log.DebugLevel {
Expand Down Expand Up @@ -296,6 +302,8 @@ func buildCommand(c *cli.Context) {
if !filepath.IsAbs(contextDir) {
contextDir = filepath.Join(wd, args[0])
}
} else if contextDir != wd {
log.Warningf("Implicit context directory used: %s. You can override context directory using the last argument.", contextDir)
}

dir, err := os.Stat(contextDir)
Expand Down Expand Up @@ -380,6 +388,7 @@ func buildCommand(c *cli.Context) {
Push: c.Bool("push"),
CacheDir: cacheDir,
LogJSON: c.GlobalBool("json"),
BuildArgs: runconfigopts.ConvertKVStringsToMap(c.StringSlice("build-arg")),
})

plan, err := build.NewPlan(rockerfile.Commands(), true)
Expand Down Expand Up @@ -411,8 +420,6 @@ func buildCommand(c *cli.Context) {
}

func pullCommand(c *cli.Context) {
initLogs(c)

args := c.Args()
if len(args) < 1 {
log.Fatal("rocker pull <image>")
Expand Down
Loading

0 comments on commit 9444404

Please sign in to comment.