diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..18b86a2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:1.16-alpine + +WORKDIR /go/src/github.com/davidlick/supermarket-api/ +COPY . . +WORKDIR ./cmd/api/ + +RUN go build -o supermarket-api -v ./... + +EXPOSE 3000 + +CMD ["./supermarket-api"] diff --git a/Makefile b/Makefile index c4177a9..f2fa1fd 100644 --- a/Makefile +++ b/Makefile @@ -22,5 +22,19 @@ build: run: go run cmd/api/*.go +docker-build: + docker build -t supermarket-api-image . + +docker-run: + docker run \ + --rm \ + --name supermarket-api \ + -p "3000:3000" \ + -e "ENV=dev" \ + -e "APIPORT=3000" \ + -e "LOGLEVEL=debug" \ + -e "DMLINITFILE=../../defaultproduce.json" \ + supermarket-api-image + clean: rm ./supermarket-api ./coverage.out