dify icon indicating copy to clipboard operation
dify copied to clipboard

feat: add start commands to devcontainer

Open perzeuss opened this issue 10 months ago • 3 comments

Description

I work with the dify repo every week and every time I forget the whole command to start the api or the worker. I added these commands because they are intuitive and easy to remember.

This change just introduces shortcut commands to run services, which are made available via alias in the devcontainer:

  • start-api: starts the flask app in debug mode
  • start-worker: starts the worker
  • start-web: starts the nextjs web app in dev mode
  • start-containers: runs docker compose for the middleware compose file to start containers like dbs and sandbox

Type of Change

  • [x] Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement

How Has This Been Tested?

  • [ ] Open the dify workspace in a devcontainer
  • [ ] Run the VS Code script "Rebuild Container"
  • [ ] Watch the logs, after the container is created, it should run an npm install for web (as it did before)
  • [ ] After the container has been created, it should run pip install for api (as it did before)
  • [ ] run start-containers (just type it in the terminal and press enter)
    • [ ] this should run docker compose to run required containers for local development
  • [ ] run start-api
    • [ ] this should start the dify api
  • [ ] run start-worker
    • [ ] this should start the the dify worker
  • [ ] run start-web
    • [ ] this should start the dify web
  • [ ] open ~/.bashrc you should see 4 commands defined at the end of the file
  • [ ] close vs code and reopen it
  • [ ] the devcontainer should run pip install but should not create the aliases again
  • [ ] open ~/.bashrc again
  • [ ] it should still contain only the 4 commands once

Suggested Checklist:

  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [ ] My changes generate no new warnings
  • [ ] I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
  • [ ] optional I have made corresponding changes to the documentation
  • [ ] optional I have added tests that prove my fix is effective or that my feature works
  • [ ] optional New and existing unit tests pass locally with my changes

perzeuss avatar Apr 26 '24 12:04 perzeuss

I did not add docs because I don't want to confuse people with these commands, but maybe you have an idea where to add a hint that these commands exist?

perzeuss avatar Apr 26 '24 12:04 perzeuss

To not change existing behaviour, I did place cd api && pip install -r requirements.txt in the post start command. However it might make sense to place it in the post create command too. Maybe it was just in postStartCommand field before, because devcontainer config file supports only one command in the postCreateCommand field?

perzeuss avatar Apr 26 '24 12:04 perzeuss

I think you need to fix the ci builds. I think it's ok to left the docs blank for this pr.

crazywoola avatar Apr 26 '24 12:04 crazywoola