Skip to content

Commit

Permalink
chore: add dockerfile and docker-compose (bxcodec#20)
Browse files Browse the repository at this point in the history
* add dockerfile and docker-compose
  • Loading branch information
bxcodec authored Dec 23, 2018
1 parent 808ff08 commit a275d19
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ vendor/
article_clean
_*
*.test
.DS_Store
.DS_Store
engine
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Builder
FROM golang:1.11.4-alpine3.8 as builder

RUN apk update && apk upgrade && \
apk --update add git gcc make && \
go get -u github.com/golang/dep/cmd/dep

WORKDIR /go/src/github.com/bxcodec/go-clean-arch

COPY . .

RUN make engine

# Distribution
FROM alpine:latest

RUN apk update && apk upgrade && \
apk --update --no-cache add tzdata && \
mkdir /app

WORKDIR /app

EXPOSE 9090

COPY --from=builder /go/src/github.com/bxcodec/go-clean-arch/engine /app

CMD /app/engine
95 changes: 85 additions & 10 deletions Gopkg.lock

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

26 changes: 18 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
BINARY=article_clean
TESTS=go test $$(go list ./... | grep -v /vendor/) -cover
BINARY=engine
test:
go test -v -cover -covermode=atomic ./...

build:
${TESTS}
vendor:
@dep ensure -v

engine: vendor
go build -o ${BINARY}

install:
${TESTS}
install:
go build -o ${BINARY}

unittest:
go test -short $$(go list ./... | grep -v /vendor/)


clean:
if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi

.PHONY: clean install unittest
docker:
docker build -t go-clean-arch .

run:
docker-compose up -d

stop:
docker-compose down

.PHONY: clean install unittest build docker run stop vendor
Loading

0 comments on commit a275d19

Please sign in to comment.