Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
Use ECR Public
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-Toosi committed May 31, 2023
1 parent 63fa428 commit bf30bd0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
requests==2.28.2
docker==6.0.1
boto3==1.26.105
boto3==1.26.143
pre-commit==3.3.1
11 changes: 4 additions & 7 deletions src/docker_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import docker
from docker.errors import APIError, ImageNotFound, NotFound

AWS_REGION = "ap-southeast-2"
AWS_REGION = "us-east-1"
ECR_REGISTRY = os.environ.get("ECR_REGISTRY")
SUBMISSIONS_ECR_REPO = os.environ.get("SUBMISSIONS_ECR_REPO")
GAME_SERVER_ECR_REPO = os.environ.get("GAME_SERVER_ECR_REPO")
Expand All @@ -17,21 +17,18 @@
print("ECR details should be provided in the env vars, bye.")
quit()

ECR_CLIENT = boto3.client("ecr", region_name=AWS_REGION)
ECR_CLIENT = boto3.client("ecr-public", region_name=AWS_REGION)

# Authenticate Docker to ECR registry
token = ECR_CLIENT.get_authorization_token()
username, password = (
base64.b64decode(token["authorizationData"][0]["authorizationToken"])
base64.b64decode(token["authorizationData"]["authorizationToken"])
.decode()
.split(":")
)
registry = token["authorizationData"][0]["proxyEndpoint"]
if str(registry).startswith("https://"):
registry = registry[8:]

DOCKER_CLIENT = docker.from_env()
DOCKER_CLIENT.login(username, password, registry=registry)
DOCKER_CLIENT.login(username, password, registry=ECR_REGISTRY)


def get_submission_image_tag(submission_id):
Expand Down

0 comments on commit bf30bd0

Please sign in to comment.