Not using Phoenix, but just an Elixir app with cowboy, fly launch doesn't work!

When I try to deploy a very basic Elixir app with cowboy with fly launch it creates a fly.toml file like below. That is a very ancient and unsupported buildpack that doesn’t work at all anymore.

If I try making a blank Phoenix app and do fly launch it works perfectly, but it’s not super obvious what I need to do to make the basic Elixir app work.

# fly.toml app configuration file generated for ipfs-cdn-elixir on 2024-08-28T20:24:43-07:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'elixir-cowboy-app-test'
primary_region = 'sea'

[build]
  builder = 'heroku/buildpacks:20'
  buildpacks = ['https://cnb-shim.herokuapp.com/v1/hashnuke/elixir']

[env]
  PORT = '8080'

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

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

This is the error

[builder] Warning: Buildpack 'hashnuke/elixir@0.1' requests deprecated API '0.4'
[builder] Timer: Builder started at 2024-08-29T04:15:47Z
[builder]
[builder] #######################################################################
[builder]
[builder] ERROR: This buildpack is a legacy buildpack that has been shimmed
[builder] for compatibility with Cloud Native Buildpacks (CNBs) using the
[builder] cnb-shim service:
[builder] https://github.com/heroku/cnb-shim
[builder]
[builder] The cnb-shim service is not actively maintained and does not support
[builder] modern Buildpack API and lifecycle versions.
[builder]
[builder] In addition, the legacy builder images that use shimmed buildpacks
[builder] (such as 'heroku/buildpacks:20' or 'heroku/builder-classic:22') are
[builder] no longer supported and do not receive any security updates or fixes.
[builder]
[builder] Please switch to one of our newer 'heroku/builder:*' builder images:
[builder] https://github.com/heroku/cnb-builder-images#available-images
[builder]
[builder] If you are using the Pack CLI, you will need to adjust your '--builder'
[builder] CLI argument, or else change the default builder configuration using:
[builder] 'pack config default-builder <new_builder_name>'
[builder]
[builder] If you are using a third-party platform to deploy your app, check their
[builder] documentation for how to adjust the builder image used for your build.
[builder]
[builder] If you manually specify a cnb-shim buildpack URL (that refers to
[builder] 'cnb-shim.herokuapp.com') you will also need to update that to
[builder] the ID of a non-shimmed buildpack.
[builder]
[builder] See here for Heroku's supported CNB languages:
[builder] https://github.com/heroku/buildpacks#supported-languages
[builder]
[builder] Or search for community buildpacks here:
[builder] https://registry.buildpacks.io/
[builder]
[builder] To ignore this error, set the env var ALLOW_EOL_SHIMMED_BUILDER to 1.
[builder]
[builder] #######################################################################
[builder]
[builder] Timer: Builder ran for 8.34237ms and ended at 2024-08-29T04:15:47Z
[builder] ERROR: failed to build: exit status 1

Tried gigalixir with same app and it “just works” all I had to do was add a elixir_buildpack.config

I want to use fly though!

I noticed the basic Phoenix app did create a Dockerfile while the [build] section in the fly.toml was blank.

Modified Dockerfile to use in my case

ARG ELIXIR_VERSION=1.17.2
ARG OTP_VERSION=27.0.1
ARG DEBIAN_VERSION=bullseye-20240812-slim

ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"

FROM ${BUILDER_IMAGE} as builder

# install build dependencies
RUN apt-get update -y && apt-get install -y build-essential git \
    && apt-get clean && rm -f /var/lib/apt/lists/*_*

# prepare build dir
WORKDIR /app

# install hex + rebar
RUN mix local.hex --force && \
    mix local.rebar --force

# set build ENV
ENV MIX_ENV="prod"

# install mix dependencies
COPY mix.exs mix.lock ./
RUN mix deps.get --only $MIX_ENV
RUN mix deps.compile

# copy source files
COPY lib lib
COPY config config

# Compile the release
RUN mix compile
RUN mix release

# start a new build stage so that the final image will only contain
# the compiled release and other runtime necessities
FROM ${RUNNER_IMAGE}

RUN apt-get update -y && \
  apt-get install -y libstdc++6 openssl libncurses5 locales ca-certificates \
  && apt-get clean && rm -f /var/lib/apt/lists/*_*

# Set the locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

WORKDIR "/app"
RUN chown nobody /app

# set runner ENV
ENV MIX_ENV="prod"

# Only copy the final release from the build stage
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/my_app_name ./

USER nobody

CMD ["/app/bin/my_app_name", "start"]

Working now!

Added elixir

From Phoenix to Questions / Help

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.