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?

Last Post!

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

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31525 112
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42576 114
New

We're in Beta

About us Mission Statement