Curator - Clojure Web App

I wrote a simple Clojure web application that you'll find on Github. It's a prototype, maybe still online at curator.lsenta.io.

The App

It's a "link sharing platform": Users add topics and share links on their public profile page.

welcome

add links

Back-end

I used luminus with PostgreSQL for persistence and buddy for authentication. That's a one-week experiment in writing my first Clojure application. There are a lot of rough edges. My goal was to go from lein new to "online" in a minimum amount of time.

A note on using PostgreSQL for dev and deploy:

If you're writing code on MacOS, Kitematic is an application to run Docker containers in a few clicks.

kitematic

Here's how I developed & deployed Curator:

  1. Start a PostgreSQL container using Kitematic. Kitematic will assign an ip:port to access the database. Something like 192.168.99.100:32772.
  2. Setup the database as detailed in Luminus documentation
  3. Connect with pgadmin to create the database

That's all you need to develop with Postgres.

Now here's how I deployed to a Linux server. That's a quick & dirty process that is good enough for such project:

The trick is to use an ssh tunnel between your local machine and the server. That way you only have to change the configuration once before you migrate the database and generate the project uberjar.

  1. Start a Docker container on the server
    docker run --name postgrescurator -p 127.0.0.1:32772:5432 postgres. This container is accessible only from localhost so we'll ignore the password.
  2. From your dev env, open an ssh tunnel to your server with ssh -L 32772:localhost:32772 my-server.
  3. pgadmin to localhost:32772, create the database
  4. re-configure your project to use the database at localhost:32772 then run lein ragtime migrate, this will migrate your remote database thanks to the ssh tunneling.
  5. With the same configuration, build your uberjar, lein ring uberjar, then scp it to your remote server and run java -jar my-uberjar.jar from there.

I also use a simple Nginx configuration to access the website from a subdomain:

server {  
    listen 80;
        server_name curator.beavr.io;

    location / {
            proxy_pass http://localhost:3000;
    }
}

And that's it, let me know if this helped you test or deploy your own prototype.