Skip to content

Commit

Permalink
Merge remote-tracking branch 'proto-registry/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
shaldengeki committed Feb 26, 2024
2 parents 8b8f122 + 6daa4b7 commit f9fa63a
Show file tree
Hide file tree
Showing 30 changed files with 1,195 additions and 0 deletions.
137 changes: 137 additions & 0 deletions proto-registry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

postgres-data
env.production.real
bazel-bin
bazel-out
bazel-registry
bazel-rules
bazel-testlogs
16 changes: 16 additions & 0 deletions proto-registry/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: no-commit-to-branch
args: [--branch, staging, --branch, main]
- id: requirements-txt-fixer
- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: black
21 changes: 21 additions & 0 deletions proto-registry/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Charles OuGuo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file added proto-registry/registry/BUILD
Empty file.
15 changes: 15 additions & 0 deletions proto-registry/registry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# registry service

This is a minimal web service that registers & exposes schemas, [adhering to the Confluent Schema Registry API](https://docs.confluent.io/platform/current/schema-registry/develop/api.html#subjects). It is intended to serve as a reference implementation and is _not_ production-ready.

## Development

We support building & running via OCI-compatible container images (via Bazel) or via Docker.

### Bazel

Do `bazel build //api:image`. Run on the container runtime of your choice.

### Docker

Install docker compose on your platform, then do `docker compose --env-file env.development up`.
84 changes: 84 additions & 0 deletions proto-registry/registry/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
workspace(
name = "proto-registry-service",
)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

rules_python_version = "740825b7f74930c62f44af95c9a4c1bd428d2c53" # Latest @ 2021-06-23

http_archive(
name = "rules_python",
sha256 = "09a3c4791c61b62c2cbc5b2cbea4ccc32487b38c7a2cc8f87a794d7a659cc742",
strip_prefix = "rules_python-{}".format(rules_python_version),
url = "https://github.com/bazelbuild/rules_python/archive/{}.zip".format(rules_python_version),
)

load("@rules_python//python:pip.bzl", "pip_install")

pip_install(
name = "worker_deps",
requirements="//worker:requirements.txt"
)
pip_install(
name = "api_deps",
requirements="//api:requirements.txt"
)

http_archive(
name = "io_bazel_rules_docker",
sha256 = "59d5b42ac315e7eadffa944e86e90c2990110a1c8075f1cd145f487e999d22b3",
strip_prefix = "rules_docker-0.17.0",
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.17.0/rules_docker-v0.17.0.tar.gz"],
)

load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)
container_repositories()

load("@io_bazel_rules_docker//repositories:deps.bzl", container_deps = "deps")

container_deps()

load("@io_bazel_rules_docker//container:pull.bzl", "container_pull")

container_pull(
name = "py3_image",
registry = "index.docker.io",
repository = "library/python",
tag = "3.9-alpine",
)

register_toolchains(
"//toolchain:container_py_toolchain",
)

register_execution_platforms(
"@local_config_platform//:host",
"@io_bazel_rules_docker//platforms:local_container_platform",
)

load(
"@io_bazel_rules_docker//python3:image.bzl",
_py_image_repos = "repositories",
)

_py_image_repos()

http_archive(
name = "bazel_skylib",
sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
],
)

container_pull(
name = "nginx_image",
registry = "index.docker.io",
repository = "library/nginx",
tag = "1-alpine",
digest = "sha256:c35699d53f03ff9024ce2c8f6730567f183a15cc27b24453c5d90f0e7542daea",
)
2 changes: 2 additions & 0 deletions proto-registry/registry/api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/__pycache__
/venv
38 changes: 38 additions & 0 deletions proto-registry/registry/api/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
load("@rules_python//python:defs.bzl", "py_binary")
load("@api_deps//:requirements.bzl", "requirement")
load("@io_bazel_rules_docker//python3:image.bzl", "py3_image")

py_binary(
name = "binary",
srcs = glob(["**/*.py"]),
main = "app.py",
deps = [
requirement("Flask"),
requirement("Flask-Migrate"),
requirement("importlib-metadata"),
requirement("importlib-resources"),
requirement("typing-extensions"),
requirement("psycopg2"),
requirement("sqlalchemy"),
requirement("Flask-SQLAlchemy"),
requirement("flask-cors")
]
)

py3_image(
name = "image",
srcs = glob(["**/*.py"]),
main = "app.py",
base = "@py3_image//image",
deps = [
requirement("Flask"),
requirement("Flask-Migrate"),
requirement("importlib-metadata"),
requirement("importlib-resources"),
requirement("typing-extensions"),
requirement("psycopg2"),
requirement("sqlalchemy"),
requirement("Flask-SQLAlchemy"),
requirement("flask-cors")
]
)
22 changes: 22 additions & 0 deletions proto-registry/registry/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM python:3.9-alpine

EXPOSE 5000/tcp

RUN apk update && \
apk add --virtual build-deps gcc python3-dev musl-dev g++ && \
apk add postgresql-dev postgresql-client

WORKDIR /usr/src/app

ENV FLASK_APP=app.py
ENV API_PORT=5000
ENV FRONTEND_HOST=home_frontend
ENV FRONTEND_PORT=5001

COPY requirements.txt ./

RUN pip install --no-cache-dir -r requirements.txt

COPY . .

CMD flask run --host 0.0.0.0 --port $API_PORT
1 change: 1 addition & 0 deletions proto-registry/registry/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .config import app
Loading

0 comments on commit f9fa63a

Please sign in to comment.