forked from rstudio/rstudio-docker-products
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Justfile
92 lines (76 loc) · 3.15 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
set positional-arguments
BUILDX_PATH := ""
IMAGE_PREFIX := "rstudio-"
PRODUCT := "package-manager"
IMAGE_OS := "ubuntu1804"
RSPM_VERSION := "2022.11.4-20"
RSPM_LICENSE := ""
RSPM_LICENSE_SERVER := ""
R_VERSION := "3.6.2"
R_VERSION_ALT := "4.1.0"
PYTHON_VERSION := "3.9.5"
PYTHON_VERSION_ALT := "3.8.10"
PERSIST_LICENSE := "false"
PERSIST_LICENSE_DIR := join(justfile_directory(), "tmp-lic")
_make-default-tag OS=IMAGE_OS:
echo "{{IMAGE_PREFIX}}{{PRODUCT}}:{{OS}}-$(just -f ../Justfile _get-tag-safe-version {{RSPM_VERSION}})"
# Build Package Manager image - just build ubuntu1804 2022.07.2-11 rstudio/rstudio-package-manager:ubuntu1804-2022.07.2-11
build OS=IMAGE_OS VERSION=RSPM_VERSION *TAGS="":
#!/usr/bin/env bash
set -euxo pipefail
BUILDX_ARGS=""
if [[ "{{BUILDX_PATH}}" != "" ]]; then
BUILDX_ARGS="--cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,dest=/tmp/.buildx-cache"
fi
if [[ "{{TAGS}}" == "" ]]; then
raw_tag_array=($(just _make-default-tag {{OS}}))
else
raw_tag_array=("{{TAGS}}")
fi
tag_array=()
for tag in $raw_tag_array
do
tag_array+=("-t" $tag)
done
docker buildx --builder="{{ BUILDX_PATH }}" build --load ${BUILDX_ARGS} \
${tag_array[@]} \
--build-arg RSPM_VERSION="{{ VERSION }}" \
--build-arg R_VERSION="{{ R_VERSION }}" \
--file=./Dockerfile.$(just -f ../Justfile _parse-os {{OS}}) .
# Test Package Manager image - just test rstudio/rstudio-package-manager:ubuntu1804-2022.07.2-11 2022.07.2-11
test TAG=`just _make-default-tag` VERSION=RSPM_VERSION CMD="":
#!/usr/bin/env bash
set -euxo pipefail
IMAGE_NAME="{{ TAG }}" \
RSPM_VERSION="{{ VERSION }}" \
RSPM_LICENSE="{{ RSPM_LICENSE }}" \
RSPM_LICENSE_SERVER="{{ RSPM_LICENSE_SERVER }}" \
R_VERSION="{{ R_VERSION }}" \
docker-compose -f ./docker-compose.test.yml run sut {{ CMD }}
# Test Package Manager image interactively - just test-i rstudio/rstudio-package-manager:ubuntu1804-2022.07.2-11 2022.07.2-11
test-i TAG=`just _make-default-tag` VERSION=RSPM_VERSION:
just test {{ TAG }} {{ VERSION }} bash
# Run Package Manager - just RSPM_LICENSE="<RSPM license>" run rstudio/rstudio-package-manager:ubuntu1804-2022.07.2-11
run TAG=`just _make-default-tag` CMD="":
#!/usr/bin/env bash
set -euxo pipefail
if [ -z "{{ RSPM_LICENSE }}" ] && [ -z "{{ RSPM_LICENSE_SERVER }}" ]; then
echo "Please set RSPM_LICENSE or RSPM_LICENSE_SERVER before running."
exit 1
fi
volume_opts=()
if [ {{ PERSIST_LICENSE }} = "true" ]; then
if [ {{RSPM_LICENSE}} ]; then
echo "Volumes will be configured to persist license state data for an activation key."
volume_opts=$(just -f ../Justfile _config-license-persist-volumes key {{PRODUCT}} {{PERSIST_LICENSE_DIR}})
elif [ {{RSPM_LICENSE_SERVER}} ]; then
echo "Volumes will be configured to persist license state data for a floating license server."
volume_opts=$(just -f ../Justfile _config-license-persist-volumes float {{PRODUCT}} {{PERSIST_LICENSE_DIR}})
fi
fi
docker run -it \
${volume_opts[@]} \
-p 4242:4242 \
-e RSPM_LICENSE="{{ RSPM_LICENSE }}" \
-e RSPM_LICENSE_SERVER="{{ RSPM_LICENSE_SERVER }}" \
"{{ TAG }}" {{ CMD }}