-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (60 loc) · 2.14 KB
/
Makefile
File metadata and controls
80 lines (60 loc) · 2.14 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
74
75
76
77
78
79
80
IMAGE = enspirit/talktome
SHELL=/bin/bash -o pipefail
DOCKER_REGISTRY := $(or ${DOCKER_REGISTRY},${DOCKER_REGISTRY},docker.io)
################################################################################
### Config variables
###
# Load them from an optional .env file
-include .env
# Specify which ruby version is used as base
DEFAULT_MRI_VERSION := 3.1
MRI_VERSION := $(or ${MRI_VERSION},${MRI_VERSION},$(DEFAULT_MRI_VERSION))
# Specify which docker tag is to be used
VERSION := $(or ${VERSION},${VERSION},latest)
DOCKER_REGISTRY := $(or ${DOCKER_REGISTRY},${DOCKER_REGISTRY},docker.io)
PLATFORMS := linux/amd64,linux/arm64/v8
TINY = ${VERSION}
MINOR = $(shell echo '${TINY}' | cut -f'1-2' -d'.')
MAJOR = $(shell echo '${MINOR}' | cut -f'1' -d'.')
$(info $(TINY) $(MINOR) $(MAJOR))
################################################################################
### Main docker rules
###
clean:
rm -rf pkg/*
rm -rf Dockerfile.log Dockerfile.built Dockerfile.pushed
Dockerfile.built: Dockerfile $(shell git ls-files)
@docker buildx build -f Dockerfile ./ \
--push \
--build-arg MRI_VERSION=${MRI_VERSION} \
--platform ${PLATFORMS} \
-t $(DOCKER_REGISTRY)/enspirit/talktome \
-t $(DOCKER_REGISTRY)/enspirit/talktome:${TINY} \
-t $(DOCKER_REGISTRY)/enspirit/talktome:${MINOR} \
-t $(DOCKER_REGISTRY)/enspirit/talktome:ruby${MRI_VERSION} \
-t $(DOCKER_REGISTRY)/enspirit/talktome:$(TINY)-ruby${MRI_VERSION} \
-t $(DOCKER_REGISTRY)/enspirit/talktome:$(MINOR)-ruby${MRI_VERSION}
touch Dockerfile.built
.build/buildx.builder:
mkdir -p .build
docker buildx create --use --name talktome
touch .build/buildx.builder
image: .build/buildx.builder Dockerfile.built
################################################################################
### Main development rules
###
bundle:
bundle install
up: Dockerfile.built
docker run -d -p 80:3000 $(IMAGE)
test: bundle
bundle exec rake test
################################################################################
### Gem Management
###
gem: clean bundle
bundle exec rake gem
gem.publish: gem
gem push `ls -Art pkg/*.gem | tail -n 1`
gem.publish.ci:
gem push `ls -Art pkg/*.gem | tail -n 1`