-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Revert "fixed versioning and packaging, which resulted in an uninstallable/empty pandahub package" This reverts commit 1985879. * re-apply packaging fix after revert * fix .env defaults * fix docker (compose) setup * set default setting on empty env var * move test directory * persist data for mongodb service * remove outdated files * revert e84d1aa and related commits (_id handling on project activation)
- Loading branch information
Showing
21 changed files
with
94 additions
and
183 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
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,19 +1,18 @@ | ||
FROM python:3.10 as dev | ||
# dev stage | ||
FROM python:3.11 AS dev | ||
ENV PYTHONUNBUFFERED=1 | ||
ENV PATH="/opt/venv/bin:$PATH" | ||
WORKDIR /src | ||
COPY requirements.txt . | ||
RUN python -m venv /opt/venv && \ | ||
python -m pip install -r requirements.txt | ||
CMD ["python", "-m", "pandahub.api.main"] | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
ENV PYTHONPATH /code/pandahub | ||
|
||
ENV DEBUG False | ||
ENV PANDAHUB_SERVER_URL 0.0.0.0 | ||
ENV PANDAHUB_SERVER_PORT 8002 | ||
ENV WORKERS 2 | ||
|
||
COPY ./ /code/pandahub/ | ||
WORKDIR /code/pandahub | ||
|
||
RUN python -m pip install --upgrade pip | ||
RUN python -m pip install .["all"] | ||
RUN python -m pip install watchdog pyyaml | ||
|
||
# CMD uvicorn --host "0.0.0.0" --port "8002" "pandahub.api.main:app" --reload | ||
ENTRYPOINT ["python", "pandahub/api/main.py"] | ||
# production stage | ||
FROM python:3.11-slim AS production-stage | ||
ENV PATH="/opt/venv/bin:$PATH" | ||
WORKDIR /src | ||
# copy files from build stage | ||
COPY --from=dev /opt/venv /opt/venv | ||
COPY . . | ||
CMD ["uvicorn", "--host", "127.0.0.1", "--port", "8080", "pandahub.api.main:app"] |
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
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,34 +1,39 @@ | ||
version: '3' | ||
|
||
networks: | ||
test: | ||
external: false | ||
|
||
services: | ||
db: | ||
user: ${CURRENT_UID} | ||
image: mongo:latest | ||
container_name: mongodb | ||
restart: always | ||
volumes: | ||
- mongodb_pandahub:/data/db | ||
networks: | ||
- test | ||
ports: | ||
- "27017:27017" | ||
- "127.0.0.1:27017:27017" | ||
|
||
pandahub_server: | ||
user: ${CURRENT_UID} | ||
container_name: pandahub | ||
pandahub-dev: | ||
image: dev/pandahub | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
target: dev | ||
env_file: | ||
- .env | ||
environment: | ||
- SECRET=devonly! | ||
- MONGODB_URL=${MONGODB_URL:-mongodb://db:27017} | ||
- PYTHONPYCACHEPREFIX=/pycache | ||
ports: | ||
- "8002:8002" | ||
# volumes: | ||
# - ./:/code/pandahub | ||
- "127.0.0.1:8002:8002" | ||
volumes: | ||
- ./:/src/ | ||
- pycache:/pycache | ||
networks: | ||
- test | ||
depends_on: | ||
- db | ||
volumes: | ||
pycache: | ||
mongodb_pandahub: |
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
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,8 +1,13 @@ | ||
from dotenv import load_dotenv | ||
import os | ||
|
||
def get_os_env(key, default=None): | ||
value = os.getenv(key, default) | ||
value = default if value == "" else value | ||
return value | ||
|
||
def settings_bool(var_name, default=None): | ||
var = os.getenv(var_name) | ||
var = get_os_env(var_name) | ||
if var is None: | ||
return default | ||
if isinstance(var, str) and var.lower() == "true": | ||
|
@@ -12,7 +17,7 @@ def settings_bool(var_name, default=None): | |
return False | ||
|
||
def get_secret(key, default=None): | ||
secret = os.getenv(key, default) | ||
secret = get_os_env(key, default) | ||
if secret and os.path.isfile(secret): | ||
with open(secret) as f: | ||
secret = f.read() | ||
|
@@ -21,35 +26,35 @@ def get_secret(key, default=None): | |
# load variables from .env to environment variables | ||
load_dotenv() | ||
|
||
MONGODB_URL = get_secret("MONGODB_URL") or "mongodb://localhost:27017" | ||
MONGODB_USER = get_secret("MONGODB_USER") or None | ||
MONGODB_PASSWORD = get_secret("MONGODB_PASSWORD") or None | ||
MONGODB_URL = get_secret("MONGODB_URL", "mongodb://localhost:27017") | ||
MONGODB_USER = get_secret("MONGODB_USER") | ||
MONGODB_PASSWORD = get_secret("MONGODB_PASSWORD") | ||
|
||
MONGODB_GLOBAL_DATABASE_URL = get_secret("MONGODB_GLOBAL_DATABASE_URL") or None | ||
MONGODB_GLOBAL_DATABASE_USER = get_secret("MONGODB_GLOBAL_DATABASE_USER") or None | ||
MONGODB_GLOBAL_DATABASE_PASSWORD = get_secret("MONGODB_GLOBAL_DATABASE_PASSWORD") or None | ||
MONGODB_GLOBAL_DATABASE_URL = get_secret("MONGODB_GLOBAL_DATABASE_URL") | ||
MONGODB_GLOBAL_DATABASE_USER = get_secret("MONGODB_GLOBAL_DATABASE_USER") | ||
MONGODB_GLOBAL_DATABASE_PASSWORD = get_secret("MONGODB_GLOBAL_DATABASE_PASSWORD") | ||
if not MONGODB_GLOBAL_DATABASE_URL: | ||
MONGODB_GLOBAL_DATABASE_URL = os.getenv("MONGODB_URL_GLOBAL_DATABASE") or None | ||
MONGODB_GLOBAL_DATABASE_URL = get_os_env("MONGODB_URL_GLOBAL_DATABASE") | ||
|
||
EMAIL_VERIFICATION_REQUIRED = settings_bool("EMAIL_VERIFICATION_REQUIRED", default=False) | ||
|
||
MAIL_USERNAME = os.getenv("MAIL_USERNAME") or "[email protected]" | ||
MAIL_PASSWORD = os.getenv("MAIL_PASSWORD") or "" | ||
MAIL_PORT = os.getenv("MAIL_PORT") or 587 | ||
MAIL_SMTP_SERVER = os.getenv("MAIL_SMTP_SERVER") or "" | ||
MAIL_USERNAME = get_os_env("MAIL_USERNAME", "[email protected]") | ||
MAIL_PASSWORD = get_os_env("MAIL_PASSWORD", "") | ||
MAIL_PORT = get_os_env("MAIL_PORT", 587) | ||
MAIL_SMTP_SERVER = get_os_env("MAIL_SMTP_SERVER", "") | ||
MAIL_STARTTLS = settings_bool("MAIL_STARTTLS", default=True) | ||
MAIL_SSL_TLS = settings_bool("MAIL_SSL_TLS", default=False) | ||
|
||
PASSWORD_RESET_URL = os.getenv("PASSWORD_RESET_URL") or "" | ||
EMAIL_VERIFY_URL = os.getenv("EMAIL_VERIFY_URL") or "" | ||
SECRET = get_secret("SECRET") or None | ||
PASSWORD_RESET_URL = get_os_env("PASSWORD_RESET_URL", "") | ||
EMAIL_VERIFY_URL = get_os_env("EMAIL_VERIFY_URL", "") | ||
SECRET = get_secret("SECRET") | ||
|
||
REGISTRATION_ENABLED = settings_bool("REGISTRATION_ENABLED", default=True) | ||
REGISTRATION_ADMIN_APPROVAL = settings_bool("REGISTRATION_ADMIN_APPROVAL", default=False) | ||
|
||
CREATE_INDEXES_WITH_PROJECT = settings_bool("CREATE_INDEXES_WITH_PROJECT", default=True) | ||
|
||
DEBUG = settings_bool("DEBUG", default=False) | ||
PANDAHUB_SERVER_URL = os.getenv("PANDAHUB_SERVER_URL", "0.0.0.0") | ||
PANDAHUB_SERVER_PORT = int(os.getenv('PANDAHUB_SERVER_PORT', 8002)) | ||
WORKERS = int(os.getenv('WORKER', 2)) | ||
PANDAHUB_SERVER_URL = get_os_env("PANDAHUB_SERVER_URL", "0.0.0.0") | ||
PANDAHUB_SERVER_PORT = int(get_os_env('PANDAHUB_SERVER_PORT', 8002)) | ||
WORKERS = int(get_os_env('WORKER', 2)) |
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
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
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
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,13 @@ | ||
uvicorn>=0.24.0 | ||
fastapi-users[beanie]>=12.0 | ||
fastapi>=0.104.0 | ||
fastapi-mail>=1.4.1 | ||
pandapower~=2.14 | ||
pandapipes>=0.7.0 | ||
pymongo | ||
pydantic | ||
simplejson | ||
requests | ||
python-dotenv | ||
pymongoarrow | ||
blosc |
File renamed without changes.
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
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.