I have a feeling most of that time was uploading a very-large image from scratch. It looks like the buildpack was cached on your builder, too, so that’s best case for the buildpack.
I’m curious what happens if you run it a second time?
Giant images are a problem with nixpacks. We’re thinking about how to optimize that.
Ran it again. Job took 3m 57s this time around. But that is both the build and deploy times combined, so it is unclear for this discussion about just the build times.
Configuring firecracker
Starting virtual machine
Starting init (commit: c86b3dc)...
Setting up swapspace version 1, size = 512 MiB (536866816 bytes)
no label, UUID=a5f22059-3b19-44fa-9bb1-cfa54407e1fd
Preparing to run: `/app/bin/migrate` as root
Error: UnhandledIoError(Os { code: 2, kind: NotFound, message: "No such file or directory" })
[ 0.131206] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
[ 0.132337] CPU: 0 PID: 1 Comm: init Not tainted 5.12.2 #1
[ 0.133006] Call Trace:
[ 0.133264] show_stack+0x52/0x58
[ 0.133619] dump_stack+0x6b/0x86
[ 0.133976] panic+0xfb/0x2bc
[ 0.134359] do_exit.cold+0x60/0xb0
[ 0.134672] do_group_exit+0x3b/0xb0
[ 0.135046] __x64_sys_exit_group+0x18/0x20
[ 0.135462] do_syscall_64+0x38/0x50
[ 0.135820] entry_SYSCALL_64_after_hwframe+0x44/0xae
[ 0.136330] RIP: 0033:0x6ff9c5
[ 0.136837] Code: eb ef 48 8b 76 28 e9 76 05 00 00 64 48 8b 04 25 00 00 00 00 48 8b b0 b0 00 00 00 e9 af ff ff ff 48 63 ff b8 e7 00 00 00 0f 05 <ba> 3c 00 00 00 48 89 d0 0f 05 eb f9 66 2e 0f 1f 84 00 00 00 00 00
[ 0.138637] RSP: 002b:00007ffc720824a8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
[ 0.139413] RAX: ffffffffffffffda RBX: 00000000004f0ed0 RCX: 00000000006ff9c5
[ 0.140112] RDX: 00000000009cf4c0 RSI: 0000000000000000 RDI: 0000000000000001
[ 0.140825] RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000000
[ 0.141569] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffc72082508
[ 0.142294] R13: 00007ffc72082518 R14: 0000000000000000 R15: 0000000000000000
[ 0.143058] Kernel Offset: disabled
[ 0.143420] Rebooting in 1 seconds..
==> Monitoring deployment
v5 is being deployed
699237cc: mia pending
699237cc: mia running healthy
699237cc: mia running unhealthy [health checks: 1 total]
699237cc: mia running unhealthy [health checks: 1 total]
Failed Instances
Failure #1
--> v5 failed - Failed due to unhealthy allocations - rolling back to job version 4 and deploying as v6
Instance
ID PROCESS VERSION REGION DESIRED STATUS HEALTH CHECKS RESTARTS CREATED
699237cc 5 mia run running 1 total 2 15s ago
--> Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/
Error abort
Recent Events
TIMESTAMP TYPE MESSAGE
2022-08-10T04:48:09Z Received Task received by client
2022-08-10T04:48:09Z Task Setup Building Task Directory
2022-08-10T04:48:11Z Started Task started by client
2022-08-10T04:48:13Z Terminated Exit Code: 0
2022-08-10T04:48:13Z Restarting Task restarting in 1.190761974s
2022-08-10T04:48:19Z Started Task started by client
2022-08-10T04:48:21Z Terminated Exit Code: 0
2022-08-10T04:48:21Z Restarting Task restarting in 1.224775359s
2022-08-10T04:48:27Z Started Task started by client
2022-08-10T04:48:11Z [info]Starting virtual machine
2022-08-10T04:48:11Z [info]Starting init (commit: c86b3dc)...
2022-08-10T04:48:11Z [info]Preparing to run: `bash` as root
2022-08-10T04:48:11Z [info]2022/08/10 04:48:11 listening on [fdaa:0:570e:a7b:2c00:6992:37cc:2]:22 (DNS: [fdaa::3]:53)
2022-08-10T04:48:12Z [info]Main child exited normally with code: 0
2022-08-10T04:48:12Z [info]Starting clean up.
2022-08-10T04:48:18Z [info]Starting instance
2022-08-10T04:48:18Z [info]Configuring virtual machine
2022-08-10T04:48:18Z [info]Pulling container image
2022-08-10T04:48:19Z [info]Unpacking image
2022-08-10T04:48:19Z [info]Preparing kernel init
2022-08-10T04:48:19Z [info]Configuring firecracker
2022-08-10T04:48:19Z [info]Starting virtual machine
2022-08-10T04:48:19Z [info]Starting init (commit: c86b3dc)...
2022-08-10T04:48:19Z [info]Preparing to run: `bash` as root
2022-08-10T04:48:19Z [info]2022/08/10 04:48:19 listening on [fdaa:0:570e:a7b:2c00:6992:37cc:2]:22 (DNS: [fdaa::3]:53)
2022-08-10T04:48:20Z [info]Main child exited normally with code: 0
2022-08-10T04:48:20Z [info]Starting clean up.
2022-08-10T04:48:26Z [info]Starting instance
2022-08-10T04:48:27Z [info]Configuring virtual machine
2022-08-10T04:48:27Z [info]Pulling container image
2022-08-10T04:48:27Z [info]Unpacking image
2022-08-10T04:48:27Z [info]Preparing kernel init
2022-08-10T04:48:27Z [info]Configuring firecracker
2022-08-10T04:48:27Z [info]Starting virtual machine
2022-08-10T04:48:27Z [info]Starting init (commit: c86b3dc)...
2022-08-10T04:48:27Z [info]Preparing to run: `bash` as root
2022-08-10T04:48:27Z [info]2022/08/10 04:48:27 listening on [fdaa:0:570e:a7b:2c00:6992:37cc:2]:22 (DNS: [fdaa::3]:53)
2022-08-10T04:48:28Z [info]Main child exited normally with code: 0
2022-08-10T04:48:28Z [info]Starting clean up.
Error: Process completed with exit code 1.
My Dockerfile:
# Find eligible builder and runner images on Docker Hub. We use Ubuntu/Debian instead of
# Alpine to avoid DNS resolution issues in production.
#
# https://hub.docker.com/r/hexpm/elixir/tags?page=1&name=ubuntu
# https://hub.docker.com/_/ubuntu?tab=tags
#
#
# This file is based on these images:
#
# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image
# - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20210902-slim - for the release image
# - https://pkgs.org/ - resource for finding needed packages
# - Ex: hexpm/elixir:1.13.4-erlang-24.3.4-debian-bullseye-20210902-slim
#
ARG ELIXIR_VERSION=1.13.4
ARG OTP_VERSION=24.3.4
ARG DEBIAN_VERSION=bullseye-20210902-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 mkdir config
# copy compile-time config files before we compile dependencies
# to ensure any relevant config change will trigger the dependencies
# to be re-compiled.
COPY config/config.exs config/${MIX_ENV}.exs config/
RUN mix deps.compile
COPY priv priv
COPY lib lib
COPY assets assets
# compile assets
RUN mix assets.deploy
# Compile the release
RUN mix compile
# Changes to config/runtime.exs don't require recompiling the code
COPY config/runtime.exs config/
COPY rel rel
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 \
&& 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/nuki ./
USER nobody
CMD ["/app/bin/server"]
# Appended by flyctl
ENV ECTO_IPV6 true
ENV ERL_AFLAGS "-proto_dist inet6_tcp"
Keep in mind, this was totally autogenerated by fly launch, I didn’t edit this file at all.
How can I pass configuration to nixpacks for things like additional libraries? I don’t see any way to pass the --libs flag and none of the options I can think of for trying to pass the NIXPACKS_LIBS env var (or NIXPACKS_APT_PKGS) have any effect.
I tried setting the env vars before invoking flyctl deploy, I tried passing --env, I tried passing --build-arg, I even tried --build-secret, none of them worked. I also tried putting it in fly.toml in the [env] section though I assume that’s identical to the --env flag.
I’ve made a pre-release that should pass-through all env vars prefixed with NIXPACKS_ to the nixpacks command.
Depending on how you installed flyctl to begin with, you have a few options:
If you installed via homebrew (if you’re on macos), then it might be easier to download the release binary from: Release v0.0.388-pre-1 · superfly/flyctl · GitHub and just running that like ./flyctl.
If you’ve installed it from our install script via curl, you can do: curl -L https://fly.io/install.sh | sh -s pre to get a prerelease.
My initial build context transfer went from 74MB to 2-300MB before even getting started on the build. This step is quite slow when done on a 20Mbit/sec uplink.
I have a bun/nextjs app and it tried to run npm ci as an added step from the nixpack. This failed, even though my Dockerfile’s first step is to install nodejs and npm. So for me, nixpacks are not currently viable. As a side note, I’m also testing Railway and encounter other problems trying to manually specify my build steps in my Dockerfile, so maybe I’m not using it right in the first place.