version: '3'

volumes:
  bundle:
  db:

services:
  db:
    image: nouchka/sqlite3:latest
    volumes:
      - db:/root/db
    stdin_open: true
    tty: true

  web: &rails
    build:
      context: .
      dockerfile: Dockerfile
    command: bash -c "rm -f tmp/pids/server.pid && bundle install && EDITOR='mate --wait' bundle exec rails credentials:edit && bundle exec rake db:create db:migrate db:seed && bundle exec rails s -e production -b '0.0.0.0'"
    volumes:
      - .:/app
      - bundle:/usr/local/bundle
      - ./node_modules:/app/node_modules
    tmpfs: /app/tmp
    depends_on:
      - db
    env_file: app.env
    tty: true
    stdin_open: true
    environment:
      VIRTUAL_HOST: contact.bitium.agency
      LETSENCRYPT_HOST: contact.bitium.agency
      VIRTUAL_PORT: 3000

networks:
  default:
    external:
      name: nginx-proxy