Skip to content

Commit 56751d3

Browse files
committed
local docker container
1 parent de06543 commit 56751d3

6 files changed

Lines changed: 90 additions & 0 deletions

File tree

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
.PHONY: clean-pyc clean-build clean docs
22
UNAME := $(shell uname)
33

4+
SPHINX_BUILDARGS=
5+
# Note that these are keys generated by the docker rsconnect service, so are
6+
# not really secrets. They are saved to json to make it easy to use rsconnect
7+
# as multiple users from the tests
8+
RSC_API_KEYS=vetiver/tests/rsconnect_api_keys.json
9+
410
ifeq ($(UNAME), Darwin)
511
BROWSER := open
612
else
@@ -73,3 +79,23 @@ install: clean
7379

7480
develop: clean-pyc
7581
python setup.py develop
82+
83+
dev: vetiver/tests/rsconnect_api_keys.json
84+
85+
dev-start:
86+
docker-compose up -d
87+
docker-compose exec -T rsconnect bash < script/setup-rsconnect/add-users.sh
88+
# curl fails with error 52 without a short sleep....
89+
sleep 5
90+
curl -s --retry 10 --retry-connrefused http://localhost:3939
91+
92+
dev-stop:
93+
docker-compose down
94+
rm -f $(RSC_API_KEYS)
95+
96+
$(RSC_API_KEYS): dev-start
97+
python script/setup-rsconnect/dump_api_keys.py $@
98+
99+
test:
100+
pytest
101+

docker-compose.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: '3.1'
2+
3+
services:
4+
5+
rsconnect:
6+
image: rstudio/rstudio-connect:2021.12.1
7+
restart: always
8+
ports:
9+
- 3939:3939
10+
volumes:
11+
- $PWD/script/setup-rsconnect/users.txt:/etc/users.txt
12+
- $PWD/script/setup-rsconnect/rstudio-connect.gcfg:/etc/rstudio-connect/rstudio-connect.gcfg
13+
# by default, mysql rounds to 4 decimals, but tests require more precision
14+
privileged: true
15+
environment:
16+
RSTUDIO_CONNECT_HASTE: "enabled"
17+
RSC_LICENSE: ${RSC_LICENSE}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
awk ' { system("useradd -m -s /bin/bash "$1); system("echo \""$1":"$2"\" | chpasswd"); system("id "$1) } ' /etc/users.txt
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import json
2+
import sys
3+
4+
from pins.rsconnect.api import _HackyConnect
5+
6+
OUT_FILE = sys.argv[1]
7+
8+
9+
def get_api_key(user, password, email):
10+
rsc = _HackyConnect("http://localhost:3939")
11+
12+
return rsc.create_first_admin(user, password, email).api_key
13+
14+
15+
api_keys = {
16+
"admin": get_api_key("admin", "admin0", "admin@example.com"),
17+
"susan": get_api_key("susan", "susan", "susan@example.com"),
18+
"derek": get_api_key("derek", "derek", "derek@example.com"),
19+
}
20+
21+
json.dump(api_keys, open(OUT_FILE, "w"))
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[Server]
2+
DataDir = /data
3+
Address = http://localhost:3939
4+
5+
[HTTP]
6+
Listen = :3939
7+
8+
[Authentication]
9+
Provider = pam
10+
11+
[Authorization]
12+
DefaultUserRole = publisher
13+
14+
[Python]
15+
Enabled = false
16+
17+
[RPackageRepository "CRAN"]
18+
URL = https://packagemanager.rstudio.com/cran/__linux__/bionic/latest
19+
20+
[RPackageRepository "RSPM"]
21+
URL = https://packagemanager.rstudio.com/cran/__linux__/bionic/latest

script/setup-rsconnect/users.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
admin admin0
2+
test test
3+
susan susan
4+
derek derek

0 commit comments

Comments
 (0)