matreyes

matreyes

Elixir slow in devcontainer (vscode and docker)

Just wanted to share my experience:

I was suffering with my elixir vscode devcontainer (docker) environment, because tests took ~20 seconds to start running.

I tried delegating the workspace:
- ..:/workspace:delegated
This makes the shared folder (between the container and the host) to write first on the container and to be eventually consistent with the host, so it doesn’t try to sync all the time.

At the beginning it worked, but sometime at the beginning of this year (2021) slowed down again.

Finally got with this amazing post by Marcus Baguley, that recommends to change the /deps and /_build folder to somewhere outside the workspace folder:

https://stories.abletech.nz/optimising-docker-for-mac-and-elixir-130db4ecd7c3

And now it works as expected.
Totally recommended for your dev environment!

Marked As Solved

matreyes

matreyes

Oh, I discovered that It was easier than what Marcus sugested
the env variables MIX_BUILD_ROOT and MIX_DEPS_PATH overrides build_path and deps_path, so you just have to add

environment:
    MIX_BUILD_ROOT: /opt/elixir-artifacts/_build
    MIX_DEPS_PATH: /opt/elixir-artifacts/deps
volumes:
    - elixir-artifacts:/opt/elixir-artifacts

to your docker-compose :slight_smile:

Also Liked

cnck1387

cnck1387

Another benefit besides speed from moving your build deps out of your volume mount path is that you will no longer have a bunch of dependencies volume mounted back to your dev box, so things stay tidy.

It’s also a discussion point in my upcoming DockerCon talk because this concept applies to other things too like node_modules/.

egze

egze

That’s cool. Thanks for sharing

quatermain

quatermain

Did you try .dockerignore file where you can put folders to ignore and Docker will not use them for loading?

matreyes

matreyes

Yes! Docker on Mac doesn’t shine.

user20230119

user20230119

If you’re on Windows, compiling was slow using bind mounts with Dev Container. I copied my workspace to a named volume and it run as fast as it does on the host.

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

We're in Beta

About us Mission Statement