Add local Docker development setup#53
Conversation
* Add docker-compose.dev.yml, which extends docker-compose.yml, builds finmars images locally instead of pulling them and enables hot reload for finmars-core, finmars-vue-portal, finmars-workflow and finmars-workflow-portal * Update README with local development instructions and created a prerequisites section that applies both to running and deploying. * Updates the NGINX configuration to proxy requests differently to Nuxt assets when running in development mode. This took the most time to figure out, as simply replacing `node run .output/server/index.mjs` with `nuxt dev` caused rather unhelpful HTTP errors due to difference in how these servers resolve paths.
|
I still found some issues related to |
| cd finmars-community-edition | ||
|
|
||
| # 4. Build and install envs, certificates, keycloak etc | ||
| make DEV=1 install |
There was a problem hiding this comment.
May be move setting DEV from CLI to ./scripts/install.sh?
There was a problem hiding this comment.
The DEV variable needs to be read by the Makefile, since it changes the COMPOSE_FILE environment variable, which in turn changes which files docker compose use.
Ideally, I'd to read whether ENVIRONMENT_TYPE=development , however, it is not straightforward to read this in make. However, that does not mean it is really hard. I just did not want to overcomplicate the Makefile. I cannot guarantee that it would work on MacOS or Windows then.
The other option would be to write a -dev target for each make target, for example make up-dev, make down-dev et cetera. However, then I will need to duplicate each rule that invokes docker compose.
Now you need to either write each time make DEV=1, or use export DEV=1 once per session in your terminal. This is simple in make, but maybe not ideal from the user experience. It seemed to me to be the least worst solution for the problem I could find.
What way would you think is the best. If you have any other ideas, they are welcome.
There was a problem hiding this comment.
THIS_MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
-include $(THIS_MAKEFILE_DIR).env
ifneq ($(filter 1 true yes y on,$(strip $(DEV))),)
COMPOSE_FILE := $(COMPOSE_FILE):docker-compose.dev.yml
endif
There was a problem hiding this comment.
I have used grep to read the variable for now. I have considered using include, however, it is quite prone to break, since it does not support variable assignments with quotes or values with #
| pull_policy: build | ||
| build: | ||
| context: ../finmars-vue-portal | ||
| dockerfile_inline: | |
There was a problem hiding this comment.
It looks like a kludge. The best way is to update the Dockerfile in the project and delete the running script from it.
There was a problem hiding this comment.
I agree. However, these Dockerfiles are different than the production Dockerfile, since they do include development dependencies and may skip the build step.
What do you think about putting a "dev.Dockerfile" in the respective repositories?
There was a problem hiding this comment.
dev.Dockerfile is good idea
/api/v1/portfolios/portfolio/ev-group/ returned `group_name` and `group_identifier` as numbers instead of strings. Other endpoints, like /api/v1/instruments/instrument/ev-group/ return strings correctly. These numerical values were then shown in the UI, as showcased in finmars-platform/finmars-core#149 (comment). By marking `portfolio_type` as a relation, it now correctly shows the names when invoking this API endpoint.
| ports: | ||
| - 5432:5432 | ||
| core: &core-base | ||
| image: ~ # Force Docker to build images locally instead of pulling them |
There was a problem hiding this comment.
Do you sure this is working properly?
The COMPOSE_FILE environment variable is used directly by docker compose, no need to pass it as the `-f` flag. Moreover, the `-f` flag doesn't handle multiple compose files separated by colons, which the COMPOSE_FILE environment variable does. The Makefile relies on multiple compose files.
2698c84 to
e7ffec5
Compare
node run .output/server/index.mjswithnuxt devcaused rather unhelpful HTTP errors due to difference in how these servers resolve paths.