-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (38 loc) · 1.48 KB
/
Makefile
File metadata and controls
47 lines (38 loc) · 1.48 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
# Define variables
APP_NAME := gncitizen
BACKEND_DIR := backend
FRONTEND_DIR := frontend
DOCKER_COMPOSE_FILE := docker-compose.yml
include .env
DOCKER_IMAGE_BACKEND := $(APP_NAME)-backend
DOCKER_IMAGE_FRONTEND := $(APP_NAME)-frontend
# Phony targets
.PHONY: all install-dependencies generate-requirements build docker-start clean
# Default target
all: install-dependencies generate-requirements build docker-start
# Install dependencies for frontend and backend
install-dependencies:
cd $(BACKEND_DIR) && \
if [ -f poetry.lock ]; then \
poetry install; \
elif [ -f requirements.txt ]; then \
pip install -r requirements.txt; \
fi
cd $(FRONTEND_DIR) && npm install
# Generate Python requirements files
generate-requirements:
cd $(BACKEND_DIR) && \
poetry export -f requirements.txt -o requirements.txt --without-hashes && \
poetry export -f requirements.txt --only=dev -o requirements-dev.txt --without-hashes && \
poetry export -f requirements.txt --only=docs -o requirements-docs.txt --without-hashes
# Build Docker images for backend and frontend
build:
docker build -t $(DOCKER_IMAGE_BACKEND) -f $(BACKEND_DIR)/Dockerfile $(BACKEND_DIR)
docker build -t $(DOCKER_IMAGE_FRONTEND) -f $(FRONTEND_DIR)/Dockerfile $(FRONTEND_DIR)
# Start project using docker-compose
docker-start:
docker-compose -f $(DOCKER_COMPOSE_FILE) up -d
# Clean up Docker containers and images
clean:
docker-compose -f $(DOCKER_COMPOSE_FILE) down
docker rmi $(DOCKER_IMAGE_BACKEND) $(DOCKER_IMAGE_FRONTEND)