BTHLABS-49: WIP
This commit is contained in:
parent
d909391ee6
commit
0072dfd95d
51
README.md
51
README.md
|
@ -1,3 +1,54 @@
|
||||||
# HotPocket by BTHLabs
|
# HotPocket by BTHLabs
|
||||||
|
|
||||||
This repository contains the _HotPocket_ project.
|
This repository contains the _HotPocket_ project.
|
||||||
|
|
||||||
|
## Development setup
|
||||||
|
|
||||||
|
### Requirements:
|
||||||
|
|
||||||
|
* Python 3.12,
|
||||||
|
* Poetry 1.8.3,
|
||||||
|
* `git-crypt`,
|
||||||
|
* Docker with Docker Compose and Buildx.
|
||||||
|
|
||||||
|
### Setup
|
||||||
|
|
||||||
|
1. `$ git-crypt unlock KEYFILE`
|
||||||
|
1. `$ poetry install`
|
||||||
|
1. `$ docker buildx bake`
|
||||||
|
1. `$ poetry run inv setup`
|
||||||
|
|
||||||
|
### Running local development stack
|
||||||
|
|
||||||
|
1. `$ docker compose up`
|
||||||
|
|
||||||
|
**Exported services:**
|
||||||
|
|
||||||
|
* The app: https://app.hotpocket.work.bthlabs.net:8000/
|
||||||
|
* The admin: https://app.hotpocket.work.bthlabs.net:8000/
|
||||||
|
* Keycloak: https://auth.hotpocket.work.bthlabs.net:8443/
|
||||||
|
* Postgres: postgres://postgres.hotpocket.work.bthlabs.net:5432/
|
||||||
|
* RabbitMQ: amqp://rabbitmq.hotpocket.work.bthlabs.net:5672/
|
||||||
|
* RabbitMQ Management: amqp://rabbitmq.hotpocket.work.bthlabs.net:15672/
|
||||||
|
|
||||||
|
**Default credentials:**
|
||||||
|
|
||||||
|
The default credentials across most of the services are:
|
||||||
|
`hotpocket:hotpocketm4st3r`. This applies to the initial app and admin account,
|
||||||
|
Keycloak master realm, Postgres and RabbitMQ.
|
||||||
|
|
||||||
|
The Keycloak `hotpocket-development` realm user's credentials are:
|
||||||
|
`hotpocket@bthlabs.net:hotpocketm4st3r`. You can use these to log in to the app
|
||||||
|
and admin using OIDC.
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
_HotPocket_ is developed by [BTHLabs](https://www.bthlabs.pl/).
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
_HotPocket_ is licensed under the Apache 2.0 License.
|
||||||
|
|
15
poetry.lock
generated
15
poetry.lock
generated
|
@ -1,5 +1,18 @@
|
||||||
# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.
|
# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hotpocket-workspace-tools"
|
||||||
|
version = "1.0.0.dev0"
|
||||||
|
description = "HotPocket Workspace Tools"
|
||||||
|
optional = false
|
||||||
|
python-versions = "^3.12"
|
||||||
|
files = []
|
||||||
|
develop = true
|
||||||
|
|
||||||
|
[package.source]
|
||||||
|
type = "directory"
|
||||||
|
url = "services/packages/workspace_tools"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "invoke"
|
name = "invoke"
|
||||||
version = "2.2.0"
|
version = "2.2.0"
|
||||||
|
@ -14,4 +27,4 @@ files = [
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.12"
|
python-versions = "^3.12"
|
||||||
content-hash = "f82ba2e109e4c2d37ddfb64b80fa2ac34947f6c98133ce09f8c61cdd00cd930a"
|
content-hash = "ec33c3b3ec0f988e333872bdd134c1adce0782e98512dd2484cb85009b3da6cb"
|
||||||
|
|
|
@ -8,6 +8,7 @@ package-mode = false
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.12"
|
python = "^3.12"
|
||||||
|
hotpocket-workspace-tools = {path = "services/packages/workspace_tools", develop = true}
|
||||||
invoke = "2.2.0"
|
invoke = "2.2.0"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
|
|
|
@ -23,6 +23,6 @@ CELERY_BEAT_SCHEDULE_FILENAME = 'run/celerybeat-schedule-docker'
|
||||||
UPLOADS_PATH = Path(
|
UPLOADS_PATH = Path(
|
||||||
os.environ.get(
|
os.environ.get(
|
||||||
'HOTPOCKET_BACKEND_UPLOADS_PATH',
|
'HOTPOCKET_BACKEND_UPLOADS_PATH',
|
||||||
'/srv/run/uploads',
|
'/srv/app/run/uploads',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
15
services/backend/poetry.lock
generated
15
services/backend/poetry.lock
generated
|
@ -855,6 +855,19 @@ python-dateutil = "2.9.0.post0"
|
||||||
type = "directory"
|
type = "directory"
|
||||||
url = "../packages/testing"
|
url = "../packages/testing"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hotpocket-workspace-tools"
|
||||||
|
version = "1.0.0.dev0"
|
||||||
|
description = "HotPocket Workspace Tools"
|
||||||
|
optional = false
|
||||||
|
python-versions = "^3.12"
|
||||||
|
files = []
|
||||||
|
develop = true
|
||||||
|
|
||||||
|
[package.source]
|
||||||
|
type = "directory"
|
||||||
|
url = "../packages/workspace_tools"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hvac"
|
name = "hvac"
|
||||||
version = "2.3.0"
|
version = "2.3.0"
|
||||||
|
@ -2274,4 +2287,4 @@ brotli = ["brotli"]
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.12"
|
python-versions = "^3.12"
|
||||||
content-hash = "777763feee98b9615a284910e9fddc9477ab4bbe42f6766cb570319319b8c488"
|
content-hash = "3d8cf7ddb06917472eed4724058178f36c17f40db891a19d13f5d0d758e61102"
|
||||||
|
|
|
@ -33,6 +33,7 @@ flake8-commas = "4.0.0"
|
||||||
freezegun = "1.5.2"
|
freezegun = "1.5.2"
|
||||||
hotpocket-backend-testing = {path = "testing", develop = true}
|
hotpocket-backend-testing = {path = "testing", develop = true}
|
||||||
hotpocket-testing = {path = "../packages/testing", develop = true}
|
hotpocket-testing = {path = "../packages/testing", develop = true}
|
||||||
|
hotpocket-workspace-tools = {path = "../packages/workspace_tools", develop = true}
|
||||||
invoke = "2.2.0"
|
invoke = "2.2.0"
|
||||||
ipdb = "0.13.13"
|
ipdb = "0.13.13"
|
||||||
ipython = "9.3.0"
|
ipython = "9.3.0"
|
||||||
|
|
|
@ -9,6 +9,9 @@ import os
|
||||||
from invoke import task
|
from invoke import task
|
||||||
from invoke.exceptions import UnexpectedExit
|
from invoke.exceptions import UnexpectedExit
|
||||||
|
|
||||||
|
from hotpocket_workspace_tools import get_workspace_mode
|
||||||
|
|
||||||
|
WORKSPACE_MODE = get_workspace_mode()
|
||||||
ENV = os.getenv('HOTPOCKET_BACKEND_ENV', 'docker')
|
ENV = os.getenv('HOTPOCKET_BACKEND_ENV', 'docker')
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,11 +108,10 @@ def ci(ctx):
|
||||||
@task
|
@task
|
||||||
def setup(ctx):
|
def setup(ctx):
|
||||||
ctx.run('python manage.py migrate')
|
ctx.run('python manage.py migrate')
|
||||||
ctx.run('python manage.py migrate', env=dict(
|
ctx.run('python manage.py create_initial_account hotpocket hotpocketm4st3r')
|
||||||
DJANGO_SETTINGS_MODULE=f'hotpocket_backend.settings.{ENV}.admin',
|
|
||||||
HOTPOCKET_BACKEND_APP='admin',
|
if WORKSPACE_MODE == WORKSPACE_MODE.METAL:
|
||||||
))
|
ctx.run('mkdir -p run/uploads')
|
||||||
ctx.run('mkdir -p run/uploads')
|
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
|
|
15
services/packages/poetry.lock
generated
15
services/packages/poetry.lock
generated
|
@ -221,6 +221,19 @@ python-dateutil = "2.9.0.post0"
|
||||||
type = "directory"
|
type = "directory"
|
||||||
url = "testing"
|
url = "testing"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hotpocket-workspace-tools"
|
||||||
|
version = "1.0.0.dev0"
|
||||||
|
description = "HotPocket Workspace Tools"
|
||||||
|
optional = false
|
||||||
|
python-versions = "^3.12"
|
||||||
|
files = []
|
||||||
|
develop = true
|
||||||
|
|
||||||
|
[package.source]
|
||||||
|
type = "directory"
|
||||||
|
url = "workspace_tools"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iniconfig"
|
name = "iniconfig"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
|
@ -889,4 +902,4 @@ files = [
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.12"
|
python-versions = "^3.12"
|
||||||
content-hash = "cb0ccd3db8ca24c4b439c880dbb6012bc7d9104fb59b45b9dd4738b8e975f1a8"
|
content-hash = "02c9f754b0dbe7e7b2f24d576f294be52027f4267b9a8ea3ac316f2eba1b881b"
|
||||||
|
|
|
@ -12,6 +12,7 @@ python = "^3.12"
|
||||||
hotpocket-common = {path = "common", develop = true}
|
hotpocket-common = {path = "common", develop = true}
|
||||||
hotpocket-soa = {path = "soa", develop = true}
|
hotpocket-soa = {path = "soa", develop = true}
|
||||||
hotpocket-testing = {path = "testing", develop = true}
|
hotpocket-testing = {path = "testing", develop = true}
|
||||||
|
hotpocket-workspace-tools = {path = "workspace_tools", develop = true}
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
factory-boy = "3.3.3"
|
factory-boy = "3.3.3"
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from invoke import task
|
from invoke import task
|
||||||
from invoke.exceptions import UnexpectedExit
|
from invoke.exceptions import UnexpectedExit
|
||||||
|
|
||||||
ENV = os.getenv('HOTPOCKET_COMMON_ENV', 'docker')
|
from hotpocket_workspace_tools import get_workspace_mode
|
||||||
|
|
||||||
|
WORKSPACE_MODE = get_workspace_mode()
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
|
@ -89,7 +89,7 @@ def ci(ctx):
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def setup(ctx):
|
def setup(ctx):
|
||||||
raise NotImplementedError()
|
print('NOOP')
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
|
|
3
services/packages/workspace_tools/README.md
Normal file
3
services/packages/workspace_tools/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# HotPocket by BTHLabs
|
||||||
|
|
||||||
|
This repository contains the _HotPocket Workspace Tools_ project.
|
|
@ -0,0 +1,2 @@
|
||||||
|
from .constants import WorkspaceMode # noqa: F401
|
||||||
|
from .workspace_mode import get_workspace_mode # noqa: F401
|
|
@ -0,0 +1,11 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import enum
|
||||||
|
|
||||||
|
DEFAULT_WORKSPACE_MODE = 'docker'
|
||||||
|
|
||||||
|
|
||||||
|
class WorkspaceMode(enum.Enum):
|
||||||
|
DOCKER = 'docker'
|
||||||
|
METAL = 'metal'
|
|
@ -0,0 +1,17 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from .constants import DEFAULT_WORKSPACE_MODE, WorkspaceMode
|
||||||
|
|
||||||
|
|
||||||
|
def get_workspace_mode(default: str | None = None) -> WorkspaceMode:
|
||||||
|
return WorkspaceMode(os.getenv(
|
||||||
|
'HOTPOCKET_WORKSPACE_MODE',
|
||||||
|
(
|
||||||
|
default
|
||||||
|
if default is not None
|
||||||
|
else DEFAULT_WORKSPACE_MODE
|
||||||
|
),
|
||||||
|
))
|
14
services/packages/workspace_tools/pyproject.toml
Normal file
14
services/packages/workspace_tools/pyproject.toml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
[tool.poetry]
|
||||||
|
name = "hotpocket-workspace-tools"
|
||||||
|
version = "1.0.0.dev0"
|
||||||
|
description = "HotPocket Workspace Tools"
|
||||||
|
authors = ["Tomek Wójcik <contact@bthlabs.pl>"]
|
||||||
|
license = "BTHLabs Source Available License Agreement"
|
||||||
|
readme = "README.md"
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = "^3.12"
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
13
tasks.py
13
tasks.py
|
@ -2,15 +2,10 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import enum
|
|
||||||
import os
|
|
||||||
|
|
||||||
from invoke import task
|
from invoke import task
|
||||||
|
|
||||||
|
from hotpocket_workspace_tools import get_workspace_mode, WorkspaceMode
|
||||||
class WorkspaceMode(enum.Enum):
|
|
||||||
DOCKER = 'docker'
|
|
||||||
METAL = 'metal'
|
|
||||||
|
|
||||||
|
|
||||||
class DockerBuildContext:
|
class DockerBuildContext:
|
||||||
|
@ -63,16 +58,16 @@ class DockerBuildContext:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
WORKSPACE_MODE = WorkspaceMode(os.getenv('HOTPOCKET_WORKSPACE_MODE', 'docker'))
|
WORKSPACE_MODE = get_workspace_mode()
|
||||||
|
|
||||||
ALL_SERVICES = ['backend']
|
ALL_SERVICES = ['backend', 'packages']
|
||||||
|
|
||||||
|
|
||||||
def _run_in_service(ctx, service, command, **kwargs):
|
def _run_in_service(ctx, service, command, **kwargs):
|
||||||
match WORKSPACE_MODE:
|
match WORKSPACE_MODE:
|
||||||
case WorkspaceMode.DOCKER:
|
case WorkspaceMode.DOCKER:
|
||||||
return ctx.run(
|
return ctx.run(
|
||||||
f'docker compose run --rm -it {service}-ops {command}',
|
f'docker compose run --rm -it {service}-management {command}',
|
||||||
)
|
)
|
||||||
|
|
||||||
case WorkspaceMode.METAL:
|
case WorkspaceMode.METAL:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user