-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile
More file actions
35 lines (26 loc) Β· 1.04 KB
/
Makefile
File metadata and controls
35 lines (26 loc) Β· 1.04 KB
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 sql_mongo_converter Docker image
# β our GHCR namespace & repo
IMAGE ?= ghcr.io/hoangsonww/sql-mongo-converter
REGISTRY ?= ghcr.io
USER ?= hoangsonww
# β parse version="x.y.z" from setup.py (portable sed)
VERSION := $(shell sed -nE "s/^[[:space:]]*version[[:space:]]*=[[:space:]]*[\"']([0-9]+\.[0-9]+\.[0-9]+)[\"'].*$$/\1/p" setup.py)
.PHONY: all login build push clean version
all: login build push
version:
@echo $(VERSION)
login:
@# ensure we have a token
@test -n "$(GITHUB_TOKEN)" || (echo "Error: GITHUB_TOKEN not set" && exit 1)
@echo "π Logging into $(REGISTRY) as $(USER)"
@echo "$(GITHUB_TOKEN)" | docker login $(REGISTRY) -u $(USER) --password-stdin
build:
@echo "π¨ Building Docker image $(IMAGE):$(VERSION)"
@docker build --pull -t $(IMAGE):$(VERSION) -t $(IMAGE):latest .
push:
@echo "π Pushing $(IMAGE):$(VERSION) and $(IMAGE):latest"
@docker push $(IMAGE):$(VERSION)
@docker push $(IMAGE):latest
clean:
@echo "π Removing images"
-@docker rmi $(IMAGE):$(VERSION) $(IMAGE):latest || true