Docker + docker compose support
This commit is contained in:
parent
3e7ad917e2
commit
fe88481431
10 changed files with 141 additions and 29 deletions
47
tasks.py
47
tasks.py
|
@ -1,7 +1,10 @@
|
|||
import asyncio
|
||||
import io
|
||||
import subprocess
|
||||
import tarfile
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from typing import Generator
|
||||
from typing import Optional
|
||||
|
||||
import httpx
|
||||
|
@ -13,13 +16,13 @@ from invoke import task # type: ignore
|
|||
@task
|
||||
def generate_db_migration(ctx, message):
|
||||
# type: (Context, str) -> None
|
||||
run(f'poetry run alembic revision --autogenerate -m "{message}"', echo=True)
|
||||
run(f'alembic revision --autogenerate -m "{message}"', echo=True)
|
||||
|
||||
|
||||
@task
|
||||
def migrate_db(ctx):
|
||||
# type: (Context) -> None
|
||||
run("poetry run alembic upgrade head", echo=True)
|
||||
run("alembic upgrade head", echo=True)
|
||||
|
||||
|
||||
@task
|
||||
|
@ -46,15 +49,15 @@ def compile_scss(ctx, watch=False):
|
|||
theme_file.write_text("// override vars for theming here")
|
||||
|
||||
if watch:
|
||||
run("poetry run boussole watch", echo=True)
|
||||
run("boussole watch", echo=True)
|
||||
else:
|
||||
run("poetry run boussole compile", echo=True)
|
||||
run("boussole compile", echo=True)
|
||||
|
||||
|
||||
@task
|
||||
def uvicorn(ctx):
|
||||
# type: (Context) -> None
|
||||
run("poetry run uvicorn app.main:app --no-server-header", pty=True, echo=True)
|
||||
run("uvicorn app.main:app --no-server-header", pty=True, echo=True)
|
||||
|
||||
|
||||
@task
|
||||
|
@ -96,16 +99,11 @@ def generate_requirements_txt(ctx, where="requirements.txt"):
|
|||
)
|
||||
|
||||
|
||||
@task(generate_requirements_txt)
|
||||
def build_configuration_wizard_image(ctx):
|
||||
# type: (Context) -> None
|
||||
run("docker build -t testmpw -f configuration_wizard.dockerfile .")
|
||||
|
||||
|
||||
@task
|
||||
def build_docs(ctx):
|
||||
# type: (Context) -> None
|
||||
run("PYTHONPATH=. poetry run python scripts/build_docs.py", pty=True, echo=True)
|
||||
with embed_version():
|
||||
run("PYTHONPATH=. python scripts/build_docs.py", pty=True, echo=True)
|
||||
|
||||
|
||||
@task
|
||||
|
@ -131,7 +129,7 @@ def download_twemoji(ctx):
|
|||
@task(download_twemoji, compile_scss, migrate_db)
|
||||
def configuration_wizard(ctx):
|
||||
# type: (Context) -> None
|
||||
run("PYTHONPATH=. poetry run python scripts/config_wizard.py", pty=True, echo=True)
|
||||
run("PYTHONPATH=. python scripts/config_wizard.py", pty=True, echo=True)
|
||||
|
||||
|
||||
@task
|
||||
|
@ -152,3 +150,26 @@ def stats(ctx):
|
|||
from app.utils.stats import print_stats
|
||||
|
||||
print_stats()
|
||||
|
||||
|
||||
@contextmanager
|
||||
def embed_version() -> Generator[None, None, None]:
|
||||
version_file = Path("app/_version.py")
|
||||
version_file.unlink(missing_ok=True)
|
||||
version = (
|
||||
subprocess.check_output(["git", "rev-parse", "--short=8", "v2"])
|
||||
.split()[0]
|
||||
.decode()
|
||||
)
|
||||
version_file.write_text(f'VERSION_COMMIT = "{version}"')
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
version_file.unlink()
|
||||
|
||||
|
||||
@task
|
||||
def build_docker_image(ctx):
|
||||
# type: (Context) -> None
|
||||
with embed_version():
|
||||
run("docker build -t microblogpub/microblogpub .")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue