Skip to content

Commit

Permalink
Patch Erlang build on Alpine
Browse files Browse the repository at this point in the history
Works around this issue: erlang/otp#9211
  • Loading branch information
lukebakken committed Dec 18, 2024
1 parent 16db9e1 commit 42543eb
Show file tree
Hide file tree
Showing 19 changed files with 178 additions and 40 deletions.
25 changes: 18 additions & 7 deletions 3.13/alpine/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
22 changes: 22 additions & 0 deletions 3.13/alpine/patch/otp/27.2/erts-configure.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- erts/configure.orig
+++ erts/configure
@@ -21677,6 +21677,7 @@
/* end confdefs.h. */

#include <stdlib.h>
+#include <unistd.h>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
@@ -25866,8 +25867,10 @@
e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

+#include <fcntl.h>
#include <poll.h>
-main()
+#include <stdlib.h>
+int main()
{
#ifdef _POLL_EMUL_H_
exit(1); /* Implemented using select() -- fail */
6 changes: 3 additions & 3 deletions 3.13/ubuntu/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 18 additions & 7 deletions 4.0/alpine/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
22 changes: 22 additions & 0 deletions 4.0/alpine/patch/otp/27.2/erts-configure.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- erts/configure.orig
+++ erts/configure
@@ -21677,6 +21677,7 @@
/* end confdefs.h. */

#include <stdlib.h>
+#include <unistd.h>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
@@ -25866,8 +25867,10 @@
e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

+#include <fcntl.h>
#include <poll.h>
-main()
+#include <stdlib.h>
+int main()
{
#ifdef _POLL_EMUL_H_
exit(1); /* Implemented using select() -- fail */
6 changes: 3 additions & 3 deletions 4.0/ubuntu/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 18 additions & 7 deletions 4.1-rc/alpine/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
22 changes: 22 additions & 0 deletions 4.1-rc/alpine/patch/otp/27.2/erts-configure.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- erts/configure.orig
+++ erts/configure
@@ -21677,6 +21677,7 @@
/* end confdefs.h. */

#include <stdlib.h>
+#include <unistd.h>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
@@ -25866,8 +25867,10 @@
e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

+#include <fcntl.h>
#include <poll.h>
-main()
+#include <stdlib.h>
+int main()
{
#ifdef _POLL_EMUL_H_
exit(1); /* Implemented using select() -- fail */
6 changes: 3 additions & 3 deletions 4.1-rc/ubuntu/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 18 additions & 7 deletions Dockerfile-alpine.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Alpine Linux is not officially supported by the RabbitMQ team -- use at your own risk!
FROM alpine:{{ .alpine.version }} as build-base
FROM alpine:{{ .alpine.version }} AS build-base

RUN apk add --no-cache \
build-base \
Expand All @@ -10,7 +10,7 @@ RUN apk add --no-cache \
linux-headers \
ncurses-dev

FROM build-base as openssl-builder
FROM build-base AS openssl-builder

ARG BUILDKIT_SBOM_SCAN_STAGE=true

Expand Down Expand Up @@ -117,19 +117,23 @@ RUN set -eux; \
# smoke test
RUN $OPENSSL_INSTALL_PATH_PREFIX/bin/openssl version

FROM openssl-builder as erlang-builder
FROM openssl-builder AS erlang-builder

ARG BUILDKIT_SBOM_SCAN_STAGE=true

RUN set -eux; \
# /usr/local/src doesn't exist in Alpine by default
mkdir -p /usr/local/src; \
\
RUN set -eux; \
OTP_PATH="/usr/local/src/otp-$OTP_VERSION"; \
mkdir -p "/usr/local/src/patch"; \
mkdir -p "$OTP_PATH"

COPY patch/ /usr/local/src/patch/

RUN set -eux; \
OTP_SOURCE_URL="https://github.com/erlang/otp/releases/download/OTP-$OTP_VERSION/otp_src_$OTP_VERSION.tar.gz"; \
OTP_PATH="/usr/local/src/otp-$OTP_VERSION"; \
\
# Download, verify & extract OTP_SOURCE
mkdir -p "$OTP_PATH"; \
wget --output-document "$OTP_PATH.tar.gz" "$OTP_SOURCE_URL"; \
echo "$OTP_SOURCE_SHA256 *$OTP_PATH.tar.gz" | sha256sum -c -; \
tar --extract --file "$OTP_PATH.tar.gz" --directory "$OTP_PATH" --strip-components 1; \
Expand All @@ -138,6 +142,13 @@ RUN set -eux; \
# https://erlang.org/doc/applications.html
# ERL_TOP is required for Erlang/OTP makefiles to find the absolute path for the installation
cd "$OTP_PATH"; \
if [ -d /usr/local/src/patch/otp/$OTP_VERSION ]; then \
for patch_file in /usr/local/src/patch/otp/$OTP_VERSION/*.patch; do \
if [ -f "$patch_file" ]; then \
patch -p0 < "$patch_file"; \
fi; \
done; \
fi; \
export ERL_TOP="$OTP_PATH"; \
export CFLAGS='-g -O2'; \
# add -rpath to avoid conflicts between our OpenSSL's "libssl.so" and the libssl package by making sure "$INSTALL_PATH_PREFIX/lib" is searched first (but only for Erlang/OpenSSL to avoid issues with other tools using libssl; https://github.com/docker-library/rabbitmq/issues/364)
Expand Down
Loading

0 comments on commit 42543eb

Please sign in to comment.