# Installing Databunker ## Just run as the Docker container This is the easiest method to start with Data Bunker. Always use the latest version. **For the first time**, you can fetch and start Databunker with the following command: ``` cd ~ mkdir -p data chmod 0777 data docker run -v ~/data:/databunker/data -p 3000:3000 \ --rm --name dbunker paranoidguy/databunker ``` This command will init Databunker service, init database and start container. This command will print **DATABUNKER_MASTERKEY** and **DATABUNKER_ROOTTOKEN**. You can run: ```docker logs dbunker``` to view these important variables. The database will be saved in the ~/data directory. **DATABUNKER_MASTERKEY** is used to encrypt database records. **DATABUNKER_ROOTTOKEN** is an access token to databunker API. ## Stop service To stop Databunker container you can run the following command: ``` docker kill dbunker ``` # Run it again You can run it again, after it was initalized. This time, you will have to provide the **DATABUNKER_MASTERKEY** environment variable. Use the following command: ``` docker run -p 3000:3000 -v ~/data:/databunker/data \ -e "DATABUNKER_MASTERKEY=**DATABUNKER_MASTERKEY**" \ --rm --name dbunker paranoidguy/databunker ``` # Custom configuration Databunker has a configuration file that you can alter to enable custom email gateway, notification urls, twilio account (sms gateway), user serf-service behaviour, etc... There are number of ways you can change configuration file in container, for example by creating your own Docker file. Another option is to create this file outside of container in conf/ directory and mount this directory in container. ### You can do it as following: 1. Download default configuration file and place it in ~/conf/ directory. ``` mkdir ~/conf curl https://raw.githubusercontent.com/paranoidguy/databunker/master/databunker.yaml \ -o ~/conf/databunker.yaml ``` 2. After that you can alter the configuration file with your editor: **~/conf/databunker.yaml** 3. Run container and mount ~/conf/ directory: ``` docker run -p 3000:3000 -v ~/data:/databunker/data -v ~/conf:/databunker/conf \ -e "DATABUNKER_MASTERKEY=**DATABUNKER_MASTERKEY**" \ --restart unless-stopped --name dbunker paranoidguy/databunker ``` # SSL certificates You can generate SSL certificates and place them in the /databunker/certs directory in the running container. For example you can do this by mounting **/databunker/certs** to a local **~/certs/** directory as: ``` cd ~ mkdir -p certs # generate certificates, check bellow docker run -p 3000:3000 -v ~/data:/databunker/data \ -v ~/certs:/databunker/certs \ -e "DATABUNKER_MASTERKEY=**DATABUNKER_MASTERKEY**" \ --rm --name dbunker paranoidguy/databunker ``` So, you need to prepare server.crt and server.key files. ## Generate self-signed certificates You can do the following command to generate one: ``` cd ~ mkdir -p certs cd certs openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \ -subj "/C=UK/ST=/L=London/O=Your-company Ltd./CN=databunker.your-company.com" \ -keyout server.key -out server.crt ``` ## Use certificates generated by letsencrypt Copy letsencrypt file **privkey.pem** to ~/certs/server.key Copy letsencrypt file **fullchain.pem** file to ~/certs/server.crt # Create a test record You can download and run a small test script that will create a user record, user app record, user consent, etc... ``` curl https://raw.githubusercontent.com/paranoidguy/databunker/master/create-test-user.sh -o test.sh chmod 755 ./test.sh ./test.sh **DATABUNKER_MASTERKEY** ``` You can now open browser at http://localhost:3000/ Use the following account details: Email: test@paranoidguy.com Phone: 4444 Code: 4444