-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (91 loc) · 3.84 KB
/
Makefile
File metadata and controls
122 lines (91 loc) · 3.84 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
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
PYTHON_VERSION = "3.11.6"
VENV_NAME := $(shell basename $(PWD))
ONELINE: .
_configure_redis_password:
./docker.sh run --rm redis redis-cli -a $(REDIS_PASSWORD) CONFIG SET requirepass $(REDIS_PASSWORD)
build:
./docker.sh build
down:
./docker.sh down
restart: stop run
run:
./docker.sh up -d
setup:
./scripts/setup.sh
stop:
./docker.sh stop
generate-migration:
./docker.sh run --rm api alembic -c ./core/src/core/alembic.ini revision --autogenerate -m "$(m)"
create-empty-migration:
./docker.sh run --rm api alembic -c ./core/src/core/alembic.ini revision -m "$(m)"
migrate:
./docker.sh run --rm api alembic -c ./core/src/core/alembic.ini upgrade head
test:
MODE=test ./docker.sh run --rm -it test pytest tests
_install_python_version:
echo "\n>Install Python version in pyenv if it doesn't exist yet..."
echo Saving "$(VENV_NAME)" in .python-version
echo $(VENV_NAME) > .python-version
echo "-- Checking python pyenv $ installation..."
if pyenv versions | grep -q $(PYTHON_VERSION); then \
echo "- python $(PYTHON_VERSION) installation was found in pyenv"; \
else \
echo "- python $(PYTHON_VERSION) installation was not found in pyenv, installing it..."; \
pyenv install $(PYTHON_VERSION); \
fi
_install_virtualenv:
# Resets virtual env
echo "\n>Installing virtual env..."
echo "- Uninstalling previous venv..."
pyenv uninstall -f $(VENV_NAME)
echo "- Installing venv..."
pyenv virtualenv $(PYTHON_VERSION) $(VENV_NAME)
pip install --upgrade wheel pip==25.2
_install_packages:
echo "Installing local packages"
# requirements-test.txt already contains core requirements
# pip3 install -r backend/core/requirements.txt
pip3 install -r backend/core/requirements-test.txt
pip3 install -r backend/api/requirements.txt
_install_pre_commit_hooks:
pre-commit install
_create_local_env_files:
# Check if ./config/env exists and creates it by copying ./config/env_template content otherwise
if [ -d "./config/env" ]; then \
echo "Env directory already exists"; \
else \
echo "Creating local env variables"; \
cp -R ./config/env_template ./config/env; \
echo "Env variables target created. Please, provide actual values before running application"; \
fi
setup-venv: \
_install_python_version \
_install_virtualenv \
_install_packages \
_install_pre_commit_hooks \
_create_local_env_files
generate-local-certs:
# Wait for confirmation from user to generate new certificates
@echo "This will generate new local certificates, are you sure you want to continue? [y/N] "; \
read REPLY; \
if [ "$$REPLY" != "y" ] && [ "$$REPLY" != "Y" ]; then \
exit 1; \
fi
# Remove existing certificates or ignore if they don't exist
rm -r certs || true
mkdir certs
mkcert -cert-file certs/local-cert.pem -key-file certs/local-key.pem "localhost"
_compile_requirements_api:
pip-compile --no-emit-index-url backend/core/pyproject.toml backend/api/pyproject.toml --output-file backend/api/requirements.txt
_compile_requirements_core:
pip-compile --no-emit-index-url backend/core/pyproject.toml --output-file backend/core/requirements.txt
_compile_requirements_test:
pip-compile --no-emit-index-url --extra dev backend/core/pyproject.toml --output-file backend/core/requirements-test.txt
_compile_requirements_community_manager:
pip-compile --no-emit-index-url backend/core/pyproject.toml backend/community_manager/pyproject.toml --output-file backend/community_manager/requirements.txt
compile_requirements: _compile_requirements_api _compile_requirements_core _compile_requirements_test _compile_requirements_community_manager
cp backend/core/requirements.txt backend/indexer_blockchain/requirements.txt
cp backend/core/requirements.txt backend/indexer_gifts/requirements.txt
cp backend/core/requirements.txt backend/indexer_price/requirements.txt
cp backend/core/requirements.txt backend/indexer_stickers/requirements.txt
include config/env/.core.env