Websocket server for Homesynck, a message synchronization system. Based on Phoenix Channels.
Table of contents
A Homesynck server instance is made of 2 parts (and 1 optional part):
Those 3 parts can be downloaded and run all in harmony using Docker containers and docker-compose.
git --version
docker ps
Got permission denied while trying to connect to the Docker daemon
you’ll need to prepend any docker
and docker-compose
command we do here with sudo
, assuming you have such permissions on your machinedocker-compose -v
1.25.0
john@doe.com
) pointing to the IP of your machineBy following those instructions you’ll get an up and running Homesynck server instance on your machine.
We won’t customize database settings and we won’t setup HTTPS during this. But you will need to do it before deploying to production by following our database management guide and our https enabling guide.
Let’s get going:
git clone https://github.com/Homesynck/Homesynck-server.git
cd homesynck-server
mix phx.gen.secret 64
if you got an existing Phoenix projectecho "SECRET_KEY_BASE=your generated key" >> docker.env
cat docker.env
does print SECRET_KEY_BASE=your generated key
docker-compose up --build -d
docker ps
docker logs homesynck-server_phoenix-server_1
http://localhost:4001
Phone validation is a spam prevention feature that can be useful for big audience apps.
If activated, a register token will be sent to a phone number validation API. This API is then meant to send the token to the phone owner through automated SMS. Then, the user would use this token to register one account. Phone numbers used to generate a register token will be on a cooldown and won’t be authorized to generate another register token for 30 days, thus preventing account creation spam.
docker-compose.yml
phoenix-server -> environment
change ENABLE_PHONE_VALIDATION
to "false"
docker-compose up --build -d
Phone validation requires hosting your own automated SMS API.
Compliant phone validation APIs must:
{
"number": "user phone number in international format",
"message": "generated register token to send through SMS",
"secret": "API key if required"
}
Check out our example APIs
In order to configure the server to use your API, do the following:
docker-compose.yml
phoenix-server -> environment
change ENABLE_PHONE_VALIDATION
to "true"
docker.env
file:
PHONE_VALIDATION_API_ENDPOINT=
put your API urlPHONE_VALIDATION_API_KEY=
put your API key as in the "secret"
field of the request’s bodydocker-compose up --build -d
docker-compose.yml
phoenix-server -> environment
change ENABLE_ADMIN_ACCOUNT
to "false"
docker-compose up --build -d
This feature creates an account for you on firststart using credentials in the server’s configuration.
Enabling it and also enabling “no register mode” can be useful to only let you use your own server, thus making it suitable for private use.
This “admin account” can also be used for tests and maintenance.
In order to enable and configure it do the following:
docker-compose.yml
phoenix-server -> environment
change ENABLE_ADMIN_ACCOUNT
to "true"
docker.env
file:
ADMIN_USERNAME=
put your admin account usernameADMIN_PASSWORD=
put your admin account passworddocker-compose up --build -d
If you change the ADMIN_USERNAME
or ADMIN_PASSWORD
later, it will take effect on server restart.
“No register mode” prevents anyone from creating an account using public WebSocket endpoints.
You can enable the “admin account” feature along with this one in order to create a unique admin account for private use.
In order to enable and configure “no register mode” do the following:
docker-compose.yml
phoenix-server -> environment
change ENABLE_REGISTER
to "false"
docker-compose up --build -d
docker-compose.yml
postgres_password
with your new passworddocker-compose up --build -d
HTTPS is mandatory since the server does not encrypt messages by default, making your synchronized data vulnerable to nowadays beginner-friendly man-in-the-middle attacks.
docker-compose.yml
yourdomain.com
with your domain nameyour@email.com
with your email (doesn’t have to be a working one, but it’s better)docker-compose up --build -d
https://yourdomain.com