get api working in docker container
This commit is contained in:
parent
ef4f8959df
commit
e18cc26ddd
3 changed files with 16 additions and 11 deletions
|
|
@ -19,6 +19,7 @@ RUN apk add curl rlwrap
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY deps.edn ./
|
COPY deps.edn ./
|
||||||
RUN clj -P
|
RUN clj -P
|
||||||
|
RUN clj -Spath
|
||||||
COPY build.clj config.edn ./
|
COPY build.clj config.edn ./
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,34 @@
|
||||||
(ns micro-blog.api
|
(ns micro-blog.api
|
||||||
(:require [io.pedestal.connector :as conn]
|
(:require [io.pedestal.connector :as conn]
|
||||||
[io.pedestal.http.http-kit :as hk]
|
[io.pedestal.http.http-kit :as hk]
|
||||||
|
[micro-blog.config :refer [config]]
|
||||||
micro-blog.mastodon
|
micro-blog.mastodon
|
||||||
micro-blog.blue-sky
|
micro-blog.blue-sky
|
||||||
[taoensso.telemere :as tel]))
|
[taoensso.telemere :as tel]))
|
||||||
|
|
||||||
(defn mastodon-proc-handler []
|
(defn mastodon-proc-handler [_request]
|
||||||
(tel/log! :info "Procing Mastodon Scrape")
|
(let [msg "Proceding Mastodon Scrape"]
|
||||||
(micro-blog.mastodon/run)
|
(tel/log! :info msg)
|
||||||
{:status 200
|
(micro-blog.mastodon/run)
|
||||||
:body "Scraped Mastodon\n"})
|
{:status 200
|
||||||
|
:body msg}))
|
||||||
|
|
||||||
(defn blue-sky-proc-handler []
|
(defn blue-sky-proc-handler [_request]
|
||||||
(tel/log! :info "Procing BlueSky Scrape")
|
(let [msg "Procing BlueSky Scrape"]
|
||||||
|
(tel/log! :info msg)
|
||||||
(micro-blog.mastodon/run)
|
(micro-blog.mastodon/run)
|
||||||
{:status 200
|
{:status 200
|
||||||
:body "Scraped Mastodon\n"})
|
:body msg}))
|
||||||
|
|
||||||
(def routes
|
(def routes
|
||||||
#{["/bluesky" :get blue-sky-proc-handler :route-name :blue-sky]
|
#{["/bluesky" :get blue-sky-proc-handler :route-name :blue-sky]
|
||||||
["/mastodon" :get mastodon-proc-handler :route-name :mastodon]})
|
["/mastodon" :get mastodon-proc-handler :route-name :mastodon]})
|
||||||
|
|
||||||
(defn create-connector []
|
(defn create-connector []
|
||||||
(-> (conn/default-connector-map 8890)
|
(-> (conn/default-connector-map (:api-host @config) (Integer/parseInt (str (:api-port @config))))
|
||||||
(conn/with-default-interceptors)
|
(conn/with-default-interceptors)
|
||||||
(conn/with-routes routes)
|
(conn/with-routes routes)
|
||||||
(hk/create-connector nil)))
|
(hk/create-connector nil)))
|
||||||
|
|
||||||
(defn start []
|
(defn start []
|
||||||
;; (log/info :in 'start :msg "Starting Pedestal server with Telmere logging")
|
|
||||||
(conn/start! (create-connector)))
|
(conn/start! (create-connector)))
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,9 @@
|
||||||
:blue-sky-api-key "BLUE_SKY_API_KEY"
|
:blue-sky-api-key "BLUE_SKY_API_KEY"
|
||||||
:minstral-api-key "MISTRAL_API_KEY"
|
:minstral-api-key "MISTRAL_API_KEY"
|
||||||
:mastodon-host "MASTODON_BASE_URL"
|
:mastodon-host "MASTODON_BASE_URL"
|
||||||
:mastodon-account-id "MASTODON_ACCOUNT_ID"})
|
:mastodon-account-id "MASTODON_ACCOUNT_ID"
|
||||||
|
:api-host "API_HOST"
|
||||||
|
:api-port "API_PORT"})
|
||||||
|
|
||||||
(defn- load-config []
|
(defn- load-config []
|
||||||
(merge (read-string (slurp "config.edn"))
|
(merge (read-string (slurp "config.edn"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue