-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
42 lines (34 loc) · 1.18 KB
/
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
# SPDX-FileCopyrightText: 2023 Gert van Dijk <github@gertvandijk.nl>
#
# SPDX-License-Identifier: CC0-1.0
SHELL=/bin/bash -o pipefail
DOCKER_BUILD_OPTS ?=
PYTHON_PKG_VERSION ?= $(shell python -m setuptools_scm)
# Docker tags with '+' are not supported.
IMAGE_TAG ?= $(shell echo "$(PYTHON_PKG_VERSION)" | tr + _)
IMAGE_NAME := purepythonmilter
# python:3.10.12-slim-bullseye linux/amd64 @ 2023-06-08
# https://hub.docker.com/_/python/tags?page=1&name=3.10-slim-bullseye
FROM_IMAGE := python@sha256:c451f80b867635bab3c4db35b272f54cfa3923922cac7eebe2cdf4bb301fb848
CACHEBUST_MINUTE := $(shell date '+%Y-%m-%d %H:%M')
.NOTPARALLEL:
.PHONY: default
default: build push
.PHONY: guard-*
guard-%:
@ if [ "$(${*})" = "" ]; then \
echo "Variable $* not set"; \
exit 1; \
fi
.PHONY: build
build: guard-IMAGE_REGISTRY
DOCKER_BUILDKIT=1 \
docker build $(DOCKER_BUILD_OPTS) \
-t "$(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)" \
--build-arg="FROM_IMAGE=$(FROM_IMAGE)" \
--build-arg="SETUPTOOLS_SCM_PRETEND_VERSION=$(PYTHON_PKG_VERSION)" \
--build-arg="CACHEBUST_MINUTE=$(CACHEBUST_MINUTE)" \
.
.PHONY: push
push: guard-IMAGE_REGISTRY
docker push "$(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)"