|
| 1 | +FROM debian:bullseye-slim AS build |
| 2 | + |
| 3 | +SHELL ["/bin/bash", "-o", "pipefail", "-c"] |
| 4 | +COPY ./docker/apt/sources.list /etc/apt/ |
| 5 | + |
| 6 | +# Install build dependencies |
| 7 | +RUN apt-get update && apt-get install -y -qq \ |
| 8 | + wget \ |
| 9 | + git \ |
| 10 | + build-essential \ |
| 11 | + libncurses5-dev \ |
| 12 | + automake \ |
| 13 | + autoconf \ |
| 14 | + curl \ |
| 15 | + ca-certificates \ |
| 16 | + libssl-dev \ |
| 17 | + libreadline-dev \ |
| 18 | + libdpkg-perl \ |
| 19 | + liberror-perl \ |
| 20 | + libc6 \ |
| 21 | + libc-dev \ |
| 22 | + perl \ |
| 23 | + procps \ |
| 24 | + inotify-tools \ |
| 25 | + libssl1.1 \ |
| 26 | + perl-base \ |
| 27 | + zlib1g-dev \ |
| 28 | + libncurses-dev \ |
| 29 | + libsctp-dev \ |
| 30 | + xsltproc \ |
| 31 | + libxml2-utils \ |
| 32 | + && apt-get clean \ |
| 33 | + && rm -rf /var/lib/apt/lists/* |
| 34 | + |
| 35 | +# Set environment variables for Erlang build |
| 36 | +ENV KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac --without-wx --without-odbc --disable-hipe --without-jinterface --without-docs" |
| 37 | +ENV KERL_BUILD_DOCS="no" |
| 38 | +ENV KERL_DOC_TARGETS="" |
| 39 | +ENV KERL_INSTALL_HTMLDOCS="no" |
| 40 | +ENV KERL_INSTALL_MANPAGES="no" |
| 41 | + |
| 42 | +RUN git clone https://github.com/asdf-vm/asdf.git --branch v0.6.3 "$HOME"/.asdf && \ |
| 43 | + echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.bashrc && \ |
| 44 | + echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.profile |
| 45 | + |
| 46 | +ENV PATH="${PATH}:/root/.asdf/shims:/root/.asdf/bin" |
| 47 | + |
| 48 | +RUN mkdir -p /opt/erlang/epp_proxy |
| 49 | +WORKDIR /opt/erlang/epp_proxy |
| 50 | + |
| 51 | +COPY .tool-versions ./ |
| 52 | +RUN asdf plugin-add erlang |
| 53 | +RUN ERLANG_VERSION=$(grep erlang .tool-versions | cut -d' ' -f2) && \ |
| 54 | + . $HOME/.asdf/asdf.sh && asdf install erlang $ERLANG_VERSION |
| 55 | +RUN asdf global erlang $(grep erlang .tool-versions | cut -d' ' -f2) |
| 56 | +RUN asdf plugin-add rebar |
| 57 | +RUN REBAR_VERSION=$(grep rebar .tool-versions | cut -d' ' -f2) && \ |
| 58 | + . $HOME/.asdf/asdf.sh && asdf install rebar $REBAR_VERSION |
| 59 | +RUN asdf global rebar $(grep rebar .tool-versions | cut -d' ' -f2) |
| 60 | + |
| 61 | +# Copy application files |
| 62 | +COPY rebar.config rebar.lock ./ |
| 63 | +COPY config ./config |
| 64 | +COPY apps ./apps |
| 65 | + |
| 66 | +# Build the release |
| 67 | +RUN . $HOME/.asdf/asdf.sh && rebar3 as prod release |
| 68 | + |
| 69 | +# Second stage: runtime image |
| 70 | +FROM debian:bullseye-slim |
| 71 | + |
| 72 | +# Install runtime dependencies only |
| 73 | +RUN apt-get update && apt-get install -y -qq \ |
| 74 | + libssl1.1 \ |
| 75 | + libncurses6 \ |
| 76 | + libsctp1 \ |
| 77 | + procps \ |
| 78 | + && apt-get clean \ |
| 79 | + && rm -rf /var/lib/apt/lists/* |
| 80 | + |
| 81 | +# Create app directory |
| 82 | +RUN mkdir -p /opt/erlang/epp_proxy |
| 83 | +WORKDIR /opt/erlang/epp_proxy |
| 84 | + |
| 85 | +# Copy the release from the build stage |
| 86 | +COPY --from=build /opt/erlang/epp_proxy/_build/prod/rel/epp_proxy ./ |
| 87 | + |
| 88 | +# Create a non-root user to run the application |
| 89 | +RUN groupadd -r epp && useradd -r -g epp epp |
| 90 | +RUN chown -R epp:epp /opt/erlang/epp_proxy |
| 91 | +USER epp |
| 92 | + |
| 93 | +# Expose the EPP port |
| 94 | +EXPOSE 700 |
| 95 | + |
| 96 | +# Set environment variables |
| 97 | +ENV RELX_REPLACE_OS_VARS=true |
| 98 | +ENV NODE_NAME=epp_proxy@127.0.0.1 |
| 99 | + |
| 100 | +# Health check |
| 101 | +# HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ |
| 102 | +# CMD ps aux | grep "beam" | grep -v grep || exit 1 |
| 103 | + |
| 104 | +# Command to run the application |
| 105 | +CMD ["./bin/epp_proxy", "foreground"] |
0 commit comments