-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
149 lines (116 loc) · 4.35 KB
/
Copy pathjustfile
File metadata and controls
149 lines (116 loc) · 4.35 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
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
## Set up environment ##
export DATA_DIR := justfile_directory() / "Data"
################
# CLI Development #
################
# turns on non-containerized backend. note: no longer turns off containers
[working-directory("backend")]
local-api:
ALLOW_DEV_CORS=1 uv run uvicorn api.main:app --reload --port 6767
# turns on non-container frontend. note: no longer turns off containers
[working-directory("frontend")]
local-frontend:
NEXT_PUBLIC_API_URL=http://localhost:6767/api npm run dev -- --port 3000
# turns on non-container full apps, interleaved in terminal (from Procfile). Note: no longer turns off containers
local-dev:
uvx honcho start
########################################################
########################################################
################## CONTAINERS ###########################
########################################################
########################################################
###############################
# Pod for containers sharing local-host #
# ##############################
# build the pod for local-host co communication
build-pod:
podman pod exists app || podman pod create --name app --userns=keep-id -p 6767:6767 -p 3000:8080
# reset the local host pod (delete and recreate it).
reset-pod:
podman pod create --replace --name app --userns=keep-id -p 6767:6767 -p 3000:8080
###########
# Containers #
###########
# Combined
#########
# Run and build both containers as dev
dev: down dev-api dev-frontend
@echo "frontend hosted @ http://localhost:3000"
@echo "api hosted @ http://localhost:3000/api/docs"
# just run containers (if already built) as dev
dev-run: run-api run-frontend
## API Container
#############
# build the api image
[working-directory("backend")]
build-api:
podman build -t localhost/my-api -f dockerfile .
# run the api image (detached)
[working-directory("backend")]
run-api:
podman run --pod app --name api -d --rm -v ../Data:/data:ro,z localhost/my-api
# build the api image and then check it with more error printing (non detached)
[working-directory("backend")]
run-check-api: build-api
podman run --pod app -v ../Data:/data:ro,z localhost/my-api
# everything to get the api up and running
dev-api: build-pod build-api run-api
## Frontend Container
################
# build the frontend image
[working-directory("frontend")]
build-frontend:
podman build -t localhost/frontend -f dockerfile .
# run the frontend image (detached)
run-frontend:
podman run --pod app --name frontend -d --rm localhost/frontend
# everything to get the frontend up and running
dev-frontend: build-pod build-frontend run-frontend
# check typescript (not in the next.config, until fixed)
[working-directory("frontend")]
check-frontend:
npx tsc --noEmit
################
# ETL (Pipeline) Container
################
# --------- 1. Data Collection (E) ---------------------
# build the backend COLLECTION image
[working-directory("backend")]
build-collection:
podman build -t localhost/vdc-collection -f ETL/dockerfile.collect .
# Get the data for a specified year
[working-directory("backend")]
get-data year: build-collection
podman run --rm -v "$(pwd)/Data:/data:z" -e DATA_DIR=/data localhost/vdc-collection {{ year }}
# --------- 2. Data Cleaning (T) ---------------------
# build and run the backend CLEANING image
[working-directory("backend")]
transform-data:
podman build -t localhost/vdc-cleaning -f ETL/dockerfile.clean .
podman run --rm -v "$(pwd)/Data:/data:z" localhost/vdc-cleaning
# --------- 3. Data Loading (L) ---------------------
# build and run the backend LOADING image (loads cleaned tables into a DuckDB)
[working-directory("backend")]
load-data:
podman build -t localhost/vdc-loading -f ETL/dockerfile.load .
podman run --rm -v "$(pwd)/Data:/data:z" localhost/vdc-loading
# --------- FULL PIPELINE RUN (ETL) ---------------------
[working-directory("backend")]
run-etl year:
# Collect the data for a certain year
just get-data {{ year }}
# Clean the RAW populated lake tables into CLEANED
just transform-data
# Load CLEANED tables into DuckDB instance
just load-data
#####################
# Abstracted podman util #
#####################
logs:
podman pod logs -f app
# kill the localhost app and everything in it
down:
podman pod rm -f app
# see what containers are running
see-running:
podman ps