Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev setup improvements #123

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
/geoserver/*
!/geoserver/README.md
/.clj-kondo
/.lsp
/osrm/*
!/osrm/README.md
!/osrm/update-data.sh
Expand All @@ -28,7 +27,7 @@ webapp/.clj-kondo/*
!webapp/.clj-kondo/config.edn
webapp/node_modules
webapp/dist
webapp/.lsp
webapp/.lsp/.cache
webapp/out
webapp/.shadow-cljs
webapp/.lein-repl-history
webapp/.lein-repl-history
2 changes: 2 additions & 0 deletions bb.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{:tasks {up {:doc "Start dev resource with Compose"
:task (shell "docker compose up -d proxy-local")}}}
16 changes: 14 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ services:
volumes:
- './nginx/proxy_dev.conf:/etc/nginx/templates/default.conf.template:z'

proxy-local:
extends:
service: proxy-base
links:
- mapproxy
- logstash
- kibana
- geoserver
volumes:
- './nginx/proxy_local.conf:/etc/nginx/templates/default.conf.template:z'

htpasswd:
image: lipas/htpasswd
build:
Expand Down Expand Up @@ -75,8 +86,9 @@ services:
- './mapproxy:/lipas:z'
- './mapproxy/start.sh:/start.sh:z'
- 'mapproxy_cache:/mapproxy/cache_data'
ports:
- '8080:8080'
# No need to expose
#ports:
# - '8080:8080'

backend-base:
image: clojure:lein
Expand Down
101 changes: 101 additions & 0 deletions nginx/proxy_local.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
upstream mapproxy {
server mapproxy:8080;
}

upstream kibana {
server kibana:5601;
}

upstream geoserver {
server geoserver:8080;
}

# Redirect http traffic to https
# Also redirects liikuntapaikat.fi -> liikuntapaikat.lipas.fi
server {
listen 80;
return 301 https://$host$request_uri;
}

server {
root /usr/share/nginx/html/;
index index.html;

listen 443 ssl;
ssl_certificate /certs/server.crt;
ssl_certificate_key /certs/server.key;

# Make search engines ignore anything returned from this proxy
add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";

server_name lipas-dev.cc.jyu.fi;

gzip on;
gzip_vary on;
gzip_http_version 1.0;
gzip_comp_level 6;
gzip_min_length 1024;
gzip_types application/javascript application/json application/transit+json;

if ($host = "liikuntapaikat.fi") {
return 301 https://liikuntapaikat.lipas.fi$request_uri;
}
if ($host = "www.liikuntapaikat.fi") {
return 301 https://liikuntapaikat.lipas.fi$request_uri;
}
if ($host = "uimahallit.lipas.fi") {
return 303 https://lipas.fi/portaalit.html;
}
if ($host = "jaahallit.lipas.fi") {
return 303 https://lipas.fi/portaalit.html;
}

location /mapproxy {
proxy_pass http://mapproxy/mapproxy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $remote_addr;
port_in_redirect off;
proxy_connect_timeout 600;
proxy_set_header X-Script-Name /mapproxy;
}

location /kibana/ {
proxy_pass http://kibana;
satisfy all;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd;
allow 130.234.0.0/16; # JYU IP-address space
allow 127.0.0.1; # Localhost
allow 172.18.0.1; # Docker bridge
deny all;
}

location /geoserver {
proxy_pass http://geoserver;
}

location /tilastokeskus/ {
proxy_pass https://geo.stat.fi/;
}

location /matomo/ {
proxy_pass https://piwik-ui.app.jyu.fi/;
}

location /digitransit/ {
proxy_set_header 'digitransit-subscription-key' ${DIGITRANSIT_SUBSCRIPTION_KEY};
proxy_pass https://api.digitransit.fi/;
}

location /vaylavirasto/ {
proxy_pass https://avoinapi.vaylapilvi.fi/;
}

# Return index.html for unmatched uris. To enable HTML5 routing
# without /#/ prefix.
location / {
try_files $uri $uri/ /index.html =404;
}

}
4 changes: 3 additions & 1 deletion webapp/.clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{:lint-as
{reagent.core/with-let clojure.core/let
etaoin.api/doto-wait clojure.core/doto}}
etaoin.api/doto-wait clojure.core/doto}
:linters {:unsorted-requires-namespaces {:level :warning
:sort :case-sensitive}}}
4 changes: 4 additions & 0 deletions webapp/.lsp/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{:clean {:automatically-after-ns-refactor true
:ns-inner-blocks-indentation :keep
:sort {:require :lexicographically}}
:log-path "lsp.log"}
2 changes: 1 addition & 1 deletion webapp/dev/legacy-dev.clj → webapp/dev/legacy_dev.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns lipas.dev
(ns legacy-dev
"Entrypoint for `lein ring` dev server."
(:require
[lipas.backend.system :as backend]
Expand Down
6 changes: 6 additions & 0 deletions webapp/dev/project_devtools.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(ns project-devtools
(:require [re-frame.db]
[reagent-dev-tools.core :as dev-tools]))

(dev-tools/start!
{:state-atom re-frame.db/app-db})
53 changes: 14 additions & 39 deletions webapp/dev/repl.clj → webapp/dev/user.clj
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
(ns lipas.repl
(ns user
"Utilities for reloaded workflow using `integrant.repl`."
(:require
[clojure.tools.namespace.repl]
[integrant.core :as ig]
[integrant.repl]
[integrant.repl.state]
[lipas.backend.config :as config]
[lipas.backend.core :as core]
[lipas.backend.system :as system]
[lipas.integration.core :as integrations]
[lipas.maintenance :as maintenance]
[lipas.search-indexer :as search-indexer]
[lipas.worker :as worker]))
[integrant.repl :refer [reset reset-all halt go]]
[integrant.repl.state]))

(def dev-config (dissoc config/system-config :lipas/nrepl))

(integrant.repl/set-prep! #(identity dev-config))
(integrant.repl/set-prep! (fn []
(dissoc @(requiring-resolve 'lipas.backend.config/system-config) :lipas/nrepl)))
#_(clojure.tools.namespace.repl/set-refresh-dirs "/src")

(defn current-config []
Expand All @@ -30,25 +21,6 @@
(defn current-config []
integrant.repl.state/config)

(defn start! []
(integrant.repl/go))

(defn stop! []
(integrant.repl/halt))

(defn resume! []
(integrant.repl/resume))

(defn reload!
"Reloads code for changed files in classpath and restarts the system."
[]
(integrant.repl/reset))

(defn reload-all!
"Reloads code for all files in classpath and restarts the system."
[]
(integrant.repl/reset-all))

(defn db
"Returns the :lipas/db key of the currently running system. Useful for
REPL sessions when a function expects `db` as an argument."
Expand All @@ -65,25 +37,28 @@

(defn reindex-search!
[]
(search-indexer/main (db) (search) "search"))
((requiring-resolve 'lipas.backend.search-indexer/main) (db) (search) "search"))

(defn reindex-analytics!
[]
(search-indexer/main (db) (search) "analytics"))
((requiring-resolve 'lipas.backend.search-indexer/main) (db) (search) "analytics"))

(defn reset-password!
[email password]
(let [user (core/get-user (db) email)]
(core/reset-password! (db) user password)))
(let [user ((requiring-resolve 'lipas.backend.core/get-user) (db) email)]
((requiring-resolve 'lipas.backend.core/reset-password!) (db) user password)))

(defn reset-admin-password!
[password]
(reset-password! "[email protected]" password))

(comment
(start!)
(reload!)
(go)
(reset)
(reindex-search!)
(reindex-analytics!)
(reset-admin-password! "kissa13")

(require '[migratus.core :as migratus])
(migratus/create nil "roles" :edn)
)
Loading
Loading