-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
97 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
ifeq ($(shell uname -m), arm64) | ||
TAG := arm64 | ||
else | ||
TAG := amd64 | ||
endif | ||
|
||
.PHONY: default | ||
default: run | ||
|
||
build: | ||
docker build --build-arg VCS_REF="$(shell git rev-parse HEAD)" --tag cs50/cli . | ||
$(MAKE) squash | ||
docker build --build-arg TAG=$(TAG) --build-arg VCS_REF=$(shell git rev-parse HEAD) --tag cs50/cli:$(TAG) . | ||
|
||
depends: | ||
pip3 install docker-squash | ||
|
||
rebuild: | ||
docker build --no-cache --tag cs50/cli . | ||
$(MAKE) squash | ||
docker build --build-arg TAG=$(TAG) --build-arg VCS_REF=$(shell git rev-parse HEAD) --no-cache --tag cs50/cli:$(TAG) . | ||
|
||
run: | ||
docker run --env LANG="$(LANG)" --interactive --publish-all --rm --security-opt seccomp=unconfined --tty --volume "$(PWD)":/home/ubuntu cs50/cli bash --login || true | ||
docker run --env LANG=$(LANG) --env LOCAL_WORKSPACE_FOLDER="$(PWD)" --interactive --publish-all --rm --security-opt seccomp=unconfined --tty --volume "$(PWD)":/mnt --volume /var/run/docker.sock:/var/run/docker-host.sock --workdir /mnt cs50/cli:$(TAG) bash --login || true | ||
|
||
squash: depends | ||
docker images cs50/codespace | ||
docker-squash --tag cs50/cli cs50/cli | ||
docker images cs50/codespace | ||
docker-squash --tag cs50/cli:$(TAG) cs50/cli:$(TAG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# Adapted from https://github.com/devcontainers/features/blob/main/src/docker-outside-of-docker/install.sh. | ||
# If docker-ce is installed, shadows its own. | ||
|
||
SOURCE_SOCKET=/var/run/docker-host.sock | ||
TARGET_SOCKET=/var/run/docker.sock | ||
SOCAT_PID=/tmp/docker.pid | ||
|
||
case "$1" in | ||
start) | ||
echo "Starting Docker" | ||
socat UNIX-LISTEN:${TARGET_SOCKET},fork,group=docker,mode=660 UNIX-CONNECT:${SOURCE_SOCKET} & echo "$!" > "$SOCAT_PID" | ||
;; | ||
stop) | ||
echo "Stopping Docker" | ||
kill -9 $(cat "$SOCAT_PID" 2> /dev/null) 2> /dev/null | ||
rm --force "$SOCAT_PID" "$TARGET_SOCKET" | ||
;; | ||
restart) | ||
$0 stop | ||
$0 start | ||
;; | ||
status) | ||
if [[ ! -f "${SOCAT_PID}" ]] || ! ps -p $(cat "$SOCAT_PID" 2> /dev/null) &> /dev/null; then | ||
echo "Docker is not running" | ||
exit 1 | ||
else | ||
echo "Docker is running" | ||
exit 0 | ||
fi | ||
;; | ||
*) | ||
echo "Usage: $0 {start|stop|restart|status}" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
IMAGE=rocker/r-ver | ||
|
||
options=( | ||
--interactive | ||
--rm | ||
--volume "$LOCAL_WORKSPACE_FOLDER":/mnt | ||
--workdir /mnt | ||
$IMAGE | ||
R "$@" | ||
) | ||
|
||
# If TTY | ||
if [[ -t 0 ]]; then | ||
options=(--tty "${options[@]}") | ||
docker run "${options[@]}" | ||
|
||
# If pipe | ||
else | ||
cat | docker run "${options[@]}" | ||
fi |