Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elixir nixpack shouldn't run migrations in build step #1078

Open
1 task done
bianchidotdev opened this issue Mar 22, 2024 · 1 comment
Open
1 task done

Elixir nixpack shouldn't run migrations in build step #1078

bianchidotdev opened this issue Mar 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@bianchidotdev
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The default elixir buildpack tries to run migrations during the docker build. I might be missing some common use case, but I can't imagine wanting to run migrations during the image building. I checked a few other languages, and they don't seem to have similar behavior.

To reproduce

Create a new phoenix app (assuming elixir and phoenix are installed):

mix phx.new hello
cd hello
nixpacks build ./

# output
 => ERROR [12/14] RUN  mix ecto.migrate                                                                                            0.5s
------
 > [12/14] RUN  mix ecto.migrate:
0.211 warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
0.473 ** (RuntimeError) environment variable DATABASE_URL is missing.
0.473 For example: ecto://USER:PASS@HOST/DATABASE
0.473
0.473     /app/config/runtime.exs:26: (file)
0.473     (stdlib 4.3.1.2) erl_eval.erl:748: :erl_eval.do_apply/7
0.473     (stdlib 4.3.1.2) erl_eval.erl:492: :erl_eval.expr/6
0.473     (stdlib 4.3.1.2) erl_eval.erl:136: :erl_eval.exprs/6
0.473     (elixir 1.14.5) lib/code.ex:425: Code.validated_eval_string/3
------
Dockerfile:27
--------------------
  25 |     RUN  mix compile
  26 |     RUN  mix assets.deploy
  27 | >>> RUN  mix ecto.migrate
  28 |     RUN  mix run priv/repo/seeds.exs
  29 |
--------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c mix ecto.migrate" did not complete successfully: exit code: 1
Error: Docker build failed

The following nixpacks.toml fixes this:

[phases.build]
cmds = ["mix compile", "mix assets.deploy"]

Expected behavior

Don't run migrations and seeds during the build step. Maybe not at all. Python ran migrations in the start step which might make sense, but I'm not sure what the best behavior is.

Environment

Mac OS Sonoma 14.4
Nixpacks v1.21.2

@bianchidotdev bianchidotdev added the bug Something isn't working label Mar 22, 2024
@jiangplus
Copy link

I run into the same issue. Migrations shouldn't be run on docker build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants