-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from stakewise/feature/oracle-v2
Oracles V2
- Loading branch information
Showing
95 changed files
with
6,587 additions
and
20,311 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
/.git | ||
/.idea | ||
/.github | ||
venv | ||
/venv | ||
/dist | ||
.mypy_cache | ||
Dockerfile | ||
.dockerignore | ||
.gitignore | ||
settings.txt | ||
local.env |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
[flake8] | ||
max-line-length = 88 | ||
extend-ignore = E203,E501 | ||
exclude = .git,__pycache__,proto,venv | ||
ignore = E501, E203, W503 |
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,28 @@ | ||
name: CI | ||
|
||
on: [pull_request, push] | ||
|
||
jobs: | ||
pre-commit: | ||
name: Linting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
- uses: pre-commit/[email protected] | ||
docker: | ||
name: Build Docker Image | ||
runs-on: ubuntu-latest | ||
needs: pre-commit | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Build and push | ||
uses: docker/build-push-action@v1 | ||
with: | ||
username: _json_key | ||
password: ${{ secrets.GAR_JSON_KEY }} | ||
registry: europe-west4-docker.pkg.dev | ||
repository: stakewiselabs/public/oracle | ||
tag_with_ref: true | ||
tag_with_sha: true |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
__pycache__/ | ||
venv | ||
dist | ||
.mypy_cache | ||
.idea | ||
settings.txt | ||
local.env | ||
*.env |
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,21 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 21.12b0 | ||
hooks: | ||
- id: black | ||
|
||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 4.0.1 | ||
hooks: | ||
- id: flake8 | ||
|
||
- repo: https://github.com/timothycrosley/isort | ||
rev: 5.10.1 | ||
hooks: | ||
- id: isort | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.0.1 | ||
hooks: | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace |
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 |
---|---|---|
@@ -1,47 +1,69 @@ | ||
########### | ||
# Builder # | ||
########### | ||
FROM python:3.8.10-slim AS builder | ||
# `python-base` sets up all our shared environment variables | ||
FROM python:3.8.12-slim as python-base | ||
|
||
# This is where pip will install to | ||
ENV PYROOT /pyroot | ||
# A convenience to have console_scripts in PATH | ||
ENV PYTHONUSERBASE $PYROOT | ||
# python | ||
ENV PYTHONUNBUFFERED=1 \ | ||
# prevents python creating .pyc files | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
\ | ||
# pip | ||
PIP_NO_CACHE_DIR=off \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=on \ | ||
PIP_DEFAULT_TIMEOUT=100 \ | ||
\ | ||
# poetry | ||
# https://python-poetry.org/docs/configuration/#using-environment-variables | ||
POETRY_VERSION=1.1.10 \ | ||
# make poetry install to this location | ||
POETRY_HOME="/opt/poetry" \ | ||
# make poetry create the virtual environment in the project's root | ||
# it gets named `.venv` | ||
POETRY_VIRTUALENVS_IN_PROJECT=true \ | ||
# do not ask any interactive question | ||
POETRY_NO_INTERACTION=1 \ | ||
\ | ||
# paths | ||
# this is where our requirements + virtual environment will live | ||
PYSETUP_PATH="/opt/pysetup" \ | ||
VENV_PATH="/opt/pysetup/.venv" | ||
|
||
WORKDIR /build | ||
# prepend poetry and venv to path | ||
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH" | ||
|
||
# Setup virtualenv | ||
RUN python -m venv /opt/venv | ||
ENV PATH="/opt/venv/bin:$PATH" | ||
|
||
# Copy requirements | ||
COPY requirements/prod.txt ./ | ||
# `builder-base` stage is used to build deps + create our virtual environment | ||
FROM python-base as builder-base | ||
|
||
# Install build dependencies | ||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
gcc \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
RUN apt-get update \ | ||
&& apt-get install --no-install-recommends -y \ | ||
# deps for installing poetry | ||
curl \ | ||
# deps for building python deps | ||
build-essential | ||
|
||
# Install dependencies | ||
RUN pip install --upgrade --no-cache-dir pip wheel && \ | ||
pip install --require-hashes -r prod.txt | ||
# install poetry - respects $POETRY_VERSION & $POETRY_HOME | ||
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python - | ||
|
||
#################### | ||
# Production image # | ||
#################### | ||
FROM python:3.8.10-slim | ||
# copy project requirement files here to ensure they will be cached. | ||
WORKDIR $PYSETUP_PATH | ||
COPY poetry.lock pyproject.toml ./ | ||
|
||
# Dependencies path | ||
ENV PATH="/opt/venv/bin:$PATH" | ||
# install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally | ||
RUN poetry install --no-dev | ||
|
||
WORKDIR /app | ||
|
||
# `production` image used for runtime | ||
FROM python-base as production | ||
|
||
# Copy dependencies from build container | ||
COPY --from=builder /opt/venv /opt/venv | ||
WORKDIR /app | ||
COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH | ||
|
||
# Copy source code | ||
COPY . ./ | ||
|
||
# set env | ||
ENV PYTHONPATH="${PYTHONPATH}:/app" | ||
|
||
# Start application | ||
ENTRYPOINT ["python", "main.py"] | ||
ENTRYPOINT ["python"] |
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
Oops, something went wrong.