Skip to content

Commit

Permalink
Add Makefile and Dockerfile for builds of utility tool (#15)
Browse files Browse the repository at this point in the history
This change adds a Makefile and a Dockerfile for builds of the go-dicom dicomutil utility tool and for testing the package in general.
  • Loading branch information
suyashkumar committed Jul 9, 2018
1 parent 9504516 commit f9875e4
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ language: go
go:
- 1.9.x
script:
- go test -v ./...
- go build ./...
- go get github.com/golang/dep/cmd/dep
- make
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM golang:alpine
WORKDIR /go/src/github.com/gradienthealth/go-dicom
COPY . .
RUN apk add --no-cache make git
RUN go get github.com/golang/dep/cmd/dep
RUN make
11 changes: 1 addition & 10 deletions Gopkg.lock

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

24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
BINARY = dicomutil

.PHONY: build
build:
dep ensure
$(MAKE) test
go build -o build/${BINARY} ./dicomutil

.PHONY: test
test:
go test ./...

.PHONY: run
run:
make build
./${BINARY}

.PHONY: release
release:
dep ensure
$(MAKE) test
GOOS=linux GOARCH=amd64 go build -o build/${BINARY}-linux-amd64 ./dicomutil;
GOOS=darwin GOARCH=amd64 go build -o build/${BINARY}-darwin-amd64 ./dicomutil;
GOOS=windows GOARCH=amd64 go build -o build/${BINARY}-windows-amd64.exe ./dicomutil;
9 changes: 8 additions & 1 deletion dicomutil/dicomutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ var (
)

func main() {
// Update usage docs
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n%s <dicom file> [flags]\n", os.Args[0], os.Args[0])
flag.PrintDefaults()
}

flag.Parse()
if len(flag.Args()) == 0 {
log.Panic("dicomutil <dicomfile>")
flag.Usage()
os.Exit(1)
}
if *verbose {
dicomlog.SetLevel(math.MaxInt32)
Expand Down

0 comments on commit f9875e4

Please sign in to comment.