File tree 5 files changed +82
-0
lines changed
5 files changed +82
-0
lines changed Original file line number Diff line number Diff line change
1
+ # sandbox-docker
2
+
3
+ Sandbox apps into a docker container.
4
+
5
+ ## Installation
6
+
7
+ Copy it into your home directory and make it runnable:
8
+ ```
9
+ mkdir ~/.sandbox
10
+ cp -r . ~/.sandbox
11
+ chmod u+x ~/.sandbox/sandbox*.sh
12
+ ```
13
+
14
+ Set up aliases in ` .*rc ` file:
15
+ ```
16
+ alias mountbox="${HOME}/.sandbox/sandbox-static-mount.sh"
17
+ alias box="${HOME}/.sandbox/sandbox.sh"
18
+ ```
19
+
20
+ Usage for using it inside the current working directory:
21
+
22
+ ```
23
+ box youtube-dl ...
24
+ ```
25
+
26
+ Usage for not even giving the program the current working directory but using a static mount (` $INSTALL_DIRECTORY/sandbox/ ` ):
27
+
28
+ ```
29
+ mountbox youtube-dl ...
30
+ ```
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ APP_TO_RUN=" $1 "
4
+ shift
5
+ ARGUMENTS=" $@ "
6
+ SCRIPT_PATH=" $( cd " $( dirname " $0 " ) " ; pwd -P ) "
7
+
8
+ APP_PATH=" ${SCRIPT_PATH} /apps/${APP_TO_RUN} "
9
+ VOLUME_DIR=" ${SCRIPT_PATH} /sandbox"
10
+ DOCKERFILE=" ${APP_PATH} /Dockerfile"
11
+
12
+ DOCKERFILE_VERSION=$( md5 -q " $DOCKERFILE " )
13
+ IMAGE_NAME=" ${APP_TO_RUN} :${DOCKERFILE_VERSION} "
14
+
15
+ # If the docker image does not exist yet, create it
16
+ if ! docker inspect " $IMAGE_NAME " > /dev/null; then
17
+ echo " Building $IMAGE_NAME "
18
+ docker build -t " $IMAGE_NAME " -f " $DOCKERFILE " $APP_PATH
19
+ fi
20
+
21
+ echo " Running $APP_TO_RUN "
22
+ docker run \
23
+ --rm \
24
+ --name " $APP_TO_RUN " \
25
+ --volume " ${VOLUME_DIR} :/app" \
26
+ " $IMAGE_NAME " \
27
+ " $APP_TO_RUN " " $ARGUMENTS "
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ APP_TO_RUN=" $1 "
4
+ shift
5
+ ARGUMENTS=" $@ "
6
+ SCRIPT_PATH=" $( cd " $( dirname " $0 " ) " ; pwd -P ) "
7
+
8
+ APP_PATH=" ${SCRIPT_PATH} /apps/${APP_TO_RUN} "
9
+ DOCKERFILE=" ${APP_PATH} /Dockerfile"
10
+ DOCKERFILE_VERSION=$( md5 -q " $DOCKERFILE " )
11
+ IMAGE_NAME=" ${APP_TO_RUN} :${DOCKERFILE_VERSION} "
12
+ VOLUME_DIR=" $( pwd) "
13
+
14
+ if ! docker inspect " $IMAGE_NAME " > /dev/null; then
15
+ echo " Building $IMAGE_NAME "
16
+ docker build -t " $IMAGE_NAME " -f " $DOCKERFILE " $APP_PATH
17
+ fi
18
+
19
+ echo " Running $APP_TO_RUN "
20
+ docker run \
21
+ --rm \
22
+ --name " $APP_TO_RUN " \
23
+ --volume " ${VOLUME_DIR} :/app" \
24
+ " $IMAGE_NAME " \
25
+ " $APP_TO_RUN " " $ARGUMENTS "
You can’t perform that action at this time.
0 commit comments