Skip to content

Commit

Permalink
artipie#18 fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammers21 committed Aug 4, 2020
1 parent 09eedf3 commit 96a3c54
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions aws-infrastructure/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ for IP in $PUBLIC_SERVER_IP_ADDR $PUBLIC_CLIENT_IP_ADDR
do
ssh -i aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$IP <<'ENDSSH'
set -x
set -e
sudo apt-get update
sudo apt-get install -y \
python3 \
Expand Down
32 changes: 17 additions & 15 deletions docker/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
images = ["ubuntu", "graphiteapp/graphite-statsd", "g4s8/artipie-base"]

# Start artipie with preconfigured docker repo


def start_artipie():
print("Starting artipie")
artipie_yml = """
Expand All @@ -28,12 +30,10 @@ def start_artipie():
- "*"
"""
os.makedirs("./configs", exist_ok=True)
f = open("./artipie.yaml", "w+")
f.write(artipie_yml)
f.close()
f = open("./configs/my-docker.yaml", "w+")
f.write(my_docker)
f.close()
with open("./artipie.yaml", "w+") as f:
f.write(artipie_yml)
with open("./configs/my-docker.yaml", "w+") as f:
f.write(my_docker)
subprocess.run([
"bash", "-c",
"docker run -d --rm --name artipie -it -v $(pwd)/artipie.yaml:/etc/artipie.yml -v $(pwd):/var/artipie -p 8080:80 artipie/artipie:latest"
Expand Down Expand Up @@ -75,7 +75,7 @@ def perform_benchmarks(images):
}
}
}
}
}
single = result["docker"]["single-upload"]
for image in images:
registry_push = ["docker", "push", f"localhost:5000/{image}"]
Expand All @@ -88,17 +88,19 @@ def perform_benchmarks(images):
print(f"Command: {cmd}\'n Elapsed: {artipie_time}")
single["artipie"]["images"].append({image: artipie_time})
single["docker-registry"]["images"].append({image: registry_time})
f = open("docker.json", "w+")
f.write(json.dumps(result, indent=4, sort_keys=True))
f.close()

with open("benchmark-results.json", "w+") as f:
f.write(json.dumps(result, indent=4, sort_keys=True))

# Pull images form docker hub and tag them for subsequent pushes
def pull_and_tag(images, host = "localhost"):


def pull_and_tag(images, host="localhost"):
for image in images:
subprocess.run(["docker", "pull", image])
subprocess.run(["docker", "tag", image, f"{host}:5000/{image}"])
subprocess.run(["docker", "tag", image, f"{host}:8080/my-docker/{image}"])
subprocess.run(
["docker", "tag", image, f"{host}:8080/my-docker/{image}"])


# Entry point
if __name__ == '__main__':
Expand All @@ -113,7 +115,8 @@ def pull_and_tag(images, host = "localhost"):
subprocess.run(["docker", "stop", "artipie"])
# Run only pulling and tagging
elif sys.argv[1] == "pull":
pull_and_tag(images, host = os.getenv("PUBLIC_SERVER_IP_ADDR", "localhost"))
pull_and_tag(images, host=os.getenv(
"PUBLIC_SERVER_IP_ADDR", "localhost"))
# Start only registry
elif sys.argv[1] == "start_registry":
start_registry()
Expand All @@ -123,4 +126,3 @@ def pull_and_tag(images, host = "localhost"):
subprocess.run(["docker", "stop", "registry"])
elif sys.argv[1] == "stop_artipie":
subprocess.run(["docker", "stop", "artipie"])

0 comments on commit 96a3c54

Please sign in to comment.