GithubHelp home page GithubHelp logo

planetfederal / spatialconnect-server Goto Github PK

View Code? Open in Web Editor NEW
1.0 6.0 6.0 2.12 MB

License: Apache License 2.0

JavaScript 43.06% HTML 0.22% PLpgSQL 2.37% CSS 3.79% Protocol Buffer 0.24% Clojure 48.77% Shell 0.76% Nginx 0.80%

spatialconnect-server's Introduction

spatialconnect-server

This server is the interface used to communicate with mobile clients using the SpatialConnect libraries. It's also the API that powers the dashboard web application.

Version

0.9

Running with Docker

First you have to install Docker for your local workstation.

Building the spatialconnect-server container

You can build the spatialconnect-server Docker container like this

docker build -t boundlessgeo/spatialconnect-server .

Once you've built the container, you can push it to the Docker registry to trigger a redeployment:

docker push boundlessgeo/spatialconnect-server

Note that anytime the boundlessgeo/spatialconnect-server GitHub repo is updated, the container will be rebuilt and deployed to the appropriate environment.

If you need to deploy to a Cloud Foundry environment, you can deploy the container like this:

# build the container for the environment
docker build -t boundlessgeo/spatialconnect-server:devio .
# push to a container repo where PCF can access it
docker push boundlessgeo/spatialconnect-server:devio
# instruct pcf to deploy the app using the container
cf push efc -o boundlessgeo/spatialconnect-server:devio

Local development environment setup

First startup the database container:

docker-compose up -d postgis

Then create the database and database user. (You may need to wait a few seconds for the db container to fully start)

docker-compose run -e PGHOST=postgis -e PGUSER=postgres --rm postgis createuser spacon
docker-compose run -e PGHOST=postgis -e PGUSER=postgres --rm postgis createdb spacon -O spacon

Then add the required extensions to our database.

docker-compose run -e PGHOST=postgis -e PGUSER=postgres --rm postgis psql -d spacon -c "CREATE EXTENSION postgis;"
docker-compose run -e PGHOST=postgis -e PGUSER=postgres --rm postgis psql -d spacon -c "CREATE EXTENSION pgcrypto;"

Now run the migration.

You will need to install leiningen to run the migration, if you haven't installed it yet. On OSX, run brew install leiningen.

cd server/
lein migrate

Start the spatialconnect-server container (which also starts the mosquitto container)

cd ..
docker-compose up -d spatialconnect-server
# you can tail the logs to ensure everything worked as expected
docker-compose logs -f spatialconnect-server

To run the webapp for local development,

cd /path/to/spatialconnect-server/web
npm install
npm run start:local

The webpack-dev-server will host the app here http://localhost:8080 and rebuild the JS when you make changes.

When you're done, you can shut all the containers down with

docker-compose stop

And if you want to remove all the containers, you can run

docker-compose rm -vf

To test the TLS configuration, you can use the mosquitto_pub command line client. Make sure you obtain a valid token by authenticating to the spatialconnect-server container api first. Also note that the password is required even though it is not used.

mosquitto_pub -h <container hostname or ip> -p 8883 -t "test" -m "sample pub"  -u "valid jwt" -P "anypass" --cafile path/to/ca.crt --insecure -d

spatialconnect-server's People

Contributors

frankrowe avatar georific avatar mrcnc avatar tetriscode avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

spatialconnect-server's Issues

Exception in thread "main" org.postgresql.util.PSQLException: ERROR: relation "spacon.migrations" does not exist

Hello Team,

When I try to migrate using the lein script, I have the following error message:

~/docker/test/spatialconnect-server-master/server$ lein migrate
WARNING: seqable? already refers to: #'clojure.core/seqable? in namespace: clojure.core.incubator, being replaced by: #'clojure.core.incubator/seqable?
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/boolean?
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer, being replaced by: #'clojure.tools.analyzer.utils/boolean?
WARNING: bounded-count already refers to: #'clojure.core/bounded-count in namespace: clojure.core.async, being replaced by: #'clojure.core.async/bounded-count
2017-03-24 17:44:55.386 DEBUG [main] --- spacon.db.conn : Making db connection to localhost:5432/spacon
2017-03-24 17:44:55.407 INFO [MLog-Init-Reporter] --- com.mchange.v2.log.MLog : MLog clients using slf4j logging.
2017-03-24 17:44:55.463 INFO [main] --- com.mchange.v2.c3p0.C3P0Registry : Initializing c3p0-0.9.5-pre9 [built 08-October-2014 03:06:08 -0700; debug? true; trace: 10]
2017-03-24 17:44:59.417 DEBUG [main] --- spacon.db.conn : Running database migration
2017-03-24 17:44:59.418 DEBUG [main] --- spacon.db.conn : Loading database migration config
2017-03-24 17:44:59.464 INFO [main] --- c.m.v.c.i.AbstractPoolBackedDataSource : Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> z8kfsx9nc1w661mipoew|3891f024, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.postgresql.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceUseNamedDriverClass -> false, identityToken -> z8kfsx9nc1w661mipoew|3891f024, idleConnectionTestPeriod -> 800, initialPoolSize -> 2, jdbcUrl -> jdbc:postgresql://localhost:5432/spacon, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 3600, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 120, maxPoolSize -> 10, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 2, numHelperThreads -> 3, preferredTestQuery -> null, privilegeSpawnedThreads -> false, properties -> {user=, password=}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
Exception in thread "main" org.postgresql.util.PSQLException: ERROR: relation "spacon.migrations" does not exist
Position : 16, compiling:(/tmp/form-init691726267945491079.clj:1:72)
at clojure.lang.Compiler.load(Compiler.java:7442)
at clojure.lang.Compiler.loadFile(Compiler.java:7368)
at clojure.main$load_script.invokeStatic(main.clj:277)
at clojure.main$init_opt.invokeStatic(main.clj:279)
at clojure.main$init_opt.invoke(main.clj:279)
at clojure.main$initialize.invokeStatic(main.clj:310)
at clojure.main$null_opt.invokeStatic(main.clj:344)
at clojure.main$null_opt.invoke(main.clj:341)
at clojure.main$main.invokeStatic(main.clj:423)
at clojure.main$main.doInvoke(main.clj:386)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
Caused by: org.postgresql.util.PSQLException: ERROR: relation "spacon.migrations" does not exist
Position : 16

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2270)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1998)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:570)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:420)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:305)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:430)
at clojure.java.jdbc$db_query_with_resultset$run_query_with_params__17888.invoke(jdbc.clj:824)
at clojure.java.jdbc$db_query_with_resultset.invokeStatic(jdbc.clj:834)
at clojure.java.jdbc$db_query_with_resultset.invoke(jdbc.clj:790)
at clojure.java.jdbc$query.invokeStatic(jdbc.clj:866)
at clojure.java.jdbc$query.doInvoke(jdbc.clj:838)
at clojure.lang.RestFn.invoke(RestFn.java:464)
at ragtime.jdbc.SqlDatabase.applied_migration_ids(jdbc.clj:43)
at ragtime.core$migrate_all.invokeStatic(core.clj:43)
at ragtime.core$migrate_all.invoke(core.clj:32)
at ragtime.repl$migrate.invokeStatic(repl.clj:49)
at ragtime.repl$migrate.invoke(repl.clj:34)
at spacon.db.conn$migrate.invokeStatic(conn.clj:54)
at spacon.db.conn$migrate.invoke(conn.clj:52)
at clojure.lang.Var.invoke(Var.java:375)
at user$eval27117.invokeStatic(form-init691726267945491079.clj:1)
at user$eval27117.invoke(form-init691726267945491079.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6978)
at clojure.lang.Compiler.eval(Compiler.java:6968)
at clojure.lang.Compiler.load(Compiler.java:7430)

Seems there is an issue there!! I'm currently using lein version 2.7.1

lein -v
Leiningen 2.7.1 on Java 1.8.0_121 Java HotSpot(TM) 64-Bit Server VM

Can you please have a look? Thanks in advance,

Mat

create production dockerfile

Create another Dockerfile to be used for production builds that has different environment variables when building the container on Docker Hub
This line needs to be changed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.