tino415

tino415

Hello all,

today I had interesting problem in our CI/CD pipeline. We set up pipeline so in one container was run mix deps.get, MIX_ENV=test mix deps.compile and MIX_ENV=test mix compile then we copied _build and deps folder to other container and run mix test there. Problem was that after running migrations tests failed on error:

** (Mix) Could not start application ranch: exited in: :ranch_app.start(:normal, []) 00:06
744    ** (EXIT) an exception was raised: 00:06
745        ** (UndefinedFunctionError) function :ranch_app.start/2 is undefined (module :ranch_app is not available) 00:06
746            (ranch 1.8.0) :ranch_app.start(:normal, []) 00:06
747            (kernel 8.3.2.3) application_master.erl:293: :application_master.start_it_old/4

Which got resolved by running MIX_ENV=test mix deps.compile on testing machine. My question is why is that? Is that somehow avoidable? On localhost I never had to run MIX_ENV=test mix deps.compile or MIX_ENV=test mix compile to be able to run mix test and deps.compile takes a lot of time and noticeably slowing down our pipeline.

Showing Posts 1 to 10

BradS2S

BradS2S

So you might be conflating mix test which just runs all the tests in whatever env you are in with the test environment.

My bet would be that your other container has different config settings / different env. So when you take files compiled for one configuration and run it in another you are going to have a bad time.

Look in your mix.exs file and I’m guessing the ranch dependency is set to not be included in test env.

dimitarvp

dimitarvp

Your description is a bit confusing. What’s your goal? Running mix test on a separate, dedicated, VM/machine?

tino415

tino415 OP

It is actually semaphoreci and they are running separate build process steps in separate docker containers, I think it is similar to running multistage dockerfile

tino415

tino415 OP

I tried to verify this and:

  • ranch is in copied deps folder
  • test is in copied _build
  • there is _build/test/lib/ranch/ebin/ranch.app
  • error persists even when running MIX_ENV=test mix test

Am I missing something?

BradS2S

BradS2S

It isn’t best practices to copy the _buikd folder and move it. I’m not sure I follow you completely.

dimitarvp

dimitarvp

Okay, I get that, but I don’t think straight up copying files is how it’s done. Utilizing multi-stage builds you should be able to just base one image on another. Though I am not sure how does that work with distributing work among different nodes, haven’t tried it.

cjbottaro

cjbottaro

Our CI pipeline actually pushes the built Docker image to a registry.

So we have two jobs:

build -> test

The build job creates the image (compiling both prod and test) and pushes it to an image repo, then the test job pulls down the image and runs a container using a command like mix test. If the test job passes, then we’re all ready to deploy to prod since the image is already in a repository.

Complexity arises when you want to cache your deps, which drastically speeds up the build process.

tino415

tino415 OP

I don’t have control over docker files, have only limited api to copy stuff between build steps. Maybe should not compare it to multi stage build. Lets say I have no control over dockerfiles and docker stuff lets say I have simple api where I can define build steps, which every run in different docker container (I even have limited control which image is used) and then I have api to copy files between build steps.

tino415

tino415 OP

Yes, but that is not usable in this case, actually we build docker image only on master on prod pipeline, on feature branches I prefer speed.

tino415

tino415 OP

I work with what I have. Nov it works, could be 40 seconds faster, but works. But still I would like to know what is going on? Maybe there are some other files that are required to copy to replicate builded project?

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews