Skip to content

Commit

Permalink
Merge pull request #24 from stakewise/feature/oracle-v2
Browse files Browse the repository at this point in the history
Oracles V2
  • Loading branch information
tsudmi authored Dec 17, 2021
2 parents 8ce57ad + e31a633 commit 1cfb7c0
Show file tree
Hide file tree
Showing 95 changed files with 6,587 additions and 20,311 deletions.
5 changes: 3 additions & 2 deletions .dockerignore
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
3 changes: 1 addition & 2 deletions .flake8
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
28 changes: 28 additions & 0 deletions .github/workflows/ci.yaml
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
26 changes: 0 additions & 26 deletions .github/workflows/ci.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
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
7 changes: 0 additions & 7 deletions .mypy.ini

This file was deleted.

21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
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
84 changes: 53 additions & 31 deletions Dockerfile
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"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -662,4 +662,4 @@ specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.
6 changes: 0 additions & 6 deletions Makefile

This file was deleted.

Loading

0 comments on commit 1cfb7c0

Please sign in to comment.