This is a clone on minimalist-fulcro-template extended with PostgreSQL and deploy to Fly.io.
Key differences:
- You need to run
docker compose up
in this folder to start PostgreSQL - Evaluating
com.example.server.main
will not only start the server but also apply DB migrations fromresources/db-init.sql
- Pathom resolvers can use
(:conn env)
withnext.jdbc/execute!
to run queries - You must manually call
(start)
in the main ns to start the server
docker compose up # start Postgres
docker build -t ex-fly . # build the image
# Run the image, pointing to Postgres running on the host:
docker run --rm -it -p 9999:8008 \
-e DATABASE_URL="jdbc:postgresql://postgres:FulcroRulez@host.docker.internal:5432/postgres" \
ex-fly:latest
fly launch --name mft-fly --no-deploy
- here we choose the app name mft-flyfly postgres create
and choose app name, e.g. mft-fly-db This will print a connect string such aspostgres://postgres:sxRhUb2HlJUjSuc@mft-fly-db.internal:5432
- Set the DB url env var (see the
config
ns) for the app using the value:fly secrets set -a mft-fly DATABASE_URL="postgres://postgres:sxRhUb2HlJUjSuc@mft-fly-db.internal:5432"
- Deploy:
fly deploy
- Access your deployed app under its name, here: https://mft-fly.fly.dev/
- For Calva, the server is started automatically during jack-in
- Factor out
resolvers
ns & make it so that you only need to loadpathom
ns to get resolver changes in
A template for starting a new, minimalistic, full-stack Fulcro application. Intended for playing with and learning Fulcro, not for production apps, and therefore simpler than the official fulcro-template. It is a good starting point for your learning projects that is hopefully simple enough for you to understand.
TIP: For an even simpler template with an in-browser backend, see minimalist-fulcro-template-backendless.
Download or clone this repository to your computer and start hacking away.
You will run shadow-cljs, which will watch, compile, and update the sources and separately you will start a HTTP server from the REPL to serve the application and process Pathom requests.
Prerequisites: same as shadow-cljs'.
First, install frontend dependencies via npm, yarn, or similar:
npm install # or yarn install # reportedly yarn < v3
then start the application either via
npx shadow-cljs watch main
or, if you have Babashka installed, via
bb run
NOTE: For Calva, it is best to start a client build and REPL from the editor - run Jack-in, selecting shadow-cljs then the :main
build.
Now start the server: load com.example.server.main
into the Shadow REPL - this will also evaluate the (defonce stop-fn (atom start))
line, starting the server.
NOTE: Now if you ever change Pathom resolvers or something, run the restart code in the (comment ...)
in the main ns.
Finally, navigate to http://localhost:8008. Note: You can switch to the browser REPL by evaluating (shadow/repl :main)
in the REPL. (Calva does the latter for you).
You can also compile the sources into a directory via
npx shadow-cljs release main
# or: bb build
No thought was given to security, performance, monitoring, error tracking and other important production concerns. It also bakes in fulcro-troubleshooting, which you do not want unnecessarily increasing your bundle size in production settings. So if you want to use the template as a starting point for a production application, you will need to add those yourself.
Copyleft © 2022 Jakub Holý
Distributed under the Unlicense.