Added honcho and frontend assets watching. Also added inv start.

This commit is contained in:
Victoria Chan 2023-06-12 12:28:37 +01:00
Родитель afc46f1471
Коммит 152c53d499
5 изменённых файлов: 21 добавлений и 5 удалений

2
Procfile.dev Normal file
Просмотреть файл

@ -0,0 +1,2 @@
web: /app/dockerpythonvenv/bin/python network-api/manage.py runserver 0.0.0.0:8000
frontend: npm run watch

Просмотреть файл

@ -10,6 +10,7 @@ mypy
ptvsd
types-python-slugify
types-requests
honcho
pytest
pytest-django

Просмотреть файл

@ -64,6 +64,8 @@ execnet==1.9.0
# via pytest-xdist
flake8==3.9.2
# via -r dev-requirements.in
honcho==1.1.0
# via -r dev-requirements.in
html-tag-names==0.1.2
# via djlint
html-void-elements==0.1.0

Просмотреть файл

@ -14,7 +14,9 @@ services:
- CHOKIDAR_INTERVAL=2000
env_file:
- ".env"
command: /app/dockerpythonvenv/bin/python network-api/manage.py runserver 0.0.0.0:8000
# The honcho command is defined in the Procfile.dev file
# This command starts the Django server and the frontend build process
command: honcho -f Procfile.dev start
ports:
- "8000:8000"
- "8001:8001" # ptvsd port for debugging
@ -26,10 +28,12 @@ services:
- ./network-api:/app/network-api:rw
- ./.env:/app/.env:rw
- ./tests:/app/tests:rw
- ./Procfile.dev:/app/Procfile.dev:rw
- ./pyproject.toml:/app/pyproject.toml:rw
- ./release-steps.sh:/app/release-steps.sh:rw
- ./requirements.txt:/app/requirements.txt:rw
- ./requirements.in:/app/requirements.in:rw
- ./dev-requirements.txt:/app/dev-requirements.txt:rw
- ./dev-requirements.in:/app/dev-requirements.in:rw
# Frontend config
- ./source:/app/source:rw

Просмотреть файл

@ -168,7 +168,14 @@ def setup(ctx):
print("* Building Docker images")
ctx.run("docker-compose build")
initialize_database(ctx)
print("\n* Start your dev server with:\n docker-compose up")
print("\n* Start your dev server with:\n inv start or docker-compose up")
@task(aliases=["start", "docker-start"])
def startdev(ctx):
"""Start the dev server"""
with ctx.cd(ROOT):
ctx.run("docker-compose up")
# Javascript shorthands
@ -176,14 +183,14 @@ def setup(ctx):
def npm(ctx, command):
"""Shorthand to npm. inv docker-npm \"[COMMAND] [ARG]\" """
with ctx.cd(ROOT):
ctx.run(f"docker-compose run --rm watch-static-files npm {command}")
ctx.run(f"docker-compose run --rm backend npm {command}")
@task(aliases=["docker-npm-install"])
def npm_install(ctx):
"""Install Node dependencies"""
with ctx.cd(ROOT):
ctx.run("docker-compose run --rm watch-static-files npm ci")
ctx.run("docker-compose run --rm backend npm ci")
@task(aliases=["copy-stage-db"])