Frontend development
This documentation describe how to configure then start caliopen using docker.
Initialize
cd devtools
./init.sh
Start and stop Caliopen
Start latest release of Caliopen
./start.sh
Then open http://localhost:4000/
Start Caliopen and live build frontend
Probably the most used command for frontend development
./start.sh -d frontend
# watch the status of the build:
docker-compose logs -f --tail=100 frontend_dev
Then start hack into src/frontend/web_application/
.
Then open or refresh http://localhost:4000/.
Stop Caliopen
./stop.sh
Cleanup Caliopen data and containers
./clean-dev-storage.sh
Archives
The rest of this documentation describes how to start the backend in docker container and the frontend in a native way.
Setup the docker_compose stack
you need to have docker and docker compose installed on your machine.
Services available in the docker compose stack are:
- redis
- elasticsearch
- cassandra
- object store (minio for now)
- caliopen's api (api)
- caliopen's frontend (frontend)
- caliopen's lmtp service (broker)
You can start storage services using these commands:
cd devtools
docker-compose pull
docker-compose up -d redis cassandra elasticsearch
(wait few seconds for cassandra to warm-up)
Using caliopen cli tool:
- You must setup storage and some basic configuration (TTL for notifications):
cd devtools
docker-compose run cli setup
- You should create an admin user with the same username as in
configs/caliopen-go-api_dev.yaml
docker-compose run cli create_user -e admin -p 123456
- Then, you could create an user and import email
docker-compose run cli create_user -e dev -p 123456
docker-compose run cli import -e dev@caliopen.local -f mbox -p devtools/fixtures/mbox/dev@caliopen.local
NB : data are persisted after containers are stopped, even after being destroyed.
Finally start the stack
docker-compose up -d frontend lmtpd apiv2 apiv1
NB : for now, outgoing emails are caught by a local smtp server for testing purpose.
You will have a Caliopen instance filled with data, accessible from your browser on localhost:4000. You could check outgoing emails by pointing your browser at localhost:8888.
Remote identities poller and workers
To automatically fetch emails from remote IMAP accounts you need to :
- launch identityworker
- create a remote identity for user dev
- launch identitypoller
1. launch imap_worker
docker-compose up -d identity_worker
2. create a remote identity for user dev:
- Create at least one remote identity for user dev. Enter email account (-l), password (-p), server address (-s) and username for _dev account (-u) :
docker-compose run --no-deps --entrypoint imapctl identity_worker addremote -l 'your_email@gmail.com' -p 'your_secret_password' -s 'imap.gmail.com:993' -u 'dev'
3. launch ids_poller
docker-compose up -d identity_poller
ids_poller will retrieve remote identities from cassandra and schedule fetching jobs accordingly on a regularly basis. You can add more remote identities later, they will be retrieve by ids_poller as well.
Start frontend natively
Requirements:
- You need node v8 or later
- You need yarn to manage dependencies.
- Enventually stop the frontend container
docker-compose stop frontend
Then develop locally using your normal practices:
cd src/frontend/web_application
yarn install
npm start
It's a bit long to compile. The first time you will see some errors about a missing file, it will be fixed at the end of the compilation.
Rebuild a container
In case the image of a service (api or apiv1 ...) is not up-to-date, you mmight need to rebuild a container.
Replace "api" by the service you want to rebuild
docker-compose build api
docker-compose stop api
docker-compose up -d api
Fresh install
To reset containers and data:
docker-compose stop
# remove containers :
docker-compose rm
# remove volumes created by containers :
docker volume rm devtools_db devtools_index devtools_store
Troubleshoutings
elasticsearch won't start:
According to this issue, you might solve it with this command on the host:
sysctl -w vm.max_map_count=262144
# make it permanent:
echo "vm.max_map_count = 262144" > sudo tee /etc/sysctl.d/vm.caliopen.conf
frontend does not build
The following error may appears:
Module build failed: Error: ENOENT: no such file or directory, scandir '/.../CaliOpen/Caliopen/src/frontend/web_application/node_modules/node-sass/vendor
It is related to
node-sass
installation. To fix the easiest way is to remove node_modules
then reinstall
with yarn:
(cd src/frontend/web_application/ && rm -r node_modules && yarn)
or rebuild node-sass:
npm rebuild node-sass
docker container can't build or start
The following error can appear when docker is not run as root:
Building api ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
It is mostly due to minio server which updates its config file without asking.
You need to change the owner of the file (please don't commit) until we find a solution.
sudo chown $USER: src/backend/configs/minio/config.json
As described here, the config is automatically migrated and we can't use environment variables yet.