How to run code from an env variable

Problem

I’m making a side project that needed to ship custom code under machines with the same Dockerfile.

My solution

I choose to do this through environment variables!

This example will be in elixir but would work with pretty much any programming language!

tl;dr: we make a run.sh that elixir TMP_file

1. The entrypoint

Create a run.sh file like this:

#!/bin/sh
TMPFILE=$(mktemp)
echo "$CODE" > $TMPFILE
elixir $TMPFILE

Then make sure to make it executable with chmod +x run.sh.

2. The Dockerfile

Your Dockerfile should install your programming language and at the end ADD run.sh /path/to/somewhere and end with CMD /path/to/somewhere/run.sh. Here’s an actual example: flyio-run-code-from-env-variable/Dockerfile at 2c2b4c7b7ac7aab8b0bff95f405f3161660c05a5 · lubien/flyio-run-code-from-env-variable · GitHub

3. Preparing a fly.io app

Create your app using fly launch --no-deploy, tweak the internal_port to 4000 or whatever you want for your app. My example uses 4000.

Assuming your file is named bug.ex you can set the env variable as CODE=cat bug.exs fly secrets set CODE="$CODE" --stage. This will not trigger a deploy yet.

4. Deploy!

Run fly deploy --ha=false (disabling HA to make only one machine).

Your CLI will say that the deployment didn’t work if it takes forever to compile (like my Elixir example) so don’t worry. Use fly logs to see when it finishes compiling and starts the server.

Go to your-app-name.fly.dev

Tips

If the above guide is confusing, it’s fine look at the first posts that I’ve wrote here. This was originally a post where I added detailed notes about me experimenting this so there’s more tips below!


Original post:

Title: [Dev log] Trying to deploy a machine with the code on an env variable!

I got interested in one thing: can I deploy an elixir machine with the code being inside an environment variable?

I’m not sure this will work but I’m really interested in it so I’m going to try and I will post updates here in soft real time.

Edit: it works, by this message it was working already: How to run code from an env variable - #14 by lubien

2 Likes

I needed a Dockerfile so I just copied this one:

I needed a simple elixir 1 file script so I copied this one

My dir looks like this:

[I] ➜ ls -la
total 24
drwxr-xr-x   6 lubien  staff   192 May  5 08:22 .
drwxr-xr-x   3 lubien  staff    96 May  5 08:12 ..
drwxr-xr-x  12 lubien  staff   384 May  5 08:27 .git
-rw-r--r--   1 lubien  staff   715 May  5 08:13 Dockerfile
-rw-r--r--   1 lubien  staff  2118 May  5 08:20 bug.exs

So I fly launch it and accepted not config changes. Manually edited internal_port to 4000:

# fly.toml app configuration file generated for bugex on 2024-05-05T08:15:09-03:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'bugex'
primary_region = 'gru'

[build]

[http_service]
internal_port = 4000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1

Also edited bug.exs because it used port 5001, changed to 400

- http: [ip: {127, 0, 0, 1}, port: 5001],
+ http: [ip: {127, 0, 0, 1}, port: 4000],

fly deploy failed

WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.
You can fix this by configuring your app to listen on the following addresses:
  - 0.0.0.0:4000
Found these processes inside the machine with open listening sockets:
  PROCESS        | ADDRESSES
-----------------*----------------------------------------
  /.fly/hallpass | [fdaa:0:3335:a7b:1f60:2454:55c3:2]:22

The reason is that since this code is built at runtime its not immediately listening to the port. Found that out by looking at fly logs:

2024-05-05T11:22:28Z app[568300dc794008] gru [info] WARN Reaped child process with pid: 432 and signal: SIGUSR1, core dumped? false
2024-05-05T11:22:29Z app[568300dc794008] gru [info]===> Analyzing applications...
2024-05-05T11:22:29Z app[568300dc794008] gru [info]===> Compiling cowlib
2024-05-05T11:22:35Z proxy[568300dc794008] gru [error][PC01] instance refused connection. is your app listening on 0.0.0.0:4000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-05-05T11:22:43Z app[568300dc794008] gru [info] WARN Reaped child process with pid: 459 and signal: SIGUSR1, core dumped? false
2024-05-05T11:22:44Z app[568300dc794008] gru [info]===> Analyzing applications...
2024-05-05T11:22:44Z app[568300dc794008] gru [info]===> Compiling cowboy
2024-05-05T11:22:46Z proxy[568300dc794008] gru [error][PC01] instance refused connection. is your app listening on 0.0.0.0:4000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)

So after compiling it still does not work. fly logs:

2024-05-05T11:23:06Z app[568300dc794008] gru [info]11:23:06.153 [info] Running Example.Endpoint with cowboy 2.12.0 at 127.0.0.1:4000 (http)
2024-05-05T11:23:06Z app[568300dc794008] gru [info]11:23:06.158 [info] Access Example.Endpoint at http://localhost:4000
2024-05-05T11:23:07Z proxy[568300dc794008] gru [error][PC01] instance refused connection. is your app listening on 0.0.0.0:4000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-05-05T11:23:18Z proxy[568300dc794008] gru [error][PC01] instance refused connection. is your app listening on 0.0.0.0:4000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-05-05T11:23:29Z proxy[568300dc794008] gru [error][PC01] instance refused connection. is your app listening on 0.0.0.0:4000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-05-05T11:23:40Z proxy[568300dc794008] gru [error][PC01] instance refused connection. is your app listening on 0.0.0.0:4000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-05-05T11:23:50Z proxy[568300dc794008] gru [error][PC01] instance refused connection. is your app listening on 0.0.0.0:4000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-05-05T11:24:01Z proxy[568300dc794008] gru [error][PC01] instance refused connection. is your app listening on 0.0.0.0:4000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-05-05T11:24:12Z proxy[568300dc794008] gru [error][PC01] instance refused connection. is your app listening on 0.0.0.0:4000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-05-05T11:24:22Z proxy[568300dc794008] gru [error][PC01] instance refused connection. is your app listening on 0.0.0.0:4000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-05-05T11:24:33Z proxy[568300dc794008] gru [error][PC01] instance refused connection. is your app listening on 0.0.0.0:4000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)

The machine even stopped since no HTTP traffic was seen. Also starting it again will make it rebuild, I might look later on how not-to-build all time. Maybe a volume.

entering the machine and curl seems to work…

bugex on  main via 💧 v1.16.1
[I] ➜ fly ssh console
Connecting to fdaa:0:3335:a7b:1f60:2454:55c3:2... complete
root@568300dc794008:/app# apt update
Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Get:4 http://deb.debian.org/debian bullseye/main amd64 Packages [8,068 kB]
Get:5 http://deb.debian.org/debian-security bullseye-security/main amd64 Packages [271 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [18.8 kB]
Fetched 8,565 kB in 2s (5,030 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
26 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@568300dc794008:/app# apt install -y curl
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libcurl4
The following NEW packages will be installed:
  curl libcurl4
0 upgraded, 2 newly installed, 0 to remove and 26 not upgraded.
Need to get 618 kB of archives.
After this operation, 1,198 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 libcurl4 amd64 7.74.0-1.3+deb11u11 [347 kB]
Get:2 http://deb.debian.org/debian bullseye/main amd64 curl amd64 7.74.0-1.3+deb11u11 [271 kB]
Fetched 618 kB in 0s (11.0 MB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libcurl4:amd64.
(Reading database ... 18072 files and directories currently installed.)
Preparing to unpack .../libcurl4_7.74.0-1.3+deb11u11_amd64.deb ...
Unpacking libcurl4:amd64 (7.74.0-1.3+deb11u11) ...
Selecting previously unselected package curl.
Preparing to unpack .../curl_7.74.0-1.3+deb11u11_amd64.deb ...
Unpacking curl (7.74.0-1.3+deb11u11) ...
Setting up libcurl4:amd64 (7.74.0-1.3+deb11u11) ...
Setting up curl (7.74.0-1.3+deb11u11) ...
Processing triggers for libc-bin (2.31-13+deb11u4) ...
root@568300dc794008:/app# curl http://localhost:4000
<div data-phx-main data-phx-session="SFMyNTY.g2gDaAJhBXQAAAAIZAACaWRtAAAAFHBoeC1GOHlVZkx3d20tR3NaMFN4ZAAMbGl2ZV9zZXNzaW9uaAJkAAdkZWZhdWx0bggAjUA6J3CUzBdkAApwYXJlbnRfcGlkZAADbmlsZAAIcm9vdF9waWRkAANuaWxkAAlyb290X3ZpZXdkABdFbGl4aXIuRXhhbXBsZS5Ib21lTGl2ZWQABnJvdXRlcmQAFUVsaXhpci5FeGFtcGxlLlJvdXRlcmQAB3Nlc3Npb250AAAAAGQABHZpZXdkABdFbGl4aXIuRXhhbXBsZS5Ib21lTGl2ZW4GAEf4h0iPAWIAAVGA.3Xa5F9lsNPzBwO7t9rJBz4wwriF8djhR4n11gAPR7vY" data-phx-static="SFMyNTY.g2gDaAJhBXQAAAADZAAKYXNzaWduX25ld2pkAAVmbGFzaHQAAAAAZAACaWRtAAAAFHBoeC1GOHlVZkx3d20tR3NaMFN4bgYASPiHSI8BYgABUYA.DFxoVLlOua-8D0gaHoV8-bWcteiMW3q2AOVEBXJ6vjw" id="phx-F8yUfLwwm-GsZ0Sx"><script src="https://cdn.jsdelivr.net/npm/phoenix@1.7.12/priv/static/phoenix.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/phoenix_live_view@0.19.5/priv/static/phoenix_live_view.min.js"></script>
<script>
  let liveSocket = new window.LiveView.LiveSocket("/live", window.Phoenix.Socket)
  liveSocket.connect()
</script>
<style>
  * { font-size: 1.1em; }
</style>
0
<button phx-click="inc">+</button>
<button phx-click="dec">-</button></div>root@568300dc794008:/app# curl http://0.0.0.0:4000
<div data-phx-main data-phx-session="SFMyNTY.g2gDaAJhBXQAAAAIZAACaWRtAAAAFHBoeC1GOHlVZnRiZkFqdlh0a1RCZAAMbGl2ZV9zZXNzaW9uaAJkAAdkZWZhdWx0bggAjUA6J3CUzBdkAApwYXJlbnRfcGlkZAADbmlsZAAIcm9vdF9waWRkAANuaWxkAAlyb290X3ZpZXdkABdFbGl4aXIuRXhhbXBsZS5Ib21lTGl2ZWQABnJvdXRlcmQAFUVsaXhpci5FeGFtcGxlLlJvdXRlcmQAB3Nlc3Npb250AAAAAGQABHZpZXdkABdFbGl4aXIuRXhhbXBsZS5Ib21lTGl2ZW4GAJUbiEiPAWIAAVGA.q_ZLWC5AtQ00UeyGBm_Jc5mMJkqPywGHeQJFO0XR6Yc" data-phx-static="SFMyNTY.g2gDaAJhBXQAAAADZAAKYXNzaWduX25ld2pkAAVmbGFzaHQAAAAAZAACaWRtAAAAFHBoeC1GOHlVZnRiZkFqdlh0a1RCbgYAlRuISI8BYgABUYA.l3F8dHuYzkTq2wp1nuE4rAMaOyyfAF-aZUWtTbfol0k" id="phx-F8yUftbfAjvXtkTB"><script src="https://cdn.jsdelivr.net/npm/phoenix@1.7.12/priv/static/phoenix.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/phoenix_live_view@0.19.5/priv/static/phoenix_live_view.min.js"></script>
<script>
  let liveSocket = new window.LiveView.LiveSocket("/live", window.Phoenix.Socket)
  liveSocket.connect()
</script>
<style>
  * { font-size: 1.1em; }
</style>
0
<button phx-click="inc">+</button>
<button phx-click="dec">-</button></div>root@568300dc794008:/app#

Tried changing [http_service] to [services]. Same result

# [http_service]
# internal_port = 4000
# force_https = true
# auto_stop_machines = true
# auto_start_machines = true
# min_machines_running = 0
# processes = ['app']
#
[[services]]
internal_port = 4000
protocol = "tcp"
auto_stop_machines = false
auto_start_machines = true
min_machines_running = 0

[[services.ports]]
handlers = ["http"]
port = 80
force_https = true  # optional

[[services.ports]]
handlers = ["tls", "http"]
port = 443

Solved

Beginner’s mistake:

-   http: [ip: {127, 0, 0, 1}, port: 4000],
+   http: [ip: {0, 0, 0, 0}, port: 4000],

Also my toml is back to [http_service]

I should have trusted the logs :laughing:

https://bugex.fly.dev/ (I cant promise I wont have deleted this by the time you read it)

LiveView is not live because host check

2024-05-05T11:43:05Z app[568300dc794008] gru [info]11:43:05.113 [error] Could not check origin for Phoenix.Socket transport.
2024-05-05T11:43:05Z app[568300dc794008] gru [info]Origin of the request: https://bugex.fly.dev
2024-05-05T11:43:05Z app[568300dc794008] gru [info]This happens when you are attempting a socket connection to
2024-05-05T11:43:05Z app[568300dc794008] gru [info]a different host than the one configured in your config/
2024-05-05T11:43:05Z app[568300dc794008] gru [info]files. For example, in development the host is configured
2024-05-05T11:43:05Z app[568300dc794008] gru [info]to "localhost" but you may be trying to access it from
2024-05-05T11:43:05Z app[568300dc794008] gru [info]"127.0.0.1". To fix this issue, you may either:
2024-05-05T11:43:05Z app[568300dc794008] gru [info]  1. update [url: [host: ...]] to your actual host in the
2024-05-05T11:43:05Z app[568300dc794008] gru [info]     config file for your current environment (recommended)
2024-05-05T11:43:05Z app[568300dc794008] gru [info]  2. pass the :check_origin option when configuring your
2024-05-05T11:43:05Z app[568300dc794008] gru [info]     endpoint or when configuring the transport in your
2024-05-05T11:43:05Z app[568300dc794008] gru [info]     UserSocket module, explicitly outlining which origins
2024-05-05T11:43:05Z app[568300dc794008] gru [info]     are allowed:
2024-05-05T11:43:05Z app[568300dc794008] gru [info]        check_origin: ["https://example.com",
2024-05-05T11:43:05Z app[568300dc794008] gru [info]                       "//another.com:888", "//other.com"]

I know that for real prod you need to check_origin but whatever

Application.put_env(:sample, Example.Endpoint,
  http: [ip: {0, 0, 0, 0}, port: 4000],
  server: true,
  live_view: [signing_salt: "aaaaaaaa"],
-  secret_key_base: String.duplicate("a", 64)
+  secret_key_base: String.duplicate("a", 64),
+  check_origin: false
)

Time to do some bash

bugex on  main [?] via 💧 v1.16.1
[I] ➜ CODE=`cat bug.exs`

bugex on  main [?] via 💧 v1.16.1
[I] ➜ echo $CODE
Application.put_env(:sample, Example.Endpoint,
  http: [ip: {0, 0, 0, 0}, port: 4000],
  server: true,
  live_view: [signing_salt: "aaaaaaaa"],
  secret_key_base: String.duplicate("a", 64),
  check_origin: false
)
...

Created a run.sh

#!/bin/sh
echo $CODE

So far so good?

bugex on  main [?] via 💧 v1.16.1
[I] ➜ chmod +x run.sh

bugex on  main [?] via 💧 v1.16.1
[I] ➜ ./run.sh


bugex on  main [?] via 💧 v1.16.1
[I] ➜ CODE=`cat bug.exs` ./run.sh
Application.put_env(:sample, Example.Endpoint, http: [ip: {0, 0, 0, 0}, port: 4000], server: true, live_view: [signing_salt: "aaaaaaaa"], secret_key_base: String.duplicate("a", 64), check_origin: false ) Mix.install([ {:plug_cowboy, "~> 2.5"}, {:jason, "~> 1.0"}, {:phoenix, "~> 1.7.0"}, {:phoenix_live_view, "~> 0.19.0"} ]) defmodule Example.ErrorView do def render(template, _), do: Phoenix.Controller.status_message_from_template(template) end defmodule Example.HomeLive do use Phoenix.LiveView, layout: {__MODULE__, :live} def mount(_params, _session, socket) do {:ok, assign(socket, :count, 0)} end defp phx_vsn, do: Application.spec(:phoenix, :vsn) defp lv_vsn, do: Application.spec(:phoenix_live_view, :vsn) def render("live.html", assigns) do ~H""" <script src={"https://cdn.jsdelivr.net/npm/phoenix@#{phx_vsn()}/priv/static/phoenix.min.js"}></script> <script src={"https://cdn.jsdelivr.net/npm/phoenix_live_view@#{lv_vsn()}/priv/static/phoenix_live_view.min.js"}></script> <script> let liveSocket = new window.LiveView.LiveSocket("/live", window.Phoenix.Socket) liveSocket.connect() </script> <style> Dockerfile bug.exs fly.toml run.sh { font-size: 1.1em; } </style> <%= @inner_content %> """ end def render(assigns) do ~H""" <%= @count %> <button phx-click="inc">+</button> <button phx-click="dec">-</button> """ end def handle_event("inc", _params, socket) do {:noreply, assign(socket, :count, socket.assigns.count + 1)} end def handle_event("dec", _params, socket) do {:noreply, assign(socket, :count, socket.assigns.count - 1)} end end defmodule Example.Router do use Phoenix.Router import Phoenix.LiveView.Router pipeline :browser do plug(:accepts, ["html"]) end scope "/", Example do pipe_through(:browser) live("/", HomeLive, :index) end end defmodule Example.Endpoint do use Phoenix.Endpoint, otp_app: :sample socket("/live", Phoenix.LiveView.Socket) plug(Example.Router) end {:ok, _} = Supervisor.start_link([Example.Endpoint], strategy: :one_for_one) Process.sleep(:infinity)

Some tweaks

#!/bin/sh
TMPFILE=$(mktemp)
echo "$CODE" > $TMPFILE
elixir $TMPFILE
[I] ➜ CODE=`cat bug.exs` ./run.sh

08:57:47.139 [info] Running Example.Endpoint with cowboy 2.10.0 at 0.0.0.0:4000 (http)

08:57:47.140 [info] Access Example.Endpoint at http://localhost:4000

Nice!

I hope this works

bugex on  main [!+?] via 💧 v1.16.1 took 10s
[I] ➜ CODE=`cat bug.exs` fly secrets set CODE="$CODE" --stage
Secrets have been staged, but not set on VMs. Deploy or update machines in this app for the secrets to take effect.

Im using secrets just because I think its simple

Updated the Dockerfile

bugex on  main [!?] via 💧 v1.16.1
[I] ➜ g --no-pager diff
diff --git a/Dockerfile b/Dockerfile
index f6f2c94..3198930 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -17,11 +17,8 @@ ENV ERL_AFLAGS "-proto_dist inet6_tcp"

 WORKDIR "/app"

-# Copy our files over
-COPY bug.exs /app
-
 # install hex + rebar if you plan on using Mix.install
 RUN mix local.hex --force && \
     mix local.rebar --force

-CMD elixir /app/bug.exs
+CMD run.sh

And created a .dockerignore just in case:

bug.exs

Forgot to add run.sh :laughing:

Updating existing machines in 'bugex' with rolling strategy
Smoke checks for 568300dc794008 failed: the app appears to be crashing
Check its logs: here's the last lines below, or run 'fly logs -i 568300dc794008':
  Successfully prepared image registry.fly.io/bugex:deployment-01HX4A2Y35EJVJQP1XDGXHVSB4 (5.050909432s)
  Configuring firecracker
   INFO Sending signal SIGINT to main child process w/ PID 314
   INFO Sending signal SIGTERM to main child process w/ PID 314
   INFO Main child exited with signal (with signal 'SIGTERM', core dumped? false)
   INFO Starting clean up.
   WARN could not unmount /rootfs: EINVAL: Invalid argument
  [  134.525282] reboot: Restarting system
  [    0.049492] PCI: Fatal: No config space access function found
   INFO Starting init (commit: c1e2693b)...
   INFO Preparing to run: `/bin/sh -c run.sh` as root
   INFO [fly api proxy] listening at /.fly/api
  Machine created and started in 15.114s
  2024/05/05 12:02:37 INFO SSH listening listen_address=[fdaa:0:3335:a7b:1f60:2454:55c3:2]:22 dns_server=[fdaa::3]:53
  /bin/sh: 1: run.sh: not found
   INFO Main child exited normally with code: 127
   INFO Starting clean up.
   WARN could not unmount /rootfs: EINVAL: Invalid argument
  [    1.371941] reboot: Restarting system
  machine did not have a restart policy, defaulting to restart
  [    0.045843] PCI: Fatal: No config space access function found
   INFO Starting init (commit: c1e2693b)...
   INFO Preparing to run: `/bin/sh -c run.sh` as root
   INFO [fly api proxy] listening at /.fly/api
  Machine started in 524ms
  2024/05/05 12:02:39 INFO SSH listening listen_address=[fdaa:0:3335:a7b:1f60:2454:55c3:2]:22 dns_server=[fdaa::3]:53
  /bin/sh: 1: run.sh: not found
  [PC01] instance refused connection. is your app listening on 0.0.0.0:4000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
   INFO Main child exited normally with code: 127
   INFO Starting clean up.
   WARN could not unmount /rootfs: EINVAL: Invalid argument
  [    1.378800] reboot: Restarting system
  machine did not have a restart policy, defaulting to restart
  [    0.046061] PCI: Fatal: No config space access function found
   INFO Starting init (commit: c1e2693b)...
   INFO Preparing to run: `/bin/sh -c run.sh` as root
   INFO [fly api proxy] listening at /.fly/api
  Machine started in 510ms
  2024/05/05 12:02:40 INFO SSH listening listen_address=[fdaa:0:3335:a7b:1f60:2454:55c3:2]:22 dns_server=[fdaa::3]:53
  /bin/sh: 1: run.sh: not found
   INFO Main child exited normally with code: 127
   INFO S[    1.371581] reboot: Restarting system
  machine did not have a restart policy, defaulting to restart
  [    0.046433] PCI: Fatal: No config space access function found
   INFO Starting init (commit: c1e2693b)...
bugex on  main [!?] via 💧 v1.16.1
[I] ➜ g --no-pager diff
diff --git a/Dockerfile b/Dockerfile
index f6f2c94..5fa4721 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -18,10 +18,10 @@ ENV ERL_AFLAGS "-proto_dist inet6_tcp"
 WORKDIR "/app"

 # Copy our files over
-COPY bug.exs /app
+COPY run.sh /app

 # install hex + rebar if you plan on using Mix.install
 RUN mix local.hex --force && \
     mix local.rebar --force

-CMD elixir /app/bug.exs
+CMD /app/run.sh

https://bugex.fly.dev/ still works :laughing:

So this all works. TIME FOR OPTIMIZATIONS

I was looking at Fly Launch configuration (fly.toml) · Fly Docs because it might help simplify things and it would but my run.sh is so small so it seems no big deal?

Also I think I can cache builds using a volume and MIX_INSTALL_DIR but whatever I already solved what I wanted to solve :laughing:

From Phoenix to Show & Tell