How to Install Turtl Server

Install requirements

sudo apt install -y nodejs postgresql postgresql-contrib npm

Install software

sudo mkdir -p /opt/turtl
cd /opt/turtl
sudo git clone https://github.com/turtl/server
cd server/
sudo npm install
sudo cp config/config.yaml.default config/config.yaml

Create database

Access PostgreSQL shell

sudo su - postgres

Create the new database

createdb turtldb

Create a new PostgreSQL user

createuser turtlusr --pwprompt

Remember the password chosen. In this tutorial we’ll assume the pasword is PASSWORD.

Connect to the database

psql turtldb

Grant all privileges to the user

GRANT ALL PRIVILEGES ON DATABASE turtldb TO turtlusr;

Exit

\q

Edit docker-compose.yml file

sudo vi /opt/turtl/server/docker-compose.yml

version: '2.1'

services:
  turtl-server:
    build:
      context: ./
    environment:
      TURTL_DB_HOST: postgres-db
      TURTL_DB_PORT: 5432
      TURTL_DB_DATABASE: turtldb
      TURTL_DB_USER: turtlusr
      TURTL_DB_PASSWORD: PASSWORD
      TURTL_APP_SECURE_HASH_SALT: 12345678901234
    ports:
      - 8181:8181
    depends_on:
      postgres-db:
        condition: service_healthy

  postgres-db:
    image: postgres:11-alpine
    environment:
      POSTGRES_PASSWORD: PASSWORD
      POSTGRES_USER: turtlusr
      POSTGRES_DB: turtldb
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U turtl"]
      interval: 10s
      timeout: 5s
      retries: 5

Edit config.yaml file

sudo vi /opt/turtl/server/config/config.yaml

version: '2.1'

services:
  turtl-server:
    build:
      context: ./
    environment:
      TURTL_DB_HOST: postgres-db
      TURTL_DB_PORT: 5432
      TURTL_DB_DATABASE: turtl
      TURTL_DB_USER: turtl
      TURTL_DB_PASSWORD: turtl
      TURTL_APP_SECURE_HASH_SALT: abuHassN892MMn
    ports:
      - 8181:8181
    depends_on:
      postgres-db:
        condition: service_healthy

  postgres-db:
    image: postgres:11-alpine
    environment:
      POSTGRES_PASSWORD: turtl
      POSTGRES_USER: turtl
      POSTGRES_DB: turtl
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U turtl"]
      interval: 10s
      timeout: 5s
      retries: 5
server:
  # Per default, turtl will listen on all IP addresses
  # You can choose the IP it will use with this parameter
  host: '0.0.0.0'
  port: 8181

db:
  connstr: 'postgres://turtlusr:PASSWORD@127.0.0.1:5432/turtldb'
  pool: 24

loglevel: 'debug'

app:
  # ALWAYS false in production. Always.
  # Set to 'I UNDERSTAND THIS VIOLATES THE PRIVACY OF MY USERS' to enable
  enable_bookmarker_proxy: false
  # no trailing slash
  api_url: 'https://turtl.mydomain.tld/'
  www_url: 'https://turtl.mydomain.tld/'
  login:
    # Max failed login attemps. Set to -1 to disable
    max_attemps: 5
    # User locked for this duration in seconds
    lock_duration: 60
  emails:
    admin: 'me@mmydomain.tld'
    info: 'Turtl <me@mydomain.tld>'
    invites: 'me@mydomain.tld'
  # TODO: replace this with a long, unique value. seriously. write down a dream
  # you had, or the short story you came up with during your creative writing
  # class in your freshmen year of college. have fun with it.
secure_hash_salt: "blah blah blah blah"
  # set to true if you think it's ok to SEND invites if you have not confirmed
  # your account. great for testing, not so great for production. but what do
  # i know...
  allow_unconfirmed_invites: false

sync:
  # how many sync records can a client send at a time? it's a good idea to have
  # a limit here, lest a rogue client flood the server with sync items
  max_bulk_sync_records: 32

plugins:
  plugin_location: '/opt/turtl/server/plugins'
  # each key here corresponds to a folder name in the plugins folder, so `email`
  # below would be a plugin at /var/www/turtl/server/plugins/email (see the
  # example-plugins/ folder for an email plugin you can use)
  email:
    enabled: true
    endpoint: 'smtps://"my@email.tld":password@smtp.email.tld/?pool=true'
    defaults: {}

uploads:
  # if set to a path, files will be uploaded to the local filesystem instead of
  # S3. otherwise, set to false
  local: '/opt/turtl/server/public/uploads'
  # if true, downloading local files will be proxied through the turtl server.
  # this avoids needing to set up any CORS config in your favorite webserver,
  # but may slightly affect performance on high-demand servers.
  local_proxy: true
  # if local_proxy is false, this is should be the url path the uploaded files
  # are publicly available on
  url: 'http://api.turtl.dev/uploads'

s3:
  token: 'IHADAPETSNAKEBUTHEDIEDNOOOOO'
  secret: ''
  bucket: ''
  endpoint: 'https://s3.amazonaws.com'
  pathstyle: false