diff --git a/.gitignore b/.gitignore index 338786e21..63b567b90 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ mealie/temp/* mealie/temp/api.html .temp/ +# ignore frontend build artefacts +frontend/dist app_data/backups/* app_data/debug/* diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..ea23648fa --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +all: build backend +setup: setup-backend setup-frontend +build: setup build-frontend +backend: uvicorn +frontend: vue + +setup-backend: + poetry install + +setup-frontend: + cd frontend && npm install + +build-frontend: + cd frontend && npm run build + +uvicorn: + poetry run uvicorn mealie.app:app --host 0.0.0.0 --port 9000 + +mealie.app: + poetry run python mealie/app.py + +vue: + cd frontend && npm run serve + +mdocs: + cd docs && poetry run mkdocs serve + +docker-dev: + docker-compose -f docker-compose.dev.yml -p dev-mealie up --build + +docker-prod: + docker-compose -p mealie up --build -d diff --git a/docs/docs/contributors/developers-guide/starting-dev-server.md b/docs/docs/contributors/developers-guide/starting-dev-server.md index 2ec547e57..76341c01d 100644 --- a/docs/docs/contributors/developers-guide/starting-dev-server.md +++ b/docs/docs/contributors/developers-guide/starting-dev-server.md @@ -17,15 +17,48 @@ Prerequisites - Poetry - Nodejs - npm +- Caddy -Once the prerequisites are installed you can cd into the project base directory and run `make setup` to install the python and node dependencies. Once that is complete you can run `make backend` and `make vue` to start the backend and frontend servers. +Once the prerequisites are installed you can cd into the project base directory and run `make build` to install the python and node dependencies and build the frontend webroot.You will need to configure Caddy to serve the webroot and proxy the api & mdocs. Something along these lines would be a good starting point for `/etc/caddy/Caddyfile`: +``` +{ + auto_https off + admin off +} -## Make File Reference +:80 { + @proxied path /api/* /docs /openapi.json + + root * /path/to/mealie.git/frontend/dist + encode gzip + uri strip_suffix / + + handle @proxied { + reverse_proxy http://127.0.0.1:9000 + } + + handle { + try_files {path}.html {path} / + file_server + } + +} +``` + +## Makefile Reference + +### Prod environment +`make build` installs dependencies and builds the frontend ready for prod use + +`make backend` Starts the backend server on port `9000` via uvicorn + + +### Dev environment `make setup` installs python and node dependencies -`make backend` Starts the backend server on port `9000` +`make frontend` Starts the frontend server on port `8080` via npm serve -`make vue` Starts the frontend server on port `8080` +`make mealie.app` Starts the backend server on port `9000` directly from `mealie/app.py` `make mdocs` Starts the documentation server on port `8000` @@ -46,4 +79,4 @@ Once the prerequisites are installed you can cd into the project base directory **Solution:** Create an empty /mealie/dist directory. This directory is served as static content by FastAPI. It is provided during the build process and may be missing in development. -Run into another issue? [Ask for help on discord](https://discord.gg/R6QDyJgbD2) \ No newline at end of file +Run into another issue? [Ask for help on discord](https://discord.gg/R6QDyJgbD2) diff --git a/makefile b/makefile deleted file mode 100644 index c4c75b277..000000000 --- a/makefile +++ /dev/null @@ -1,24 +0,0 @@ -setup: - poetry install && \ - cd frontend && \ - npm install && \ - cd .. - -backend: - source ./.venv/bin/activate && python mealie/app.py - -vue: - cd frontend && npm run serve - -mdocs: - source ./.venv/bin/activate && \ - cd docs && \ - mkdocs serve - -docker-dev: - docker-compose -f docker-compose.dev.yml -p dev-mealie up --build - -docker-prod: - docker-compose -p mealie up --build -d - - \ No newline at end of file