-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
35 lines (26 loc) · 872 Bytes
/
Makefile
File metadata and controls
35 lines (26 loc) · 872 Bytes
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
# Makefile for Docker lifecycle: build, stop, remove, run, logs, restart
# -- Configurable variables --
IMAGE_NAME := fast-api-skeleton-app
CONTAINER_NAME := fast-api-skeleton
HOST_PORT := 8000
CONTAINER_PORT := 80
# -- Convenience aliases --
.PHONY: all build stop rm run logs restart
all: build
## Build the Docker image
build:
docker build -t $(IMAGE_NAME) .
## Stop the running container (no error if not running)
stop:
-docker stop $(CONTAINER_NAME)
## Remove the stopped container (no error if not existing)
rm:
-docker rm $(CONTAINER_NAME)
## Run the container in detached mode, publishing ports
run:
docker run -d --name $(CONTAINER_NAME) -p $(HOST_PORT):$(CONTAINER_PORT) $(IMAGE_NAME)
## Follow the container’s logs
logs:
docker logs -f $(CONTAINER_NAME)
## Full rebuild: stop, rm, rebuild image, run fresh
restart: stop rm build run