Yuanbo Han
Yuanbo Han

Reputation: 75

Syntax Error With Erlang 20.2

I encountered a wired problem with Erlang 20 .

I use rebar3 as prod tar to generate an archived file and I use this to build an docker image based on erlang:20.2-alpine.

On my Macbook Pro, it is ok to call bin/app start but on the target docker container, it tells me: erts-9.2/bin/erlexec: line 1: syntax error: unexpected "("

Erlang on my Macbook Pro:

erl
Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V9.2  (abort with ^G)

Erlang on the target container:

erl
Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V9.2  (abort with ^G)```

Upvotes: 2

Views: 631

Answers (2)

groksrc
groksrc

Reputation: 3025

Tldr; Add a .dockerignore file to your project that ignores the _build directory.

I had this problem today. Like @steve-vinoski mentioned in the comments, it did have to do with the fact that I was running a macOS output in the container but like @yuanbo-han, I too am building the release in the Dockerfile so I couldn't figure out why it wasn't working.

Then I realized, I had a COPY . . directive in my Dockerfile that was picking up the output from my mac because I didn't have a .dockerignore in place. The solution was to add the following .dockerignore file to the root of the project:

_build/
.elixir_ls/
.git/
.vscode/
deps/
priv/static/
test/
.dockerignore
.env
.formatter.exs
.gitignore
.travis.yml
Dockerfile
README.md

Upvotes: 8

Yuanbo Han
Yuanbo Han

Reputation: 75

I reference docker erlang, use docker to directly build release and target image.

Upvotes: 0

Related Questions