-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
37 lines (28 loc) · 993 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
# Variables
DOCKER_USERNAME ?= xqsit94
IMAGE_NAME := cypher
VERSION ?= v1.0.0
# Build the docker image with a specific version
build:
docker build -t $(DOCKER_USERNAME)/$(IMAGE_NAME):$(VERSION) .
# Tag the new version as latest
tag-latest:
docker tag $(DOCKER_USERNAME)/$(IMAGE_NAME):$(VERSION) $(DOCKER_USERNAME)/$(IMAGE_NAME):latest
# Run the docker image locally
run:
docker run -p 8000:8000 $(DOCKER_USERNAME)/$(IMAGE_NAME):$(VERSION)
# Push the image to Docker Hub
push:
docker push $(DOCKER_USERNAME)/$(IMAGE_NAME):$(VERSION)
# Push the latest tag to Docker Hub
push-latest:
docker push $(DOCKER_USERNAME)/$(IMAGE_NAME):latest
# Build, tag as latest, and push in one command
deploy: build tag-latest push push-latest
# Stop all running containers
stop:
docker stop $(docker ps -q --filter ancestor=$(DOCKER_USERNAME)/$(IMAGE_NAME):$(VERSION))
# Clean up unused images
clean:
docker rmi $(DOCKER_USERNAME)/$(IMAGE_NAME):$(VERSION)
.PHONY: build run push deploy stop clean