-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (58 loc) · 2.5 KB
/
Copy pathMakefile
File metadata and controls
73 lines (58 loc) · 2.5 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
.PHONY: all build push test
VER := $(shell git branch --show-current)
IMAGE := poxenstudio/mybooks:$(VER)
REPO1 := poxenstudio/mybooks:latest
TAG1 := poxenstudio/mybooks:server-side-render
TAG2 := poxenstudio/mybooks:server-side-render-$(VER)
BASE_IMAGE := poxenstudio/mybooks_base:$(VER)
BASE_REPO1 := poxenstudio/mybooks_base:latest
BUILDER := shukubuilder
ARCH := $(shell uname -m)
PLATFORM ?= linux/$(shell if [ "$(ARCH)" = "x86_64" ]; then echo "amd64"; elif [ "$(ARCH)" = "aarch64" ] || [ "$(ARCH)" = "arm64" ]; then echo "arm64"; else echo "amd64"; fi)
$(info Building for platform: $(PLATFORM))
$(info Building image: $(IMAGE))
$(info Building tag1: $(TAG1))
$(info Building tag2: $(TAG2))
all: build up
build:
docker build --pull --platform=$(PLATFORM) --no-cache=false --build-arg BUILD_COUNTRY=CN --build-arg GIT_VERSION=$(VER) \
-f Dockerfile -t $(IMAGE) -t $(REPO1) --target production .
push:
docker push $(IMAGE)
docker push $(REPO1)
# 初始化多架构构建环境(Linux必须要运行一次),不要使用snap安装的docker
setup-multiarch:
docker run --privileged --rm tonistiigi/binfmt --install all
docker buildx create --use --name $(BUILDER) || docker buildx use $(BUILDER)
docker buildx inspect $(BUILDER) --bootstrap
# 构建并推送基础镜像多架构版本(ubuntu + 系统包 + python依赖 + calibre补丁)
# 仅在 requirements.txt / calibre补丁 / 系统包变更时需重新构建
build-base-multiarch:
docker buildx build --pull --platform=linux/amd64,linux/arm64 \
--builder $(BUILDER) \
--build-arg BUILD_COUNTRY=CN \
-f Dockerfile.base -t $(BASE_IMAGE) -t $(BASE_REPO1) \
--load .
# 构建并推送多架构镜像(同时支持 amd64 和 arm64)
build-multiarch:
docker buildx build --pull --platform=linux/amd64,linux/arm64 \
--builder $(BUILDER) \
--build-arg BUILD_COUNTRY=CN --build-arg GIT_VERSION=$(VER) \
-f Dockerfile -t $(IMAGE) -t $(REPO1) \
--target production --push .
# 仅构建多架构镜像到本地缓存(不推送)
build-multiarch-local:
docker buildx build --pull --platform=linux/amd64,linux/arm64 \
--builder $(BUILDER) \
--build-arg BUILD_COUNTRY=CN --build-arg GIT_VERSION=$(VER) \
-f Dockerfile -t $(IMAGE) -t $(REPO1) \
--target production --load .
lint:
flake8 webserver --count --select=E9,F63,F7,F82 --show-source --statistics --exclude epub_to_audio,test
flake8 webserver --count --statistics --config .style.yapf --exclude epub_to_audio,test
pytest: lint
pytest tests
up:
docker compose up
down:
docker compose stop