From b4a765ab702ad97fc20b241956c3f10a37da5f13 Mon Sep 17 00:00:00 2001 From: Mike Gouline <1960272+gouline@users.noreply.github.com> Date: Mon, 9 Sep 2024 19:56:49 +1000 Subject: [PATCH] Local Docker setup --- Makefile | 19 +++++++++++++++++++ main.go | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 131ced9..3ee6775 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ include .env # Requires SLACK_CLIENT_ID and SLACK_CLIENT_SECRET +IMAGE := blaster:latest + export HOST ?= localhost export PORT ?= 4000 export CERT_FILE ?= certs/localhost.crt @@ -12,3 +14,20 @@ run: .PHONY: test test: go test -v ./... + +.PHONY: docker-build +docker-build: + docker build -t $(IMAGE) . + +.PHONY: docker-run +docker-run: docker-build + docker run --rm \ + -e DEBUG=1 \ + -e PORT=$(PORT) \ + -e CERT_FILE="$(CERT_FILE)" \ + -e KEY_FILE="$(KEY_FILE)" \ + -e SLACK_CLIENT_ID="$(SLACK_CLIENT_ID)" \ + -e SLACK_CLIENT_SECRET="$(SLACK_CLIENT_SECRET)" \ + -p $(PORT):$(PORT) \ + -v "$(PWD)/certs:/app/certs" \ + $(IMAGE) diff --git a/main.go b/main.go index 32f4a1e..8459f52 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "log" "os" "github.com/gouline/blaster/internal/pkg/server" @@ -23,5 +24,5 @@ func main() { panic(fmt.Sprintf("Failed to create server: %s", err)) } - s.Run() + log.Fatal(s.Run()) }