Containing only database and api.
The original repo included a caddy reverse proxy which is unnecessary for a lan deployment.
xBrowserSync is a free tool for syncing browser data between different browsers and devices, built for privacy and anonymity. For full details, see www.xbrowsersync.org.
This repository contains the Docker files required to get your own xBrowserSync API service up and running in moments, either by running the API image alone or by orchestrating a production-ready HTTPS service with database and reverse proxy.
Running the API image alone requires that you have a MongoDB instance and (ideally) a web server to reverse proxy the API behind.
-
Create a file named
settings.json
and include any required custom settings values, such as those for connecting to your MongoDB instance. For example, if you are running Docker and MongoDB on a windows server, you would point the service at the MongoDB instance running on the host using the following settings:{ "db": { "host": "host.docker.internal" } }
-
(Optionally) create the following environment variables on your host to store the username and password required to access the xBrowserSync database on your MongoDB instance:
- XBROWSERSYNC_DB_USER
- XBROWSERSYNC_DB_PWD
-
Run the following command to start an API container, providing the actual path to the
settings.json
file created in step 1. The service will be exposed via port 8080. If you did not create the environment variables in step 2, you will need to provide the actual username and password values in line, i.e.-e XBROWSERSYNC_DB_USER=YourDatabaseUsername -e XBROWSERSYNC_DB_PWD=YourDatabasePassword
:docker run --name xbs-api -p 8080:8080 -e XBROWSERSYNC_DB_USER -e XBROWSERSYNC_DB_PWD -v /path/to/settings.json:/usr/src/api/config/settings.json -d xbrowsersync/api
You can now access your xBrowserSync API service at http://127.0.0.1:8080.
If you do not already have a MongoDB instance or are intending to expose your xBrowserSync service over the internet then it is recommended to use the provided docker-compose.yml
which will create fully configured containers for a MongoDB database, the xBrowserSync API and a Caddy web server as a reverse proxy in front of the API. Caddy automatically acquires and updates SSL certificates so that your xBrowserSync API service will run securely over HTTPS.
-
Clone the api-docker GitHub repo:
git clone https://github.com/xbrowsersync/api-docker.git
-
Open the
.env
file in a text editor and update theAPI_HOSTNAME
value to correspond to the host name that the API service will be exposed over (ensure you have configured your DNS provider to point the desired host name to your host's IP address). Also, change theDB_USERNAME
andDB_PASSWORD
values to any of your choosing. -
(Optionally) open the
settings.json
file and include any custom settings values you wish to run on your service. Important: do not change thedb.host
value. -
Run the following command to start the containers:
docker-compose up -d
You can now access your xBrowserSync API service over HTTPS at the value of
API_HOSTNAME
defined in the.env
file.
If you wish to upgrade your existing production-ready service created using the docker-compose.yml
file, you may encounter database errors when upgrading the MongoDB version. To avoid these issues, it is recommended that you export the db data from the old version and restore to the new version once up and running.
The following steps detail the process in full:
-
Connect to the MongoDB container:
docker exec -it xbs-db bash
-
Export db data to the
xbs-db-backups
Docker volume using mongodump:mongodump --db $XBS_DB_NAME --host localhost --port 27017 --username $XBS_DB_USERNAME --password $XBS_DB_PASSWORD --authenticationDatabase admin --archive=/data/backups/xbs-db-`date +"%Y-%m-%d"`.gz --gzip
-
Exit the MongoDB container and navigate to the api-docker GitHub repo folder. Stop and remove all containers:
docker-compose down
-
Delete the
xbs-db-data
Docker volume before upgrading MongoDB. You need to find the volume name first using:docker volume ls
It will be something like
api-docker_xbs-db-data
. Once located, delete it with:docker volume rm api-docker_xbs-db-data
-
Get latest changes and start the containers:
git pull docker-compose up -d
-
Connect to the MongoDB container:
docker exec -it xbs-db bash
-
Restore db data from the
xbs-db-backups
Docker volume using mongorestore (replace{BackupFileName}
with the actual backup file name):mongorestore --username $XBS_DB_USERNAME --password $XBS_DB_PASSWORD --authenticationDatabase admin --verbose=5 --gzip --drop --archive=/data/backups/{BackupFileName}
Please log Docker-related issues in the api-docker Issues list, if you have found an issue with the xBrowserSync API itself or wish to request a new feature, do so in the api Issues list.