Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nokogiri on arm64 alpine #5414

Merged
merged 1 commit into from Jan 29, 2022
Merged

Fix nokogiri on arm64 alpine #5414

merged 1 commit into from Jan 29, 2022

Conversation

dlpierce
Copy link
Contributor

The nokogori gem when used in alpine linux on the arm64 platform does not provide compatible precompiled binaries. The gcompat package allows the binaries compoiled for glibc to work.

Changes proposed in this pull request:

  • Add gcompat package to the Dockerfile in the hyrax-base image

Guidance for testing, such as acceptance criteria or new user interface behaviors:

  • docker-compose build is successful on an arm64 computer such as an M1 Mac

@samvera/hyrax-code-reviewers

@marrus-sh
Copy link
Collaborator

when i tried to get glibc to work in alpine linux (as part of #5314) i found that the gcompat package was not sufficient, and had to go with the more involved solution here:

hyrax/Dockerfile

Lines 29 to 101 in 3d46276

# BEGIN GLIBC SUPPORT STUFF
# -------------------------
# Alpine Linux does not ship with glibc support so we have to add it ourselves.
# The following RUN statement is copy‐pasted from `frolvlad/alpine-glibc` which
# is the base image used by `denoland/deno:alpine`.
#
# <https://github.com/denoland/deno/issues/3711> tracks proper musl binaries for
# Deno, which would eliminate the need for this whole section.
ENV LANG=C.UTF-8
# The following license applies to the RUN statement which immediately follows.
#
# The MIT License (MIT)
#
# Copyright (c) 2015 Vlad
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
RUN ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases/download" && \
ALPINE_GLIBC_PACKAGE_VERSION="2.33-r0" && \
ALPINE_GLIBC_BASE_PACKAGE_FILENAME="glibc-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
ALPINE_GLIBC_BIN_PACKAGE_FILENAME="glibc-bin-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
ALPINE_GLIBC_I18N_PACKAGE_FILENAME="glibc-i18n-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
apk add --no-cache --virtual=.build-dependencies wget ca-certificates && \
echo \
"-----BEGIN PUBLIC KEY-----\
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApZ2u1KJKUu/fW4A25y9m\
y70AGEa/J3Wi5ibNVGNn1gT1r0VfgeWd0pUybS4UmcHdiNzxJPgoWQhV2SSW1JYu\
tOqKZF5QSN6X937PTUpNBjUvLtTQ1ve1fp39uf/lEXPpFpOPL88LKnDBgbh7wkCp\
m2KzLVGChf83MS0ShL6G9EQIAUxLm99VpgRjwqTQ/KfzGtpke1wqws4au0Ab4qPY\
KXvMLSPLUp7cfulWvhmZSegr5AdhNw5KNizPqCJT8ZrGvgHypXyiFvvAH5YRtSsc\
Zvo9GI2e2MaZyo9/lvb+LbLEJZKEQckqRj4P26gmASrZEPStwc+yqy1ShHLA0j6m\
1QIDAQAB\
-----END PUBLIC KEY-----" | sed 's/ */\n/g' > "/etc/apk/keys/sgerrand.rsa.pub" && \
wget \
"$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \
apk add --no-cache \
"$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \
\
rm "/etc/apk/keys/sgerrand.rsa.pub" && \
(/usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 "$LANG" || true) && \
echo "export LANG=$LANG" > /etc/profile.d/locale.sh && \
\
apk del glibc-i18n && \
\
rm "/root/.wget-hsts" && \
apk del .build-dependencies && \
rm \
"$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_I18N_PACKAGE_FILENAME"
# END GLIBC SUPPORT STUFF

if gcompat works for nokogiri, good! but i figured i’d mention it here in case it doesn’t…

i know in conversations during the tech call @no-reply mentioned possibly revisiting the decision to use Alpine Linux for everything, and if it is posing a problem for M1 development, that might be a compelling reason for doing so?

@dlpierce
Copy link
Contributor Author

Using gcompat is nokogiri's suggested solution, but I would be happy switching away from alpine too.

@no-reply
Copy link
Member

let's move forward with gcompat for the moment. if it's not sufficient, we can always consider a bigger change later.

@no-reply no-reply merged commit 01606e3 into main Jan 29, 2022
@no-reply no-reply deleted the fix_arm64_nokogiri branch January 29, 2022 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants