-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
43 lines (33 loc) · 862 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Variables
APP_NAME = disc-go-bot
IMAGE_TAG = latest
DOCKERFILE_PATH = Dockerfile
PORT = 8080
# Default target
all: build
# Build the application
build:
go build -o $(APP_NAME)
# Build the Docker image
docker-build:
docker build -t $(APP_NAME):$(IMAGE_TAG) -f $(DOCKERFILE_PATH) .
# Run the application in a Docker container
docker-run: docker-build
docker run -d -p $(PORT):$(PORT) --name $(APP_NAME) --restart always $(APP_NAME):$(IMAGE_TAG)
# Stop and remove the running Docker container
docker-stop:
docker stop $(APP_NAME)
# Restart running Docker container
docker-restart:
docker-stop
docker-run
# Clean up build artifacts
clean:
rm -f $(APP_NAME)
# Execute tests
test:
go test -v ./...
# Build and run the application locally
run: build
./$(APP_NAME)
.PHONY: all build docker-build docker-run docker-stop docker-restart clean test run