-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.sh
200 lines (171 loc) · 6.88 KB
/
init.sh
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/env bash
#
# A shell script to bootstrap the environments for demos.
#
# Usage:
# /bin/bash bootstrap.sh
export DEBIAN_FRONTEND='noninteractive'
set -o nounset
set -e
PROJECT_ROOT=$(pwd)
heading() {
echo ""
echo "====================================================================="
echo "# $1"
echo "====================================================================="
}
create_venv() {
REQUIREMENTS_TXT="$1"
uv venv
uv pip install -r "$REQUIREMENTS_TXT"
}
install_uv() {
heading "Installing uv"
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.cargo/env
}
install_zsh() {
heading "Installing zsh"
wget -O zsh.tar.xz https://sourceforge.net/projects/zsh/files/latest/download
mkdir zsh && unxz zsh.tar.xz && tar -xvf zsh.tar -C zsh --strip-components 1
cd zsh
}
install_starship() {
heading "Installing starship"
wget --no-verbose --directory-prefix '/tmp' https://github.com/starship/starship/releases/download/v1.17.1/starship-x86_64-unknown-linux-musl.tar.gz
tar --directory ~/.local/bin -zxf /tmp/starship-x86_64-unknown-linux-musl.tar.gz
echo 'eval "$(~/.local/bin/starship init bash)"' >> ~/.bashrc
}
install_nerdfont() {
heading "Installing nerdfont (DroidSansMono NF)"
curl -sS https://webi.sh/nerdfont | sh
}
install_gh() {
heading "Installing gh"
curl -sS https://webi.sh/gh | sh
git config --global user.name "SamEdwardes"
git config --global user.email "[email protected]"
~/.local/bin/gh auth setup-git
}
install_ripgrep() {
heading "Installing ripgrep (rg)"
curl -sS https://webi.sh/rg | sh
}
install_shellcheck() {
heading "Installing shellcheck"
curl -sS https://webi.sh/shellcheck | sh
}
install_bat() {
heading "Installing bat"
curl -sS https://webi.sh/bat | sh
}
bootstrap_r() {
heading "Bootstrapping R environment"
local R_INIT=$(cat << EOF
options(repos = c(CRAN = "https://packagemanager.posit.co/cran/__linux__/jammy/latest"))
install.packages("pak")
pak::pkg_install(c(
"renv",
"tidyverse",
"shiny",
"shinydashboard",
"gt",
"gtExtras",
"palmerpenguins",
"quarto",
"rmarkdown",
"janitor",
"plumber",
"devtools",
"usethis"
))
EOF
)
Rscript -e "$R_INIT"
}
# ------------------------------------------------------------------------------
# Install CLI tools
# ------------------------------------------------------------------------------
mkdir -p ~/.local/bin
install_uv
install_starship
install_nerdfont
install_gh
install_ripgrep
install_shellcheck
install_bat
# ------------------------------------------------------------------------------
# Bootstrap R
# ------------------------------------------------------------------------------
bootstrap_r
# ------------------------------------------------------------------------------
# Python - Applications
# ------------------------------------------------------------------------------
cd "$PROJECT_ROOT/applications/dash-multi-page-penguins/using-dash-pages"
heading "$(pwd)"
create_venv "requirements.txt"
.venv/bin/rsconnect deploy dash --new --title "Python App - Dash - Multipage (using Dash pages)" --python .venv/bin/python --entrypoint app:app .
cd "$PROJECT_ROOT/applications/dash-multi-page-penguins/using-dcc-location"
heading "$(pwd)"
create_venv "requirements.txt"
.venv/bin/rsconnect deploy dash --new --title "Python App - Dash Multipage (using dcc)" --python .venv/bin/python --entrypoint app:app .
cd "$PROJECT_ROOT/applications/dash-penguins"
heading "$(pwd)"
create_venv "app/requirements.txt"
.venv/bin/rsconnect deploy dash --new --title "Python App - Dash - Pengins" --python .venv/bin/python --entrypoint app:app app
cd "$PROJECT_ROOT/applications/streamlit-penguins"
heading "$(pwd)"
create_venv "app/requirements.txt"
.venv/bin/rsconnect deploy streamlit --new --title "Python App - Streamlit - Penguins" --python .venv/bin/python --entrypoint app app
# ------------------------------------------------------------------------------
# R - Applications
# ------------------------------------------------------------------------------
cd "$PROJECT_ROOT/applications/shiny-for-r-with-reticulate"
heading "$(pwd)"
create_venv "requirements.txt"
Rscript -e 'rsconnect::deployApp(appFiles = c("app.R", "requirements.txt"), forceUpdate = TRUE, appTitle = "R App - Reticulate Shiny App")'
cd "$PROJECT_ROOT/applications/shiny-penguins"
heading "$(pwd)"
Rscript -e 'rsconnect::deployApp(appDir = "app", appFiles = c("app.R"), forceUpdate = TRUE, appTitle = "R App - Shiny - Penguins")'
# ------------------------------------------------------------------------------
# Python - Dcouments
# ------------------------------------------------------------------------------
cd "$PROJECT_ROOT/documents/jupyter-python-penguins"
heading "$(pwd)"
create_venv "requirements.txt"
.venv/bin/rsconnect deploy notebook --new --title "Python Notebook - Jupyter Notebook - Penguins" --python .venv/bin/python notebook.ipynb
# cd "$PROJECT_ROOT/documents/jupyter-using-ray"
# heading "$(pwd)"
# create_venv "requirements.txt"
# ------------------------------------------------------------------------------
# R - Dcouments
# ------------------------------------------------------------------------------
cd "$PROJECT_ROOT/documents/quarto-colorado-report"
heading "$(pwd)"
Rscript -e 'renv::restore(repos = "https://packagemanager.posit.co/cran/__linux__/jammy/latest")'
# Rscript -e 'renv::install("rsconnect"); rsconnect::deployApp(appDir = ".", appPrimaryDoc = "colorado-report.qmd")'
# ------------------------------------------------------------------------------
# Python - APIs
# ------------------------------------------------------------------------------
cd "$PROJECT_ROOT/apis/fastapi-penguins"
heading "$(pwd)"
create_venv "requirements.txt"
.venv/bin/rsconnect deploy fastapi --new --title "Python API - Fast API - Penguins" --python .venv/bin/python --entrypoint app:app .
cd "$PROJECT_ROOT/apis/fastapi-whoami"
heading "$(pwd)"
create_venv "requirements.txt"
.venv/bin/rsconnect deploy fastapi --new --title "Python API - Fast API - whoami" --python .venv/bin/python --entrypoint app:app .
cd "$PROJECT_ROOT/apis/flask-webapp"
heading "$(pwd)"
create_venv "requirements.txt"
.venv/bin/rsconnect deploy api --new --title "Python App - Flask - Web App" --entrypoint "app.app:app" --python ".venv/bin/python" .
# cd "$PROJECT_ROOT/apis/vetiver-train-and-deploy-python"
# heading "$(pwd)"
# create_venv "requirements.txt"
# ------------------------------------------------------------------------------
# R - APIs
# ------------------------------------------------------------------------------
cd "$PROJECT_ROOT/apis/plumber-penguins"
heading "$(pwd)"
Rscript -e 'renv::restore(repos = "https://packagemanager.posit.co/cran/__linux__/jammy/latest")'
Rscript -e 'renv::install("rsconnect"); rsconnect::deployAPI(api = "app", appFiles = c("plumber.R"), appTitle = "R API - Plumber - Penguins Data", forceUpdate = TRUE)'