Skip to content

Deploying Attache on Digital Ocean using Docker

Philippe Vaucher edited this page Apr 5, 2017 · 4 revisions

This should take you 5 minutes.

Step 1

Create a Digital Ocean account if you don't have it yet, and login.

Step 2

Create a "Droplet"

  • under the Select Image section, choose the Applications tab and select Docker
  • feel free to customize any other settings on the page

Step 3

Once the droplet is created and available

  • If you chose the Add SSH Keys option earlier
    • Copy the ip address assigned to your droplet, e.g. X.X.X.X
    • SSH into the server ssh [email protected]
  • Otherwise, click on the Console access and login as root with your password

Step 4

Once you're inside the command line of the server, update the packages and install varnish

apt-get update && apt-get install varnish

Step 5

Reconfigure varnish to listen at port 80 instead of the default 6081

sed -i 's/6081/80/g' /etc/default/varnish

Step 6

Restart varnish

service varnish restart

Step 7

Your server is now accepting web requests via varnish which will work with an attache server running at port 8080. Except, your attache server isn't running yet. So let's do that!

docker run -it -p 8080:5000 -d --name attache attache/attache

This will ask Docker to

  • download & run attache/attache
  • allow us to reference it by name attache
  • and make it listen at port 8080 (hello varnish!)

To stop the attache server (why?)

docker stop attache

To run it again

docker start attache

AWS S3, Google Cloud Storage, ...

If you wish to have user uploaded files backed up to a cloud storage, you'll need to setup a VHOST environment variable

Then stop and remove the old attache

docker stop attache
docker rm attache

Launch a new attache container with VHOST env passed in

docker run -it -e VHOST -p 8080:5000 -d --name attache attache/attache

Test drive it

Checkout the demo app

git clone https://github.com/choonkeat/attache-railsapp.git
cd attache-railsapp
bundle
rake db:create db:schema:load

Point the ATTACHE_URL to your Digital Ocean server and run it

ATTACHE_URL=http://X.X.X.X rails s

Open http://localhost:3000/ and see it in action!