<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jonathan D. Wright</title>
    <description>The latest articles on DEV Community by Jonathan D. Wright (@jdwright).</description>
    <link>https://dev.to/jdwright</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F964286%2F42aa5271-1974-4e5a-9b2c-ba1d6846de2e.jpeg</url>
      <title>DEV Community: Jonathan D. Wright</title>
      <link>https://dev.to/jdwright</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jdwright"/>
    <language>en</language>
    <item>
      <title>Deploying Julia Genie on Heroku</title>
      <dc:creator>Jonathan D. Wright</dc:creator>
      <pubDate>Thu, 23 Mar 2023 20:53:12 +0000</pubDate>
      <link>https://dev.to/jdwright/deploying-julia-genie-on-heroku-464b</link>
      <guid>https://dev.to/jdwright/deploying-julia-genie-on-heroku-464b</guid>
      <description>&lt;p&gt;The tutorials for Genie, a web framework in the Julia language, are pretty good, but there were some holes that I wanted to fill in.  In particular, I want to show as directly as possible how to get a Genie app running on Heroku.  I'll assume some knowledge of Heroku.  There's an official tutorial here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://genieframework.com/docs/genie/v5.11/tutorials/Deploying-With-Heroku-Buildpacks.html"&gt;https://genieframework.com/docs/genie/v5.11/tutorials/Deploying-With-Heroku-Buildpacks.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My recommendation is that you follow most of it, but without using the sample app that's mentioned, as it doesn't work as is.  Instead, use Genie to create a template as shown in these tutorials:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://genieframework.com/docs/genie/v5.11/tutorials/Developing-Web-Services.html"&gt;https://genieframework.com/docs/genie/v5.11/tutorials/Developing-Web-Services.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://genieframework.com/docs/genie/v5.11/tutorials/Developing-MVC-Web-Apps.html"&gt;https://genieframework.com/docs/genie/v5.11/tutorials/Developing-MVC-Web-Apps.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;julia&amp;gt; using Genie
julia&amp;gt; Genie.Generator.newapp_fullstack("GenieDemo5")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll be prompted for a choice of db, and you should use postgres if you're going to deploy to Heroku, so I chose&lt;/p&gt;

&lt;p&gt;&lt;code&gt;3. PostgreSQL&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This creates a Genie app in a new directory GenieDemo5, and also starts the web server.  If you're already running postgres, this should work, but since I'm not, the server crashed.  I normally run postgres via docker, so you could, for example, add a &lt;code&gt;docker-compose.yml&lt;/code&gt; file to the app that looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '3'
services:
  database:
    image: postgres
    ports:
      - 5434:5432
    env_file:
      - .env.dev
    volumes:
      - db_data:/var/lib/postgresql/data
volumes:
  db_data:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and a &lt;code&gt;.env.dev&lt;/code&gt; file that looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POSTGRES_USER=postgres
POSTGRES_PASSWORD=long-password-for-genie-demo5
POSTGRES_DB=geniedemo5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The details here aren't important.  For example, I wanted to map the postgres port from 5432 in the container to 5434 on my machine to avoid conflicts.  So if you have something like the above,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker-compose up -d&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;will start your database in the background.  Then you have to set the parameters in &lt;code&gt;db/connection.yml&lt;/code&gt; to match your configuration, so for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;env: ENV["GENIE_ENV"]

dev:
  adapter:  PostgreSQL
  host:     127.0.0.1
  port:     5434
  database: geniedemo5
  username: postgres
  password: long-password-for-genie-demo5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you've handled the db set up, then your app should start locally. &lt;br&gt;
 The tutorials don't tell you how to start the server other than creating a new app, but you can do it as follows:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bin/server&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Browsing to&lt;/p&gt;

&lt;p&gt;&lt;a href="http://127.0.0.1:8000"&gt;http://127.0.0.1:8000&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;will show the Genie welcome page.  Now, we can deploy just this much to Heroku.  Following the tutorial, create an app with the suggested Julia buildpack, for example:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;heroku create geniedemo5 --buildpack https://github.com/Optomatica/heroku-buildpack-julia.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This creates the Heroku app, and outputs the app url and the git url.  If you've already created a git repo, it makes the remote for you as well, but if not, you can use the given url like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init
git remote add heroku https://git.heroku.com/geniedemo5.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You also need a &lt;code&gt;Procfile&lt;/code&gt; that looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;web: bin/server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you commit, push to Heroku, and watch the logs, you'll see the app build and start, but then crash.  Because we're using an app with different environments set up, you need to do&lt;/p&gt;

&lt;p&gt;&lt;code&gt;heroku config:set GENIE_ENV=prod&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That's enough to get the welcome page working.  Of course, you'd still need to set up the db on Heroku.  Also note that I got memory warnings until I started using a 2x dyno.  I'm not currently running this app since I didn't want to pay for a demo, but the code as described here is on github:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/jdwright/GenieDemo5"&gt;https://github.com/jdwright/GenieDemo5&lt;/a&gt;&lt;/p&gt;

</description>
      <category>julialang</category>
      <category>genie</category>
      <category>heroku</category>
    </item>
    <item>
      <title>SvelteKit with Vercel and Supabase</title>
      <dc:creator>Jonathan D. Wright</dc:creator>
      <pubDate>Fri, 11 Nov 2022 13:53:12 +0000</pubDate>
      <link>https://dev.to/jdwright/sveltekit-with-vercel-and-supabase-1ik</link>
      <guid>https://dev.to/jdwright/sveltekit-with-vercel-and-supabase-1ik</guid>
      <description>&lt;p&gt;I've been learning how to create SvelteKit apps with Vercel and Supabase, and although the Supabase docs are great, there's a couple gotchas.  If you follow the Supabase Quickstart for SvelteKit, it starts by asking you to create a SvelteKit Skeleton Project.  It says you don't need typescript, which is true in general, but the example files in the quickstart do use typescript.  So to start off as smoothly as possible, you should choose &lt;code&gt;Yes, using Typescript syntax&lt;/code&gt; when creating the SveltkeKit app.&lt;/p&gt;

&lt;p&gt;The most important gotcha is in creating &lt;code&gt;src/lib/supabaseClient.ts&lt;/code&gt;, which according to the quickstart should be&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { createClient } from '@supabase/auth-helpers-sveltekit'
import { env } from '$env/dynamic/public'

export const supabaseClient = createClient(env.PUBLIC_SUPABASE_URL, env.PUBLIC_SUPABASE_ANON_KEY)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My experience was this worked locally but not in production, and I couldn't definitively determine why.  I believe it has to do with server side rendering working differently in the two environments.  You get a &lt;code&gt;supabaseUrl is required&lt;/code&gt; error, and there are various reports of problems around this scenario online.  Some of the solutions seems to be red herrings for this exact configuration, like using &lt;code&gt;.env.local&lt;/code&gt; rather than &lt;code&gt;.env&lt;/code&gt;, or prefixing the environment variables with &lt;code&gt;NEXT_&lt;/code&gt;, which don't apply to SvelteKit.  I got it working with the following &lt;code&gt;supabaseClient.ts&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { createClient } from '@supabase/auth-helpers-sveltekit'
import {PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY} from '$env/static/public'

export const supabaseClient = createClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's not clear why the server side version is necessary; it may have to do with the build process, and something that needs to be done differently with Vercel.  Note that I also had to add these two environment variables to the Vercel settings.  That may be fairly obvious, but still worth noting when just following the Supabase quickstart guide.&lt;/p&gt;

</description>
      <category>sveltekit</category>
      <category>vercel</category>
      <category>supabase</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
