├── .gitignore ├── .upignore ├── MIT-LICENSE ├── README.md ├── project.clj ├── src └── up_clojure │ └── server.clj └── up.json /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | /.lein-* 7 | /.nrepl-port 8 | -------------------------------------------------------------------------------- /.upignore: -------------------------------------------------------------------------------- 1 | * 2 | !pom.xml 3 | !server.jar 4 | -------------------------------------------------------------------------------- /MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Radford Smith 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Clojure on Apex Up 2 | 3 | This is an example project to deploy an HTTP server written in Clojure using [Apex Up](https://github.com/apex/up). 4 | 5 | ## Getting Started 6 | 7 | Install Up: 8 | 9 | ``` 10 | $ curl -sf https://up.apex.sh/install | sh 11 | ``` 12 | 13 | Deploy the app: 14 | 15 | ```shell 16 | $ up 17 | ``` 18 | 19 | Open it in the browser: 20 | 21 | ```shell 22 | $ up url --open 23 | ``` 24 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject up-clojure "0.1.0-SNAPSHOT" 2 | :dependencies [[org.clojure/clojure "1.9.0"] 3 | [ring/ring-core "1.6.3"] 4 | [ring/ring-jetty-adapter "1.6.3"]] 5 | :main up-clojure.server 6 | :uberjar-name "server.jar" 7 | :profiles {:uberjar {:aot :all}}) 8 | -------------------------------------------------------------------------------- /src/up_clojure/server.clj: -------------------------------------------------------------------------------- 1 | (ns up-clojure.server 2 | (:require [ring.adapter.jetty :as jetty]) 3 | (:gen-class)) 4 | 5 | (defn handler [request] 6 | {:status 200 7 | :headers {"Content-Type" "text/html"} 8 | :body "Hello World"}) 9 | 10 | (defn -main [& args] 11 | (let [port (or (some-> (System/getenv "PORT") Integer/parseInt) 12 | 3000)] 13 | (jetty/run-jetty handler {:port port}))) 14 | -------------------------------------------------------------------------------- /up.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "up-clojure", 3 | "lambda": { 4 | "memory": 1536 5 | }, 6 | "hooks": { 7 | "build": "lein do pom, uberjar && cp target/server.jar .", 8 | "clean": "lein clean && rm server.jar" 9 | } 10 | } 11 | --------------------------------------------------------------------------------