forked from WordPress/openverse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
89 lines (69 loc) · 2.31 KB
/
justfile
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
set dotenv-load := false
COLOR := "\\033[0;32m"
NO_COLOR := "\\033[0m"
# Show all available recipes
@_default:
printf "\n{{ COLOR }}# Frontend (path: \`frontend/\`)\n"
printf "=============================={{ NO_COLOR }}\n"
just --list --unsorted
###########
# Version #
###########
export FRONTEND_NODE_VERSION := `grep "volta" -A 1 ../package.json | tail -n 1 | awk -F'[:"]' '{print $5}' | cut -d. -f1`
export FRONTEND_PNPM_VERSION := `grep 'packageManager' ../package.json | awk -F'@' '{print $2}' | sed 's/",//g'`
# Print the Node.js version specified in `package.json`
@node-version:
echo $FRONTEND_NODE_VERSION
# Print the pnpm version specified in `package.json`
@pnpm-version:
echo $FRONTEND_PNPM_VERSION
##########
# Docker #
##########
# This section exists because the frontend is not a part of the Docker-based setup
# and cannot be built easily like `just dc build <service>`.
# Build the frontend Docker image
build-img tag="openverse-frontend:local" target="app":
docker build \
--target {{ target }} \
--build-context 'repo_root=..' \
--build-arg FRONTEND_NODE_VERSION=$(just node-version) \
--build-arg FRONTEND_PNPM_VERSION=$(just pnpm-version) \
--tag {{ tag }} \
.
# Run the frontend Docker image
run-img tag="openverse-frontend:local":
docker run \
--rm \
--publish 8443:8443 \
{{ tag }}
######
# Up #
######
# Bring up services specific to the frontend profile
up *flags:
env COMPOSE_PROFILES="frontend" just ../up {{ flags }}
# Wait for all profile services to be up
wait-up: up
just wait
# Set up user and test site in Plausible
init: wait-up
cd .. && ./setup_plausible.sh
# Run a package.json script via pnpm
run *args:
pnpm run {{ args }}
types:
cd .. && pnpm exec vue-tsc -p frontend --noEmit
##########
# Health #
##########
# Check the health of the service
@plausible-health host="localhost:50288":
-curl -s 'http://localhost:50288/api/health' --fail | grep -v -c 'error'
# Wait for the service to be healthy
@wait host="localhost:50288":
# The just command on the second line is executed in the context of the
# parent directory and so must be prefixed with `frontend/`.
just ../_loop \
'"$(just frontend/plausible-health {{ host }})" != "1" ' \
"Waiting for Plausible to be healthy..."