项目作者: DayDreamer3d

项目描述 :
python3
高级语言: Python
项目地址: git://github.com/DayDreamer3d/registry_project.git
创建时间: 2018-02-06T22:21:49Z
项目社区:https://github.com/DayDreamer3d/registry_project

开源协议:

下载


Software Registry Project

This tiny sample project act as a registry (not a real one) which displays all the tags and fetches the repositories from the backend. It has a simple api with few of endpoints which to add and get the repositories from the backend.

Installation

It is written in python and deployed using docker containers.

  1. We have to switch our docker engine to swarm mode.
  2. Download project’s compose file to deploy the stack of services.
  3. Switch to the downloaded directory and execute docker stack deploy --compose-file docker-compose.yml softreg to build the stack. This will download all the necessary images and run the desired services.

Usage

We can avail the project in two ways. First from UI (WIP) and second directly hitting the api endpoints.
Let’s look at them both.

UI

After installation, if you access <host-ip> it will bring up the ui which would be blank in the starting but would display all the saved tags. Selecting these tags and searching will display all the corresponding repositories.

Api

Api provides endpionts to GET, POST the data to server (no DELETE only constructive !) but to access any of the end points we need to obtain client-key that’s our first step.

1. Obtain the client key

Please send a POST request to <host-ip>/api/auth/client-key to obtain the client key.

Result would look like this:

2. Visit the api home page

To know about the collection of resources best way to know is to visit this page. It’s not too far and have probably the shortest url whihch is <host-ip>/api?client-key=<client-key>, it’s output would be.

  1. {
  2. "client-key-url": "/api/auth/client-key",
  3. "repos-url": "/api/repos",
  4. "tags-url": "/api/tags"
  5. }

3. Add a repository

To add new repos (with tags) we have to send a POST request to url <host-ip>/api/repos?client-key=<client-key> and a request body containing all fields like

  1. {
  2. "name": "usd_dev:v2",
  3. "description": "Second version of USD in Docker development.",
  4. "uri": "usd_dev.v2",
  5. "tags": [
  6. "docker usd"
  7. ]
  8. }

4. Fetch repositories based on tags

To get a repository from a backend we have change the request method to GET, add tags as query parameters with the same url <host-ip>/api/repos?client-key=<client-key>&tag=node%20graph%20qt&tag=%22alembic%20file%20format%22

  1. {
  2. "repo_details": [
  3. {
  4. "description": "The base of alembic caches.",
  5. "downloads": 0,
  6. "name": "alembic-base",
  7. "tags": [
  8. "\"alembic file format\"",
  9. "\"vfx pipeline\""
  10. ],
  11. "uri": "alembic-base.v1"
  12. },
  13. {
  14. "description": "Generic Qt Node editor.",
  15. "downloads": 0,
  16. "name": "nodes editor",
  17. "tags": [
  18. "node graph qt",
  19. "\"vfx pipeline\""
  20. ],
  21. "uri": "nodes_editor.v1"
  22. }
  23. ],
  24. "repo_urls": {
  25. "alembic-base": "/api/repos/alembic-base",
  26. "nodes editor": "/api/repos/nodes%20editor"
  27. }
  28. }

Remove the Project

  1. Remove the deployed stack by using docker stack rm softreg.
  2. Wait for all running containers to be removed. Use docker ps to check the running containers.
  3. Finally remove the repositories by executing docker rmi daydreamer/softreg-registry-service:v1 daydreamer/softreg-app:v1 daydreamer/softreg-nginx:v1 redis:latest rabbitmq:3-management mysql:latest nginx:latest python:3.

Please don’t hesitate in raising an issue and have fun !