-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
99 lines (75 loc) · 3.27 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
# Makefile for setting up a virtual enviroment and running the application.
.PHONY: install dependencies install_libxmlsec1
# SECTION 1: Install dependencies
DEPENDENCIES := pkg-config libffi libjpeg poetry pyenv pyenv-virtualenv
install: dependencies install_libxmlsec1
dependencies: $(DEPENDENCIES)
$(DEPENDENCIES):
@if ! brew list $@ >/dev/null 2>&1; then \
echo "Installing $@..."; \
brew install $@; \
else \
echo "$@ is already installed."; \
fi
install_libxmlsec1:
@if ! brew list [email protected] >/dev/null 2>&1; then \
echo "Installing [email protected]..."; \
brew tap tvuotila/libxmlsec1; \
brew install tvuotila/libxmlsec1/[email protected]; \
else \
echo "[email protected] is already installed."; \
fi
# SECTION 2: Set up the virtual environment with Python packages
.PHONY: venv
# The Python version and virtual environment name
PYTHON_VERSION=3.11.1
VENV_NAME=circ-311
venv:
@echo "Installing Python $(PYTHON_VERSION)..."
pyenv install -s $(PYTHON_VERSION)
@echo "Creating virtual environment $(VENV_NAME)..."
pyenv virtualenv $(PYTHON_VERSION) $(VENV_NAME)
# SECTION 3: Run the python application and the containers in development mode.
.PHONY: run setup_env_variables run_python_app start_docker stop_docker rebuild_docker clean
# Define environment variables, change them to whatever you need
export ADMIN_EKIRJASTO_AUTHENTICATION_URL=https://localhost # This should be changed to the actual one!
export PALACE_SEARCH_URL=http://localhost:9200
export SIMPLIFIED_PRODUCTION_DATABASE=postgresql://palace:test@localhost:5432/circ
PYTHON_APP = app.py
# Docker compose file, change filename to whatever you need
DOCKER_COMPOSE_FILE = docker-compose-dev.yml
run: setup_env_variables rebuild_docker run_python_app
# Target to set up environment (exporting environment variables)
setup_env_variables:
@echo "Setting up environment..."
@export ADMIN_EKIRJASTO_AUTHENTICATION_URL=${ADMIN_EKIRJASTO_AUTHENTICATION_URL}
@export PALACE_SEARCH_URL=${PALACE_SEARCH_URL}
@export SIMPLIFIED_PRODUCTION_DATABASE=${SIMPLIFIED_PRODUCTION_DATABASE}
@echo "Environment variables set: ADMIN_EKIRJASTO_AUTHENTICATION_URL=${ADMIN_EKIRJASTO_AUTHENTICATION_URL}, \
PALACE_SEARCH_URL=${PALACE_SEARCH_URL}, SIMPLIFIED_PRODUCTION_DATABASE=${SIMPLIFIED_PRODUCTION_DATABASE}"
# Target to run the Python application instead in a Docker container
run_python_app:
@echo "Starting Python application..."
@poetry run python ${PYTHON_APP}
start_docker:
@echo "Starting Docker containers..."
@docker-compose -f ${DOCKER_COMPOSE_FILE} up -d
stop_docker:
@echo "Stopping Docker containers..."
@docker-compose -f ${DOCKER_COMPOSE_FILE} down
rebuild_docker:
@echo "Rebuilding Docker images ..."
@docker-compose -f ${DOCKER_COMPOSE_FILE} build --no-cache
@docker-compose -f ${DOCKER_COMPOSE_FILE} up -d
# Define the path where the PostgreSQL data is stored: Check your docker-compose-dev.yml file to see the location.
POSTGRES_DATA = ../circ-postgres-postrelease
# Clean target to remove any generated files or containers (if needed)
clean: stop_docker
@echo "Cleaning up..."
@if [ -d "${POSTGRES_DATA}" ]; then \
echo "Deleting directory: ${POSTGRES_DATA}"; \
rm -rf ${POSTGRES_DATA}; \
echo "Deleted directory: ${POSTGRES_DATA}"; \
else \
echo "Directory ${POSTGRES_DATA} does not exist."; \
fi