I saw something a while back about a proof of comncept or demo with XTDB-2. Is that a thing?
yep: https://biffweb.com/p/trying-out-xtdb2/ however it's out of date and probably not very helpful anymore. I'm planning to do a followup hopefully in the next couple months if we're lucky.
Hi, I'm just getting started with clojure/biff and have got a basic app deployed to digital ocean as described in the "Deploy to production" tutorial. Now I'd like to set up a basic ci/cd pipeline to deploy on changes to a git branch. Is there an example of this kind of ci/cd setup somewhere that someone could please point me towards?
Ok, so it didn't quite "Just Work" but it wasn't too difficult. Here is the github actions workflow file if anyone else wants to do something similar:
name: Deploy To Digital Ocean Droplet via ssh
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy app
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add known hosts
run: |
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
- name: Prepare java
uses: actions/setup-java@v4
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '21'
- name: Install clojure tools
uses: DeLaGuardo/setup-clojure@12.5
with:
cli: 1.11.2.1446
- name: Deploy to Digital Ocean
uses: mobiledevops/secret-to-file-action@v1
with:
base64-encoded-secret: ${{ secrets.CONFIG_ENV_BASE64 }}
filename: "config.env"
is-executable: false
working-directory: "./"
- run: |
clojure -M:dev deploy
For speed I chose to encode the config.env file as base64, keep it in a secret and then write back to a file, but the best way to do this is to probably pass the relevant secrets as args into your clojure -M:dev deploy commandThank you so much for sharing what you figured out.
I haven't done this on top of a regular digitalocean VM, but I have deployed biff to digitalocean's App Platform as a docker container and it worked fine. you'll need to take the contents of config.env and enter them into a web form as part of the process. I think there might've also been some kind of timeout I had to configure since the app has a longer startup time. deploying this way will be more expensive--$12/month for the app platform stuff I believe and $15/month for managed postgres, since you can't use disk persistence for XTDB on ephemeral containers. my general recommendation is to stick with the default manual deploy commands and then switch to some sort of container-based deployment w/ git deploys if/when there are multiple people working on the app.
Thanks for the quick reply (and for the framework too, of course! 👍🏼). It’s just me working on this for now, but it’s for a proof of concept that might turn into a production app, so might have my colleague working on it as well eventually. However, for me personally, because I have many side projects that I work on in many different languages/frameworks, I always feel much more at peace when there’s an option to deploy just by merging into the main branch - it’s one less thread consuming mental space, and if I come back to a project cold after 6 months, it’s less of a barrier to entry to add a new feature or fix a bug etc if deployment works in this fairly “standard” way - ie being triggered by merging into a branch. So, suppose I was to have a go at implementing some kind of automated deployment to a vps eg via GitHub actions. Do you have an idea of how you’d go about this? I was thinking of either trying to replicate the steps that you take in the tutorial directly in GitHub actions, or maybe trying kamal ( https://bogoyavlensky.com/blog/deploying-full-stack-clojure-app-with-kamal/)- do you have any intuition on what might be the best approach?
makes sense--I assume you're ok with provisioning the server normally (i.e. by creating a droplet and running the server-setup.sh script manually), and you just want subsequent deploys to work by pushing to main? My first thought is that you could have github actions run the clj -M:dev deploy command and I think it might Just Work... github actions would just need to have an ssh key pair with access to the server--you could generate one and manually stick the public key in /home/app/.ssh/authorized_keys on the server.
Yes that was exactly the kind of thing I was imagining - will give it a try. Thanks very much for your help! 😀
for sure! good luck.