-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated run script and added compose file
- Loading branch information
Showing
5 changed files
with
84 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdio.h> | ||
#include <curl/curl.h> | ||
|
||
int main(void) { | ||
CURL *curl; | ||
CURLcode res; | ||
|
||
curl_global_init(CURL_GLOBAL_DEFAULT); | ||
|
||
curl = curl_easy_init(); | ||
if(curl) { | ||
curl_easy_setopt(curl, CURLOPT_URL, "https://registry-1.docker.io/v2/dbecker1/cs2110docker/tags/list"); | ||
/* Perform the request, res will get the return code */ | ||
res = curl_easy_perform(curl); | ||
/* Check for errors */ | ||
if(res != CURLE_OK) | ||
fprintf(stderr, "curl_easy_perform() failed: %s\n", | ||
curl_easy_strerror(res)); | ||
|
||
/* always cleanup */ | ||
curl_easy_cleanup(curl); | ||
} | ||
|
||
curl_global_cleanup(); | ||
|
||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import urllib.request, urllib.parse, urllib.error | ||
import json | ||
import os | ||
from subprocess import call | ||
|
||
authUrl = "https://auth.docker.io/token?service=registry.docker.io&scope=repository:dbecker1/cs2110docker:pull" | ||
|
||
authResponse = urllib.request.urlopen(authUrl) | ||
authData = authResponse.read().decode() | ||
|
||
try: | ||
authJs = json.loads(authData) | ||
except: | ||
authJs = None | ||
|
||
imageDataUrl = "https://registry-1.docker.io/v2/dbecker1/cs2110docker/tags/list"; | ||
dataRequest = urllib.request.Request(imageDataUrl) | ||
|
||
dataRequest.add_header('Authorization', "Bearer " + authJs["token"]); | ||
|
||
dataResponse = urllib.request.urlopen(dataRequest) | ||
imageData = dataResponse.read().decode() | ||
|
||
try: | ||
imageJs = json.loads(imageData) | ||
except: | ||
imageJs = None | ||
|
||
tags = imageJs["tags"] | ||
mostRecentTag = "0.0.0" | ||
|
||
for tag in tags: | ||
if tag == "latest": | ||
continue | ||
tag1Split = mostRecentTag.split(".") | ||
tag2Split = tag.split(".") | ||
i = 0 | ||
if i < len(tag1Split) and i < len(tag2Split): | ||
if int(tag1Split[i]) < int(tag2Split[i]): | ||
mostRecentTag = tag | ||
break | ||
elif len(tag2Split) > len(tag1Split): | ||
mostRecentTag = tag | ||
break | ||
|
||
currentVersion = os.environ['CS2110_IMAGE_VERSION'] | ||
|
||
if mostRecentTag != currentVersion: | ||
call(["notify-send", "'Update Docker Image'", "'Hello, your TAs have pushed an update to this Docker Image. In order to ensure you have the latest and greatest, please re-run the cs2110docker.sh script'"]) | ||
else: | ||
print("Docker image is up to date") |
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,3 @@ | ||
services: | ||
cs2110docker: | ||
build: https://github.com/dbecker1/cs2110docker |