How to deploy a clojure web application to Amazon EC2 (AWS Elastic Beanstalk + Leiningen + Compojure + Ring + Tomcat)

前端 未结 1 1218
攒了一身酷
攒了一身酷 2021-02-06 08:26

AS title,
My IDE is intellij idea 12.1.4 ,
What toolkit or plugin do I need to be able to deploy clojure web application to Amazon EC2?

Are there any link

相关标签:
1条回答
  • 2021-02-06 08:30

    If you are just deploying a war file with no other custom infrastructure then using EC2 directly is overkill and elastic beanstalk will do what you need far more easily. If you are growing something bigger, and want one click deployment then pallet is a great tool.

    There is a lot to Pallet and it is a great library for writing amazingly small programs for doing this sort of thing (and much much more). Take some time to understand the pallet concepts of 'node' 'group' 'converge' etc, and give yourself plenty of patience. Once you get going with pallet it feels like magic.

    The place to start is with the pallet getting started guide. go through the hello world example which will make sure your aws account is set up and keys are where they need to be. Then you can wite a bit of clojure code that creates an instance with the latest version of your webapp on it.

    You will need:

    • pallet 0.8+
    • the pallet java crate
    • a group spec that installs java and copies the war file over.
    • the pallet lein plugin is nice though not required
    • lots of patience to get things up and running.

    A rough outline of a group spec for this would look a bit like

    (def java-server
      (java/server-spec
       {:vendor :oracle
        :components #{:jdk}
        :version [7]})) 
    
    (def webserver
     (node-spec
       :image {:os-family :ubuntu} 
       :hardware {:min-cores 1 :min-ram (* 2 1024)}
       :phases {:configure
                (plan-fn
                   (package-manager :update)
                   (package "tomcat7")
                (remote-file "/var/lib/tomcat7/webapps/myapp.war"
                   :local-file "target/myApp.war"
                   :owner "tomcat7"
                   :group "tomcat7"
                   :mode 755))
    
    (def web-group
     (group-spec
       "my-websertvers"
       webserver
       :extends [java-server]))
    

    you would then call converge with web-group to either create or update your servers.

    and please hop onto #pallet on freenode, where the friendly folks (my self included between ~10:00 and ~18:00 US-west) are eager to help.

    0 讨论(0)
提交回复
热议问题