jcs / rubywarden

An unofficial, mostly Bitwarden-compatible API server written in Ruby (Sinatra and ActiveRecord)
ISC License
593 stars 49 forks source link

Add Dockerfile #51

Closed jhuizy closed 6 years ago

jhuizy commented 6 years ago

This adds a lightweight docker implementation that runs the server. Can be used for integrating with CI, or docker-compose.

The docker image is based on ruby:2.3 and simply installs the dependencies listed in the Gemfile, and is able to run the server. Doesn't include any SSL by default.

An example docker-compose config that I'm using for my server (includes nginx for reverse proxy and lets encrypt helper for setting up ssl):

 nginx-proxy:
    image: jwilder/nginx-proxy
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "./certs:/etc/nginx/certs:ro"
      - "/etc/nginx/vhost.d"
      - "/usr/share/nginx/html"
      - "/var/run/docker.sock:/tmp/docker.sock:ro"
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
  nginx-letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    volumes_from: 
      - nginx-proxy 
    volumes:
      - "./certs:/etc/nginx/certs:rw"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
  bitwarden:
    build: bitwarden-ruby
    command: bundle exec rackup -p 4567 config.ru
    restart: always
    environment:
      - "LETSENCRYPT_EMAIL=${EMAIL}"
      - "LETSENCRYPT_HOST=bitwarden.${DOMAIN}"
      - "VIRTUAL_HOST=bitwarden.${DOMAIN}"
      - "VIRTUAL_PORT=4567"
      - "PORT=4567"
      - "RACK_ENV=production"
      - "ALLOW_SIGNUPS=true"
    volumes:
      - "./bitwarden:/app/db"

(see more at https://github.com/jhuizy/server/blob/master/docker-compose.yml).

jcs commented 6 years ago

Please host the instructions somewhere and submit a PR to link to it from the Deployment section of README.md. I'd rather not have to maintain documentation for all kinds of different deployments.