-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (73 loc) · 2.04 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
.PHONY: up check
#Defaults
include .env.prod
export #exports the .env.prod variables
IMAGE ?= tulibraries/padigital
VERSION ?= $(DOCKER_IMAGE_VERSION)
HARBOR ?= harbor.k8s.temple.edu
BASE_IMAGE ?= harbor.k8s.temple.edu/library/ruby:3.3-alpine
PLATFORM ?= linux/x86_64
CLEAR_CACHES ?= no
SECRET_KEY_BASE ?= $(PADIGITAL_SECRET_KEY_BASE)
CI ?= false
PADIGITAL_DB_HOST ?= host.docker.internal
PADIGITAL_DB_USER ?= postgres
SOLR_IP ?= localhost:8983
DEFAULT_RUN_ARGS ?= -e "EXECJS_RUNTIME=Disabled" \
-e "K8=yes" \
-e "RAILS_ENV=production" \
-e "SECRET_KEY_BASE=$(SECRET_KEY_BASE)" \
-e "RAILS_SERVE_STATIC_FILES=yes" \
-e "PADIGITAL_DB_HOST=$(PADIGITAL_DB_HOST)" \
-e "PADIGITAL_DB_PASSWORD=$(PADIGITAL_DB_PASSWORD)" \
-e "PADIGITAL_DB_USER=$(PADIGITAL_DB_USER)" \
-e "SOLR_IP"=$(SOLR_IP) \
-e "RAILS_LOG_TO_STDOUT=yes" \
--rm -it
build:
@docker build --build-arg RAILS_MASTER_KEY=$(RAILS_MASTER_KEY) \
--build-arg SECRET_KEY_BASE=$(SECRET_KEY_BASE) \
--build-arg BASE_IMAGE=$(BASE_IMAGE) \
--platform $(PLATFORM) \
--progress plain \
--tag $(HARBOR)/$(IMAGE):$(VERSION) \
--tag $(HARBOR)/$(IMAGE):latest \
--file .docker/app/Dockerfile \
--no-cache .
run:
@docker run --name=padigital -p 127.0.0.1:3001:3000/tcp \
--platform $(PLATFORM) \
$(DEFAULT_RUN_ARGS) \
$(HARBOR)/$(IMAGE):$(VERSION)
lint:
@if [ $(CI) == false ]; \
then \
hadolint .docker/app/Dockerfile; \
fi
scan:
@if [ $(CLEAR_CACHES) == yes ]; \
then \
trivy image --scanners vuln -c $(HARBOR)/$(IMAGE):$(VERSION); \
fi
@if [ $(CI) == false ]; \
then \
trivy image --scanners vuln $(HARBOR)/$(IMAGE):$(VERSION); \
fi
deploy: scan lint
@docker push $(HARBOR)/$(IMAGE):$(VERSION) \
# This "if" statement needs to be a one liner or it will fail.
# Do not edit indentation
@if [ $(VERSION) != latest ]; \
then \
docker push $(HARBOR)/$(IMAGE):latest; \
fi
up: check
cp .env.dev .env
bundle install
bundle exec rake db:seed
bundle exec rake db:migrate
bundle exec rails s -p 3000
check:
ifndef SOLR_IP
$(error SOLR_IP is undefined)
endif