From cfdfbe1cca85cd68f87672ea6cd7f75a5225a480 Mon Sep 17 00:00:00 2001 From: David Lick Date: Mon, 21 Jun 2021 12:54:18 -0400 Subject: [PATCH] Add Dockerfile and make directives --- Dockerfile | 11 +++++++++++ Makefile | 14 ++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 Dockerfile 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 -- 2.54.0