-
Notifications
You must be signed in to change notification settings - Fork 14
/
_95-potential_architectures.Rmdx
147 lines (124 loc) · 3.83 KB
/
_95-potential_architectures.Rmdx
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
* APPENDIX E - Potential Docker Architectures
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
if (!require(DiagrammeR)) install.packages("DiagrammeR")
library(DiagrammeR)
```
## Small architecture
The simplest architecture we can possibly use has just one container, running PostgreSQL.
* We talk to the PostgreSQL container for data analysis from RStudio on the host, using the `DBI` and `RPostgres` packages.
* We talk to the PostgreSQL container for administration by building `docker exec` commands and executing them with `system2`.
* We either mount the `Backups` volume on the host filesystem or we copy files to and from `Backups` with `docker cp` commands wrapped with `system2`.
```{r echo=FALSE}
small_widget <- DiagrammeR::mermaid("
graph LR
Host_Filesystem---Backups
RStudio---PostgreSQL
subgraph Containers
PostgreSQL
end
subgraph Volumes
PostgreSQL---pgdata
PostgreSQL---Backups
end
end
")
# export the widget to an SVG file
small_widget %>%
DiagrammeRsvg::export_svg() %>%
cat(file = "diagrams/fkgraph.svg")
# convert to PDF and PNG - LaTeX doesn't read SVGs by default
magick::image_read("diagrams/fkgraph.svg") %>%
magick::image_write(
path = "diagrams/fkgraph.pdf",
format = "pdf"
)
magick::image_read_svg("diagrams/fkgraph.svg") %>%
magick::image_write(
path = "diagrams/fkgraph.png",
format = "png"
)
```
```{r echo=FALSE}
# display the PNG/PDF - this works in both HTML and PDF
knitr::include_graphics("diagrams/fkgraph.png", auto_pdf = TRUE)
```
<br><br><br>
## Medium architecture
The medium architecture adds a `pgAdmin4` container for administering the PostgreSQL server. We have the same workflow for backups, and we still do the data analysis with host RStudio, but we manage the server with a browser pointed at the `pgAdmin4` web service.
```{r echo=FALSE}
medium_widget <- DiagrammeR::mermaid("
graph LR
Host_Filesystem---Backups
RStudio---PostgreSQL
Browser---pgAdmin4
subgraph Containers
PostgreSQL---pgAdmin4
end
subgraph Volumes
pgAdmin4---Backups
PostgreSQL---pgdata
end
end
")
# export the widget to an SVG file
medium_widget %>%
DiagrammeRsvg::export_svg() %>%
cat(file = "diagrams/fkgraph.svg")
# convert to PDF and PNG - LaTeX doesn't read SVGs by default
magick::image_read("diagrams/fkgraph.svg") %>%
magick::image_write(
path = "diagrams/fkgraph.pdf",
format = "pdf"
)
magick::image_read_svg("diagrams/fkgraph.svg") %>%
magick::image_write(
path = "diagrams/fkgraph.png",
format = "png"
)
```
```{r echo=FALSE}
# display the PNG/PDF - this works in both HTML and PDF
knitr::include_graphics("diagrams/fkgraph.png", auto_pdf = TRUE)
```
<br><br><br>
## Large architecture (95)
In the large architecture, we add a `rocker/rstudio` container, thus creating a fully-containerized workflow. We talk to the containers via a browser only.
```{r echo=FALSE}
large_widget <- DiagrammeR::mermaid("
graph LR
Host_Filesystem---Backups
Browser---Rocker_RStudio
Browser---pgAdmin4
subgraph Containers
PostgreSQL---pgAdmin4
Rocker_RStudio---PostgreSQL
end
subgraph Volumes
pgAdmin4---Backups
PostgreSQL---pgdata
end
end")
```
# export the widget to an SVG file
large_widget %>%
DiagrammeRsvg::export_svg() %>%
cat(file = "diagrams/fkgraph.svg")
# convert to PDF and PNG - LaTeX doesn't read SVGs by default
magick::image_read("diagrams/fkgraph.svg") %>%
magick::image_write(
path = "diagrams/fkgraph.pdf",
format = "pdf"
)
magick::image_read_svg("diagrams/fkgraph.svg") %>%
magick::image_write(
path = "diagrams/fkgraph.png",
format = "png"
)
```
```{r echo=FALSE}
# display the PNG/PDF - this works in both HTML and PDF
knitr::include_graphics("diagrams/fkgraph.png", auto_pdf = TRUE)
```
-- M. Edward (Ed) Borasky
-- M. Edward (Ed) Borasky