Hex Cannot Be Found on Dockerized Phoenix App when running on Drone

So I currently have a setup wherein I deploy my dockerized Phoenix application to run tests on a self hosted Drone server. Currently the issue arises that no matter what Dockerfile I use(currently alpine-elixir-phoenix or a base elixir image with the following) which installs hex/rebar like below:

# Install Hex+Rebar
    RUN mix local.hex --force && \
    mix local.rebar --force

I receive the error upon booting in Drone,

  • How to use docker-java API to connect docker?
  • how to install libcontainer docker in place of lxc-docker
  • Asp.net 5 - Docker
  • Docker daemon processes
  • Gitlab CI runner not able to expose ports of nested Docker containers
  • Upgrade docker on CentOS 7
  • Could not find Hex, which is needed to build dependency :phoenix

    I have found that by using an older version of alpine-elixir-phoenix:2.0 this issue does not come up which leads me to believe it may be something to do with hex/elixir having updated since then? Additionally if I run the commands to install hex and rebar within the container in Drone once it is instantiated there is no issue. I ran a whoami on the instantiated Drone container and the user is root if that makes a difference. Additionally if I run the container locally and run mix hex.info, it correctly states that hex is installed, however the issue is that on the Drone instantiated container this fails.

    Example .drone.yml:

    pipeline:
        backend_test:
        image: bitwalker/alpine-elixir-phoenix
            commands:
                - cd api
                - apk update
                - apk add postgresql-client
                - MIX_ENV=test mix local.hex --force
                - MIX_ENV=test mix local.rebar --force
                - MIX_ENV=test mix deps.get
                - MIX_ENV=test mix ecto.create
                - MIX_ENV=test mix ecto.migrate
                - mix test
    

    Example Docker File used(bitwalker/alpine-elixir-phoenix) – https://github.com/bitwalker/alpine-elixir-phoenix/blob/master/Dockerfile

    where the same installation of local.hex and local.rebar occurs in the Dockerfile on lines 29 && 30. However upon instantiation of the container it is not found and therefore must be run again in the CMDs.

    Furthermore I encountered this problem again but with make and g++ not installing on alpine. I may be doing something incorrect but I cannot see where.

    testbuild_env Dockerfile

    FROM bitwalker/alpine-erlang:19.2.1b
    ENV HOME=/opt/app/ TERM=xterm
    
    # Install Elixir and basic build dependencies
    RUN \
    echo "@edge http://nl.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
    apk update && \
    apk --no-cache --update add \
      git make g++ curl \
      elixir@edge=1.4.2-r0 && \
    rm -rf /var/cache/apk/*
    
    # Install Hex+Rebar
    RUN mix local.hex --force && \
    mix local.rebar --force
    
    ENV DOCKER_BUCKET test.docker.com
    ENV DOCKER_VERSION 17.05.0-ce-rc1
    ENV DOCKER_SHA256 4561742c2174c01ffd0679621b66d29f8a504240d79aa714f6c58348979d02c6
    
    RUN set -x \
    && curl -fSL "https://${DOCKER_BUCKET}/builds/Linux/x86_64/docker-${DOCKER_VERSION}.tgz" -o docker.tgz \
    && echo "${DOCKER_SHA256} *docker.tgz" | sha256sum -c - \
    && tar -xzvf docker.tgz \
    && mv docker/* /usr/local/bin/ \
    && rmdir docker \
    && rm docker.tgz \
    && docker -v
    
    COPY docker-entrypoint.sh /usr/local/bin/
    
    ENTRYPOINT ["docker-entrypoint.sh"]
    CMD ["sh"]
    

    with the following .drone.yml

    build:
        image: test_buildenv
        commands:
          - cd api
          - apk add make
          - apk add g++
          - MIX_ENV=test mix local.hex --force
          - MIX_ENV=test mix local.rebar --force
          - docker login --username USERNAME --password PASSWORD
          - mix docker.build # creates a release file after running a dockerfile.build image
          - mix docker.release # creates a minimalist image to run the release file that was just created
          - mix docker.publish # pushes newly created image to dokcerh
        volumes:
           - /var/run/docker.sock:/var/run/docker.sock
    

  • How to monitor host's filesystem in a dockerized Topbeat
  • Accessing gitlab inside docker container from local machine
  • docker cannot remove images?
  • About the concurrency of Docker
  • Docker-machine : ca.pem not found
  • Moving app to docker from host increases HTTP lag by 5 seconds
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.