-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
161 lines (121 loc) · 4.75 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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
set shell := ["bash", "-c"]
set dotenv-load := true
set export := true
set quiet := true
APP_PORT := env_var_or_default("APP_PORT", "443")
normal := '\033[0m'
green := "\\e[32m"
cyan := "\\e[36m"
@_help:
echo ""
just --list --unsorted --list-heading $'Commands: (all services)\n'
echo -e ""
echo -e " Sub-commands (e.g. just browser dev):"
echo -e " {{ green }}app{{ normal }} -> just app"
echo -e " {{ green }}browser{{ normal }} -> just app/browser"
echo -e " {{ green }}worker{{ normal }} -> just app/worker"
echo -e " {{ green }}api{{ normal }} -> just app/api"
echo -e ""
echo -e " Current worker version: {{ cyan }}$(cat app/worker/mod.json | jq -r '.version'){{ normal }}"
echo -e ""
echo -e " Quick links:"
echo -e " api local: {{ green }}https://worker-metaframe.localhost:{{APP_PORT}}/{{ normal }}"
echo -e " api production: {{ green }}https://container.mtfm.io{{ normal }}"
echo -e " github repo: {{ green }}https://github.com/metapages/compute-queues{{ normal }}"
echo -e " api deployment config: {{ green }}https://dash.deno.com/projects/compute-queue-api{{ normal }}"
# Validate mode
@_validate_mode mode="":
@if [ "{{ mode }}" = "remote" ] || [ "{{ mode }}" = "local" ]; then :; else echo "Error: Mode must be 'remote' or 'local'" >&2; exit 1; fi
# Start Development Environment
@dev mode="remote" +args="": (_validate_mode mode)
just app/dev {{ mode }} {{ args }}
# Runs All Functional Tests and checks code (for the mode specified)
@test mode="remote":
just app test {{ mode }}
# Runs All Functional Tests and checks code
test-all:
just app test-all
# Watch the local dev stack, running the tests when files change
@watch mode="remote" +args="":
just app watch {{ mode }} {{ args }}
# Bump the version, commit, CI will deploy and publish artifacts
@deploy version="":
just app/deploy {{ version }}
# Shut Down Development Environment
@down mode="remote" +args="": (_validate_mode mode)
just app/down {{ mode }} {{ args }}
# Clean Up Project
@clean mode="remote" +args="": (_validate_mode mode)
just app/clean {{ mode }} {{ args }}
# Run Linting
@lint:
just app/lint
# Run Lint-Fix Commands
@lint-fix:
just app/lint-fix
# Run Fix Commands
@fix:
just app/fix
# Publish Versioned Artifacts
# Usage: just publish-versioned-artifacts [version]
@publish-versioned-artifacts version="":
just app/publish-versioned-artifacts {{ version }}
# Run Local Workers
# Usage: just run-local-workers
run-local-workers: publish-versioned-artifacts
#!/usr/bin/env bash
# Replace this with your image name (without tag)
IMAGE_NAME="metapage/metaframe-docker-worker"
# Get all container IDs for a given image name, ignoring the tag part
CONTAINER_IDS=$(docker ps -a --format "{{{{.ID}}" | xargs docker inspect --format '{{{{.Id}} {{{{.Config.Image}}' | grep $IMAGE_NAME | cut -d ' ' -f 1)
if [ -z "$CONTAINER_IDS" ]; then
echo "No containers found for image: $IMAGE_NAME"
else
echo "Found containers for image: $IMAGE_NAME"
# Stop and remove the containers
for CONTAINER_ID in $CONTAINER_IDS; do
echo "Stopping container $CONTAINER_ID"
docker stop $CONTAINER_ID
echo "Removing container $CONTAINER_ID"
docker rm $CONTAINER_ID
done
echo "All containers removed."
fi
VERSION=$(cat app/worker/mod.json | jq -r .version)
docker run --restart unless-stopped -tid -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp metapage/metaframe-docker-worker:$VERSION run --cpus=2 public1
docker run --restart unless-stopped -tid -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp metapage/metaframe-docker-worker:$VERSION run --cpus=2 ${DIONS_SECRET_QUEUE}
# Quick compilation checks
@check:
just app check
# Format all supported files
@fmt +args="":
deno fmt {{ args }}
find app/*/justfile -exec just --fmt --unstable -f {} {{ args }} \;
just app/browser/fmt
# Format all supported files
@fmt-check +args="":
deno fmt --check {{ args }}
find app/*/justfile -exec just --fmt --check --unstable -f {} {{ args }} \;
just app/browser/fmt-check
# Run CI
@ci: fmt-check lint
# app subdirectory commands
alias app := _app
@_app +args="":
just app/{{ args }}
# app subdirectory commands
alias worker := _worker
@_worker +args="":
just app/worker/{{ args }}
# app subdirectory commands
alias browser := _browser
@_browser +args="":
just app/browser/{{ args }}
# app subdirectory commands
alias api := _api
@_api +args="":
just app/api/{{ args }}
# app subdirectory commands
alias shared := _shared
@_shared +args="":
just app/shared/{{ args }}