GithubHelp home page GithubHelp logo

alpine-elixir's Introduction

Elixir on Alpine Linux

This Dockerfile provides a full installation of Erlang and Elixir on Alpine, intended for running releases, so it has no build tools installed. The Erlang installation is provided so one can avoid cross-compiling releases. The caveat of course is if one has NIFs which require a native compilation toolchain, but that is left as an exercise for the reader.

Usage

NOTE: This image sets up a default user, with home set to /opt/app and owned by that user. The working directory is also set to $HOME. It is highly recommended that you add a USER default instruction to the end of your Dockerfile so that your app runs in a non-elevated context.

To boot straight to a prompt in the image:

$ docker run --rm -it --user=root bitwalker/alpine-elixir iex
Erlang/OTP XX [erts-X.X] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

Interactive Elixir (<version>) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>

Extending for your own application:

FROM bitwalker/alpine-elixir:latest

# Set exposed ports
EXPOSE 5000
ENV PORT=5000

ENV MIX_ENV=prod

COPY yourapp.tar.gz ./
RUN tar -xzvf yourapp.tar.gz

USER default

CMD ./bin/yourapp foreground

License

MIT

alpine-elixir's People

Contributors

almirsarajcic avatar binaryseed avatar bitwalker avatar cschiewek avatar doughsay avatar drmartinberger avatar edennis avatar ericentin avatar flowerett avatar gazler avatar gmile avatar hopeshigh avatar hopsor avatar mcasper avatar minhajuddin avatar mustardnoise avatar optikfluffel avatar prodis avatar rlthompson-godaddy avatar rupurt avatar zblanco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alpine-elixir's Issues

Question: Image sizes

Hi,

I'm just looking at the image sizes for the empty containers:

$ docker images
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
bitwalker/alpine-elixir   latest              d814edb83fe0        4 days ago          144MB
bitwalker/alpine-erlang   latest              e5c5ce95529b        7 days ago          120MB

This is Java-size :)

Many people were reporting significantly smaller sizes so I'm trying to understand if this is normal?

version 1.12.2 not building any more.

The following DockerFile is no longer building on several machines.

It fails on theRUN command following the # Install NPM comment with the error

#13 18.22 ERROR: http://dl-cdn.alpinelinux.org/alpine/edge/main: UNTRUSTED signature

Bumping docker image version to 1.13.4 fixes the problem.

From my sparse understanding of Alpine and Docker, it appears that some dependencies have likely been shuffled between repos, but I don't know enough to fix this problem without spending more time than I have.

Is there a simple fix, or do you recommend going with 1.13.x

FROM bitwalker/alpine-elixir:1.12.2 AS phx-builder
RUN mix local.hex --force && mix local.rebar --force

# Important!  Update this no-op ENV variable when this Dockerfile
# is updated with the current date. It will force refresh of all
# of the base images and things like `apt-get update` won't be using
# old cached versions when the Dockerfile is built.
ENV REFRESHED_AT=2019-07-31

# Install NPM
RUN \
    mkdir -p /opt/app && \
    chmod -R 777 /opt/app && \
    apk update && \
    apk --no-cache --update add \
      make \
      g++ \
      wget \
      curl \
      inotify-tools \
      nodejs \
      npm && \
    npm install npm -g --no-progress && \
    update-ca-certificates --fresh && \
    rm -rf /var/cache/apk/*

# Add local node module binaries to PATH
ENV PATH=./node_modules/.bin:$PATH

# Ensure latest versions of Hex/Rebar are installed on build
ONBUILD RUN mix do local.hex --force, local.rebar --force
WORKDIR /opt/app

ENV MIX_ENV=prod

# Cache elixir deps
ADD mix.exs mix.lock ./
RUN 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 mix do compile, assets.deploy && \
    mix release --force

FROM alpine:3.13.5

EXPOSE 4000
ENV PORT=4000 MIX_ENV=prod

ENV LANG=en_US.UTF-8 \
    HOME=/opt/app/ \
    # Set this so that CTRL+G works properly
    TERM=xterm \
    PATH=/opt/app/bin:/usr/local/bin:${PATH}

RUN apk add --no-cache libstdc++    

RUN \
    # Create default user and home directory, set owner to default
    adduser -s /bin/sh -u 1001 -G root -h "${HOME}" -S -D default && \
    chown -R 1001:0 "${HOME}" && \
    # Add tagged repos as well as the edge repo so that we can selectively install edge packages
    echo "@main http://dl-cdn.alpinelinux.org/alpine/v3.10/main" >> /etc/apk/repositories && \
    echo "@community http://dl-cdn.alpinelinux.org/alpine/v3.10/community" >> /etc/apk/repositories && \
    echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \
    # Upgrade Alpine and base packages
    apk --no-cache --update --available upgrade && \
    # Install bash and Erlang/OTP deps
    apk add --no-cache --update pcre@edge && \
    apk add --no-cache --update \
      imagemagick \
      bash \
      ca-certificates \
      openssl \
      ncurses \
      unixodbc \
      zlib && \
    # Update ca certificates
    update-ca-certificates --fresh     

COPY --from=phx-builder /opt/app/_build/prod/rel/pay .

COPY --from=phx-builder /opt/app/priv/fonts/* /usr/share/fonts/

CMD cd /opt/app && pay eval "Pay.Release.migrate()" && pay start

SSH agent forwarding is not working with the latest image

With docker 18.09, I can build image and forward the ssh socket from host to container, so the container would not contain any ssh credential.

Run docker build with --ssh flag

> eval $(ssh-agent -s)
> ssh-add ~/.ssh/id_rsa
> DOCKER_BUILDKIT=1 docker build --progress=plain --ssh default .

with this Dockerfile, and the agent forwarding doesn't work

# syntax=docker/dockerfile:experimental

FROM bitwalker/alpine-elixir:1.8.1

RUN echo "......... start building image ............"

RUN apk add --no-cache openssh-client git
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
RUN --mount=type=ssh git clone [email protected]:organization/project.git

The ssh agent forwarding doesn't work and throws an error Host key verification failed..

However, it works properly with latest alpine.

# syntax=docker/dockerfile:experimental

FROM alpine:3.9

RUN echo "......... start building image ............"

RUN apk add --no-cache openssh-client git
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
RUN --mount=type=ssh git clone [email protected]:organization/project.git

The base image of alpine-elixir is alpine-erlang, and latest alpine-erlang uses alpine:3.9 as it's base. Thanks for your consideration.

libstdc++

My releases won't run without libstdc++.

Error loading shared library libstdc++.so.6: No such file or directory (needed by /opt/app/my_app/erts-12.2.1/bin/beam.smp)
Error loading shared library libgcc_s.so.1: No such file or directory (needed by /opt/app/my_app/erts-12.2.1/bin/beam.smp)

This temporary solution works.

FROM bitwalker/alpine-erlang:latest
RUN apk add --allow-untrusted --no-cache libstdc++

Probably libstdc++ should be part of bitwalker/alpine-erlang ?

Build and push 1.6

I see the repo's been updated to 1.6, but the 1.6 image hasn't been built and pushed. Any chance we could get that done?

Thanks!

Manifest not found error for 1.9.1

I'm just starting on the Docker & Releases journey. I get:

Step 1/7 : FROM bitwalker/alpine-elixir:1.9.1 as build
manifest for bitwalker/alpine-elixir:1.9.1 not found

with the following Dockerfile

FROM bitwalker/alpine-elixir:1.9.1 as build

COPY config ./config
COPY lib ./lib
COPY priv ./priv
COPY mix.exs .
COPY mix.lock .


RUN export MIX_ENV=prod && \
    mix deps.get && \
    mix release

using 1.9 instead of 1.9.1 works normally

1.11.3 released

Any plans on making latest to be 1.11.3 ?
also please create 1.11.3 as tag since we sometimes need to fix versions instead of using :latest

apk add build-base fails with musl-1.1.19-r10:

My ci was working fine but Thursday morning this error starting showing up, I have not made any changes to cause this.




$ apk add build-base
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
fetch http://nl.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  musl-1.1.19-r10:
    breaks: musl-dev-1.1.19-r11[musl=1.1.19-r11]
    satisfies:
               musl-utils-1.1.19-r10[musl=1.1.19-r10]
               musl-utils-1.1.19-r10[so:libc.musl-x86_64.so.1]
               pkgconf-1.5.1-r0[so:libc.musl-x86_64.so.1]
               gcc-6.4.0-r9[so:libc.musl-x86_64.so.1]
               libcrypto1.0-1.0.2o-r2[so:libc.musl-x86_64.so.1]
               g++-6.4.0-r9[so:libc.musl-x86_64.so.1]
               readline-7.0.003-r0[so:libc.musl-x86_64.so.1]
               bash-4.4.19-r1[so:libc.musl-x86_64.so.1]
               ca-certificates-20171114-r3[so:libc.musl-x86_64.so.1]
               busybox-1.28.4-r1[so:libc.musl-x86_64.so.1]
               binutils-2.30-r5[so:libc.musl-x86_64.so.1]
               mpfr3-3.1.5-r1[so:libc.musl-x86_64.so.1]
               ncurses-libs-6.1-r0[so:libc.musl-x86_64.so.1]
               expat-2.2.5-r0[so:libc.musl-x86_64.so.1]
               git-2.18.0-r0[so:libc.musl-x86_64.so.1]
               nghttp2-libs-1.32.0-r0[so:libc.musl-x86_64.so.1]
               libstdc++-6.4.0-r9[so:libc.musl-x86_64.so.1]
               file-5.32-r1[so:libc.musl-x86_64.so.1]
               isl-0.18-r0[so:libc.musl-x86_64.so.1]
               libcurl-7.61.0-r0[so:libc.musl-x86_64.so.1]
               mpc1-1.0.3-r1[so:libc.musl-x86_64.so.1]
               libmagic-5.32-r1[so:libc.musl-x86_64.so.1]
               pcre-8.42-r0[so:libc.musl-x86_64.so.1]
               unixodbc-2.3.5-r0[so:libc.musl-x86_64.so.1]
               zlib-1.2.11-r1[so:libc.musl-x86_64.so.1]
               libgomp-6.4.0-r9[so:libc.musl-x86_64.so.1]
               apk-tools-2.10.0-r0[so:libc.musl-x86_64.so.1]
               libssh2-1.8.0-r3[so:libc.musl-x86_64.so.1]
               make-4.2.1-r2[so:libc.musl-x86_64.so.1]
               libressl2.7-libcrypto-2.7.4-r0[so:libc.musl-x86_64.so.1]
               libgcc-6.4.0-r9[so:libc.musl-x86_64.so.1]
               alpine-baselayout-3.1.0-r0[so:libc.musl-x86_64.so.1]
               libatomic-6.4.0-r9[so:libc.musl-x86_64.so.1]
               pcre2-10.31-r0[so:libc.musl-x86_64.so.1]
               scanelf-1.2.3-r0[so:libc.musl-x86_64.so.1]
               gmp-6.1.2-r1[so:libc.musl-x86_64.so.1]
               libressl2.7-libssl-2.7.4-r0[so:libc.musl-x86_64.so.1]
               libssl1.0-1.0.2o-r2[so:libc.musl-x86_64.so.1]

I have been wrestling with this for a few days and really need to solve this so i can push some code up, any help would be great!

Build version 1.9.4

So the PR to update to 1.9.4 was merged, a version was tagged with latest but we don't have a 1.9.4 tag.

Additional dependencies

Hello,
first thanks for your really good work. But how can I add some dependencies to your alpine docker image. Right know we need to add apk add erlang-xmerl but when I use it install also erlang 19 but we want to use 20. Is it possible to install so our pheonix app will see xmerl?

Publish dockerhub tag 1.11.1

Currently only 1.11.0 is published on dockerhub.

It would also be nice to add git tags for the releases. I can work on adding a Github action to automate this if you would like.

musl needs to be upgraded

Hi. Using alpine-elixir:1.4.5 and when I try to run apk add build-base, I get the following error:

# apk add build-base
ERROR: unsatisfiable constraints:
  musl-1.1.16-r10:
    breaks: musl-dev-1.1.16-r13[musl=1.1.16-r13]
    satisfies: musl-utils-1.1.16-r10[musl=1.1.16-r10] musl-utils-1.1.16-r10[so:libc.musl-x86_64.so.1] pkgconf-1.3.7-r0[so:libc.musl-x86_64.so.1] gcc-6.3.0-r4[so:libc.musl-x86_64.so.1] binutils-libs-2.28-r2[so:libc.musl-x86_64.so.1]
               libcrypto1.0-1.0.2k-r0[so:libc.musl-x86_64.so.1] g++-6.3.0-r4[so:libc.musl-x86_64.so.1] libressl2.5-libcrypto-2.5.4-r0[so:libc.musl-x86_64.so.1] readline-6.3.008-r5[so:libc.musl-x86_64.so.1]
               libressl2.5-libssl-2.5.4-r0[so:libc.musl-x86_64.so.1] mpfr3-3.1.5-r0[so:libc.musl-x86_64.so.1] ncurses-libs-6.0-r7[so:libc.musl-x86_64.so.1] libstdc++-6.3.0-r4[so:libc.musl-x86_64.so.1]
               isl-0.17.1-r0[so:libc.musl-x86_64.so.1] libcurl-7.54.0-r0[so:libc.musl-x86_64.so.1] mpc1-1.0.3-r0[so:libc.musl-x86_64.so.1] git-2.13.0-r0[so:libc.musl-x86_64.so.1] pcre-8.40-r2[so:libc.musl-x86_64.so.1]
               unixodbc-2.3.4-r0[so:libc.musl-x86_64.so.1] zlib-1.2.11-r0[so:libc.musl-x86_64.so.1] libgomp-6.3.0-r4[so:libc.musl-x86_64.so.1] apk-tools-2.7.2-r0[so:libc.musl-x86_64.so.1] libssh2-1.8.0-r1[so:libc.musl-x86_64.so.1]
               libgcc-6.3.0-r4[so:libc.musl-x86_64.so.1] make-4.2.1-r0[so:libc.musl-x86_64.so.1] alpine-baselayout-3.0.4-r0[so:libc.musl-x86_64.so.1] libatomic-6.3.0-r4[so:libc.musl-x86_64.so.1]
               ca-certificates-20161130-r2[so:libc.musl-x86_64.so.1] gmp-6.1.2-r0[so:libc.musl-x86_64.so.1] busybox-1.26.2-r5[so:libc.musl-x86_64.so.1] scanelf-1.2.2-r0[so:libc.musl-x86_64.so.1] expat-2.2.0-r1[so:libc.musl-x86_64.so.1]
               binutils-2.28-r2[so:libc.musl-x86_64.so.1] libssl1.0-1.0.2k-r0[so:libc.musl-x86_64.so.1]

Upgrade musl first fixes the problem. Not sure why.

Tags to fix version

We were using 1.9.1, but the upgrade to OTP 22.1 broke hackney, resulting in an outage on our servers. Would it be possible to have stable version tags? So a build to a specific point version would not have breaking changes?

Could not compile deps

Here is an error message I get when trying to compile deps for docker deployment:

** (Mix) Could not compile dependency :idna, "/opt/app/.mix/rebar3 bare compile --paths "/opt/app/_build/dev/lib/*/ebin"" command failed. You can recompile this dependency with "mix │<none>                            <none>              364d0d625acf        3 days ago          399 MB
deps.compile idna", update it with "mix deps.update idna" or clean it with "mix deps.clean idna"                                                                                      │<none>                            <none>              b7f9335a7f8a        3 days ago          349 MB
ERROR: Service 'XXXXXX' failed to build: The command '/bin/sh -c mix do deps.get, deps.compile # --only prod' returned a non-zero code: 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.