forked from research-software-directory/RSD-as-a-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
93 lines (80 loc) · 3.69 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
# SPDX-FileCopyrightText: 2022 - 2023 Christian Meeßen (GFZ) <christian.meessen@gfz-potsdam.de>
# SPDX-FileCopyrightText: 2022 - 2023 Dusan Mijatovic (dv4all)
# SPDX-FileCopyrightText: 2022 - 2023 Ewan Cahen (Netherlands eScience Center) <e.cahen@esciencecenter.nl>
# SPDX-FileCopyrightText: 2022 - 2023 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences
# SPDX-FileCopyrightText: 2022 - 2023 Netherlands eScience Center
# SPDX-FileCopyrightText: 2022 - 2023 dv4all
# SPDX-FileCopyrightText: 2022 Jesús García Gonzalez (Netherlands eScience Center) <j.g.gonzalez@esciencecenter.nl>
# SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center)
#
# SPDX-License-Identifier: Apache-2.0
# PHONY makes possible to call `make commands` from inside the Makefile
.PHONY: start install frontend data dev down dev-docs
# Detect user and group IDs for frontend-dev configuration
USER_OS := $(shell uname -s)
DUID := $(shell /usr/bin/id -u)
ifeq ($(USER_OS), Linux)
DGID := $(shell /usr/bin/id -g)
endif
# For MacOS use a workaround, id -g in MacOS returns a GID with a low number (usually 20)
# such low GIDs are already used in Linux, so let's create a new one
ifeq ($(USER_OS), Darwin)
DGID := $(shell dscl . -list /Groups PrimaryGroupID | awk 'BEGIN{i=0}{if($$2>i)i=$$2}END{print i+1}')
endif
export DUID
export DGID
# Main commands
# ----------------------------------------------------------------
start: clean
docker compose build # build all services
docker compose up --scale data-generation=1 --scale scrapers=0 --detach
# open http://localhost to see the application running
install: clean
docker compose build database backend auth scrapers nginx # exclude frontend and wait for the build to finish
docker compose up --scale scrapers=0 --detach
cd frontend && yarn install
cd documentation && yarn install
# Sleep 10 seconds to be sure that docker compose up is running
sleep 10
docker compose up --scale data-generation=1 --detach
# All dependencies are installed. The data migration is runing in the background. You can now run `make dev' to start the application
clean:
docker compose down --volumes
stop:
docker compose down
frontend-docker: frontend/.env.local
docker compose build frontend-dev
docker compose up --scale frontend=0 --scale scrapers=0 --scale frontend-dev=1
data:
docker compose up --scale data-generation=1 --scale scrapers=0
sleep 60
docker compose down
# Helper commands
# -
dev-docs:
cd documentation && yarn dev
frontend/.env.local: .env
@echo "Creating frontend/.env.local"
cp .env frontend/.env.local
sed -i 's/POSTGREST_URL=http:\/\/backend:3500/POSTGREST_URL=http:\/\/localhost\/api\/v1/g' frontend/.env.local
sed -i 's/RSD_AUTH_URL=http:\/\/auth:7000/RSD_AUTH_URL=http:\/\/localhost\/auth/g' frontend/.env.local
dev: frontend/.env.local
docker compose build # build all services
docker compose up --scale data-generation=1 --scale scrapers=0 --scale frontend=0 --detach
# open http://localhost:3000 to see the application running
cd frontend && yarn dev
# run end-to-end test locally
e2e-tests:
docker compose down --volumes
docker compose build --parallel database backend auth frontend nginx
docker compose up --detach --scale scrapers=0
sleep 10
docker compose --file e2e/docker-compose.yml build
docker compose --file e2e/docker-compose.yml up
docker compose down
docker compose --file e2e/docker-compose.yml down --volumes
run-backend-tests:
docker compose --file backend-tests/docker-compose.yml down --volumes
docker compose --file backend-tests/docker-compose.yml build --parallel
docker compose --file backend-tests/docker-compose.yml up --exit-code-from postgrest-tests
docker compose --file backend-tests/docker-compose.yml down --volumes