Skip to content

Commit

Permalink
Implement oracles v2
Browse files Browse the repository at this point in the history
  • Loading branch information
tsudmi committed Nov 25, 2021
1 parent 8ce57ad commit 50b03e3
Show file tree
Hide file tree
Showing 75 changed files with 4,511 additions and 20,265 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ venv
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
26 changes: 0 additions & 26 deletions .github/workflows/ci.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Code Quality

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]
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ __pycache__/
venv
.mypy_cache
.idea
settings.txt
local.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.9b0
hooks:
- id: black

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8

- repo: https://github.com/timothycrosley/isort
rev: 5.9.3
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
79 changes: 49 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,63 @@
###########
# Builder #
###########
FROM python:3.8.10-slim AS builder
# `python-base` sets up all our shared environment variables
FROM python:3.8.11-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.8 \
# 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 . ./
Expand Down
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 50b03e3

Please sign in to comment.