forked from ProtonMail/proton-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
133 lines (106 loc) · 3.92 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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
.PHONY: image latest latest-tag test deploy-local local login-deploy
-include .env
branch ?= master
DOCKERFILE_BUILD=/tmp/Dockerfile.image
NAME_IMAGE ?= "$(CI_REGISTRY_IMAGE)/$(src)"
TAG_IMAGE := branch-$(subst /,-,$(branch))
# We use :latest so we can use somewhere else, but it's the same as branch-master the other one is for CI
ifeq ($(branch), latest)
TAG_IMAGE=latest
endif
IMAGE_URL_DEB = ubuntu:latest
IMAGE_URL_FED36 = fedora:36
IMAGE_URL_FED37 = fedora:37
IMAGE_URL_ARCH = archlinux:base
base: image-deb image-fed36image-fed37 image-arch
# Create the image based on ubuntu
image-deb: image
image-deb: DOCKER_FILE_SOURCE = Dockerfile.deb
image-deb: src = ubuntu
# Create the image based on archlinux
image-arch: image
image-arch: DOCKER_FILE_SOURCE = Dockerfile.arch
image-arch: src = archlinux
# Create the image based on fedora 37
image-fed37: image
image-fed37: DOCKER_FILE_SOURCE = Dockerfile.fed37
image-fed37: src = fedora37
# Create the image based on fedora 36
image-fed36: image
image-fed36: DOCKER_FILE_SOURCE = Dockerfile.fed36
image-fed36: src = fedora36
## Make remote image form a branch make image branch=<branchName> (master default)
image: requirements.txt docker-source
docker build -t $(NAME_IMAGE):$(TAG_IMAGE) -f "$(DOCKERFILE_BUILD)" .
docker push $(NAME_IMAGE):$(TAG_IMAGE)
docker tag $(NAME_IMAGE):$(TAG_IMAGE) $(NAME_IMAGE):$(TAG_IMAGE)
## We host our own copy of the image ubuntu:latest
docker-source:
sed "s|IMAGE_URL_FED36|$(IMAGE_URL_FED36)|; s|IMAGE_URL_FED37|$(IMAGE_URL_FED37)|; s|IMAGE_URL_DEB|$(IMAGE_URL_DEB)|; s|IMAGE_URL_ARCH|$(IMAGE_URL_ARCH)|" $(DOCKER_FILE_SOURCE) > /tmp/Dockerfile.image
requirements.txt:
@ touch requirements.txt
# Tag the image branch-master as latest
latest:
docker pull $(NAME_IMAGE):branch-master-$(src)
docker tag $(NAME_IMAGE):branch-master-$(src) $(NAME_IMAGE):latest-$(src)
docker push $(NAME_IMAGE):latest-$(src)
## Build image on local -> name nm-core:latest
local: docker-source
# docker build -t "$(NAME_IMAGE)" -f "$(DOCKERFILE_BUILD)" .
docker build -t $(NAME_IMAGE) -f "$(DOCKERFILE_BUILD)" .
@ rm -rf __SOURCE_APP || true
local: NAME_IMAGE = proton-python-client:latest
local-base: local-deb local-fed36 local-fed37 local-arch
local-deb: local
local-deb: DOCKER_FILE_SOURCE = Dockerfile.deb
local-fed37: local
local-fed37: DOCKER_FILE_SOURCE = Dockerfile.fed37
local-fed36: local
local-fed36: DOCKER_FILE_SOURCE = Dockerfile.fed36
local-arch: local
local-arch: DOCKER_FILE_SOURCE = Dockerfile.arch
# Build an image from your computer and push it to our repository
deploy-local: login-deploy build tag push
# If you want to deploy an image to our registry you will need to set these variables inside .env
login-deploy:
docker login -u "$(CI_DEPLOY_USER)" -p "$(CI_JOB_TOKEN)" "$(CI_REGISTRY)"
######### Not linked to the image ###############
## Run tests against the latest version of the image from your code
test-deb: local-deb
# Keep -it because with colors it's better
@ docker run \
--rm \
-it \
--privileged \
--volume $(PWD)/.env:/home/user/proton-python-client.env \
proton-python-client:latest \
python3 -m pytest
## Run tests against the latest version of the image from your code
test-fed37: local-fed37
# Keep -it because with colors it's better
@ docker run \
--rm \
-it \
--privileged \
--volume $(PWD)/.env:/home/user/proton-python-client.env \
proton-python-client:latest \
python3 -m pytest
test-fed36: local-fed36
# Keep -it because with colors it's better
@ docker run \
--rm \
-it \
--privileged \
--volume $(PWD)/.env:/home/user/proton-python-client.env \
proton-python-client:latest \
python3 -m pytest
## Run tests against the latest version of the image from your code
test-arch: local-arch
# Keep -it because with colors it's better
@ docker run \
--rm \
-it \
--privileged \
--volume $(PWD)/.env:/home/user/proton-python-client.env \
proton-python-client:latest \
python3 -m pytest