Docker file for phoenix 1.5 version throwing error

I just created a new phx 1.5 project and ran this docker file.

Below is my docker file

FROM bitwalker/alpine-elixir-phoenix:latest as releaser

#Copy the source folder into the Docker image
COPY . .

# Install Hex + Rebar
RUN mix do local.hex --force, local.rebar --force

RUN MIX_ENV=prod mix do deps.get, compile
RUN mix phx.digest

RUN MIX_ENV=prod mix release

########################################################################

FROM bitwalker/alpine-elixir-phoenix:latest

EXPOSE 4000
ENV PORT=4000 \
    MIX_ENV=prod

WORKDIR /app

COPY --from=releaser /app/releases/my_poc ./
COPY --from=releaser /app/priv/static/ ./priv/static/


ENTRYPOINT ["./bin/my_poc"]
CMD ["foreground"]

when I run

docker build -t my_poc .

I am getting the below error


Step 11/14 : COPY --from=releaser /app/releases/my_poc ./
COPY failed: stat /var/lib/docker/overlay2/8b4e7d41689f3e622239f2ea05e472d519a9492bb9464513483f7246911a083a/merged/app/releases/my_poc: no such file or directory

Can anyone give me insight on what mistake I am doing here and to fix it?

Your help will be greatly appreciated. Thanks.

Try to replace with:

COPY . /some-folder

Probably the folder would be the same you use later in the Dockerfile: /app

1 Like

I tried this now it is throwing this error

COPY . /app

** (Mix) Could not find a Mix.Project, please ensure you are running Mix in a directory with a mix.exs file

Then I added

COPY . /app
WORKDIR /app

Now it ends with this error

> Step 12/15 : COPY --from=releaser /app/releases/my_poc ./
> COPY failed: stat /var/lib/docker/overlay2/f0e78db20dfe100e87aa309619d6003dbb7aabc0c7d46667bb2fee53d691b5af/merged/app/releases/ogre_poc: no such file or directory

My full Docker file now

FROM bitwalker/alpine-elixir-phoenix:latest as releaser

#Copy the source folder into the Docker image
COPY . /app
WORKDIR /app
# Install Hex + Rebar
RUN mix do local.hex --force, local.rebar --force

RUN MIX_ENV=prod mix do deps.get, compile
RUN mix phx.digest

RUN MIX_ENV=prod mix release

########################################################################

FROM bitwalker/alpine-elixir-phoenix:latest

EXPOSE 4000
ENV PORT=4000 \
    MIX_ENV=prod

WORKDIR /app

COPY --from=releaser /app/releases/my_poc ./
COPY --from=releaser /app/priv/static/ ./priv/static/


ENTRYPOINT ["./bin/my_poc"]
CMD ["foreground"]

Here is the working version of my Docker image file. Please check and give your valuable feddback incase of any improvements

FROM bitwalker/alpine-elixir-phoenix:latest as releaser

WORKDIR /app

# Cache elixir deps
ADD mix.exs mix.lock ./
RUN MIX_ENV=prod mix do deps.get, deps.compile

# Same with npm deps
ADD assets/package.json assets/
RUN cd assets && \
    npm install

ADD . .

# Run frontend build, compile, and digest assets
RUN cd assets/ && \
    npm run deploy && \
    cd - && \
    mix do compile, phx.digest


RUN MIX_ENV=prod mix release

########################################################################

FROM bitwalker/alpine-elixir-phoenix:latest

EXPOSE 4000
ENV PORT=4000 \
    MIX_ENV=prod

WORKDIR /app

COPY --from=releaser /app/_build/prod/rel/my_poc /app
COPY --from=releaser /app/priv/ /app/priv/
RUN ls /app/priv/static

ENTRYPOINT ["./bin/my_poc"]
CMD ["start"]