Unexpected error while executing my app
scorsi opened this issue · comments
Hi,
I've created a Dockerfile for my phoenix application.
My app is built using mix release
thanks to the distillery
package.
Here is my Dockerfile:
FROM elixir:1.6-alpine
ENV API_VERSION 0.0.1
ENV MIX_HOST 8080
RUN mkdir /app && \
apk --no-cache add tar bash
COPY ./archives/api_${API_VERSION}.tar.gz /app/api.tar.gz
RUN cd /app && \
tar -zxvf /app/api.tar.gz && \
rm /app/api.tar.gz && \
apk del tar && \
rm -rf /var/cache/apk/*
WORKDIR /app/releases/${API_VERSION}
EXPOSE $MIX_HOST
VOLUME /app
CMD ["./api.sh", "foreground"]
But I got the following error:
/app/erts-9.3.1/bin/erlexec: line 1: syntax error: unexpected "("
While it's perfectly working on my host machine.
Do you have any idea ?
Thanks,
the erlexec
should be a binary but its content got a shell script? some shelling debugging technique may apply, like CMD ["sh", "-x", "./api.sh", "foreground"]
? and you can some head lines of the api.sh
?
Hi,
Yeah erlexec
is a binary, the api.sh
seems well formatted and is auto-generated by destillery
.
I just changed my Dockerfile as above:
FROM alpine:3.8
RUN mkdir -p /app && \
apk --no-cache add elixir && \
apk --update --no-cache add erlang-runtime-tools && \
mix local.hex --force && \
mix local.rebar --force
VOLUME ["/app"]
WORKDIR "/app"
EXPOSE 4000
CMD ["iex"]
I mount my elixir app into the /app
folder and then run mix phx.server
.
I forgot the destillery
package for the moment.
I think something is missing to properly execute the bundled app inside the dockerfile.
I got this error building on OSX M1 chip. Running file
command on erlexec
show that it is build for ARM architecture even withing Docker container.
If you on ARM processor aka. Mac M1 go to Docker Setting -> Experimental and enable Use New Virtualization Framework
This will add new docker buildx
command.
Now build your image with Docker like so
docker buildx build --platform linux/amd64 -t my_image_tag .