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

Multi-platform Fuseki images #2949

Open
namedgraph opened this issue Jan 14, 2025 · 4 comments · May be fixed by #2957
Open

Multi-platform Fuseki images #2949

namedgraph opened this issue Jan 14, 2025 · 4 comments · May be fixed by #2957
Labels
enhancement Incrementally add new feature

Comments

@namedgraph
Copy link
Contributor

namedgraph commented Jan 14, 2025

Version

4.7.0

Feature

The current Dockerfile does not build on my Mac M1, presumably because the eclipse-temurin:${JAVA_VERSION}-alpine base image is not multi-platform.

I was able to build on M1 using the Dockerfile below but it's probably far from optimal.

## Apache Jena Fuseki server Dockerfile.

## This Dockefile builds a reduced footprint container.

ARG JAVA_VERSION=17

ARG ALPINE_VERSION=3.17.1
ARG JENA_VERSION=4.7.0

# Internal, passed between stages.
ARG FUSEKI_DIR=/fuseki
ARG FUSEKI_JAR=jena-fuseki-server-${JENA_VERSION}.jar

## ---- Stage: Download and build java.
FROM eclipse-temurin:${JAVA_VERSION} AS base

ARG JENA_VERSION
ARG FUSEKI_DIR
ARG FUSEKI_JAR
ARG REPO=https://repo1.maven.org/maven2
ARG JAR_URL=${REPO}/org/apache/jena/jena-fuseki-server/${JENA_VERSION}/${FUSEKI_JAR}

RUN [ "${JENA_VERSION}" != "" ] || { echo -e '\n**** Set JENA_VERSION ****\n' ; exit 1 ; }
RUN echo && echo "==== Docker build for Apache Jena Fuseki ${JENA_VERSION} ====" && echo

## -- Fuseki installed and runs in /fuseki.
WORKDIR $FUSEKI_DIR

## -- Download the jar file.
COPY download.sh .
RUN chmod a+x download.sh

# Download, with check of the SHA1 checksum.
RUN ./download.sh --chksum sha1 "$JAR_URL"

## -- Alternatives to download : copy already downloaded.
## COPY ${FUSEKI_JAR} .

## Use Docker ADD - does not retry, does not check checksum, and may run every build.
## ADD "$JAR_URL"

ADD entrypoint.sh .
ADD log4j2.properties .

## ---- Stage: Build runtime
FROM eclipse-temurin:${JAVA_VERSION}

## Import ARGs
ARG JENA_VERSION
ARG JAVA_MINIMAL
ARG FUSEKI_DIR
ARG FUSEKI_JAR

#COPY --from=base /opt/java/openjdk /opt/java/openjdk
COPY --from=base /fuseki /fuseki

WORKDIR $FUSEKI_DIR

ARG LOGS=${FUSEKI_DIR}/logs
ARG DATA=${FUSEKI_DIR}/databases

ARG JENA_USER=fuseki
ARG JENA_GROUP=$JENA_USER
ARG JENA_UID=2000
ARG JENA_GID=2000

# Run as this user
# -H : no home directory
# -D : no password
RUN groupadd --gid "${JENA_GID}" "${JENA_GROUP}" && \
    useradd --uid "${JENA_UID}" --gid "${JENA_GID}" --shell /bin/bash --no-create-home "${JENA_USER}"

RUN mkdir --parents "${FUSEKI_DIR}" && \
    chown -R $JENA_USER ${FUSEKI_DIR}

USER $JENA_USER

RUN \
    mkdir -p $LOGS && \
    mkdir -p $DATA && \
    chmod a+x entrypoint.sh

## Default environment variables.
ENV \
    JAVA_HOME=/opt/java/openjdk    \
    JAVA_OPTIONS="-Xmx2048m -Xms2048m"  \
    JENA_VERSION=${JENA_VERSION}        \
    FUSEKI_JAR="${FUSEKI_JAR}"          \
    FUSEKI_DIR="${FUSEKI_DIR}"

EXPOSE 3030

ENTRYPOINT ["./entrypoint.sh" ]
CMD []

Are you interested in contributing a solution yourself?

None

@namedgraph namedgraph added the enhancement Incrementally add new feature label Jan 14, 2025
@rvesse
Copy link
Member

rvesse commented Jan 14, 2025

Can you provide specific error messages you encounter when building on a M1 Mac?

There are definitely eclipse-temurin variants that can be used to build multi-platform images on M1 Mac's because I build such images for my $dayjob

It may simply be a case of updating the target JAVA_VERSION in the Dockerfile?

A quick look on Docker Hub shows that eclipse-temurin:17-alpine was only built for linux/amd64 whereas eclipse-temurin:21-alpine has linux/amd64 and linux/arm/v8 builds available

@namedgraph
Copy link
Contributor Author

namedgraph commented Jan 14, 2025

With eclipse-temurin:17-alpine base:

Martynas.Jusevicius@MartynasJusevicius-MacBook-Pro fuseki-docker % docker-compose build                 
[+] Building 1.5s (3/3) FINISHED                                                                                                                                                                                                                                              
 => [fuseki internal] load build definition from Dockerfile                                                                                                                                                                                                              0.0s
 => => transferring dockerfile: 3.57kB                                                                                                                                                                                                                                   0.0s
 => [fuseki internal] load metadata for docker.io/library/alpine:3.17.1                                                                                                                                                                                                  1.3s
 => ERROR [fuseki internal] load metadata for docker.io/library/eclipse-temurin:17-alpine                                                                                                                                                                                1.4s
------
 > [fuseki internal] load metadata for docker.io/library/eclipse-temurin:17-alpine:
------
failed to solve: eclipse-temurin:17-alpine: failed to resolve source metadata for docker.io/library/eclipse-temurin:17-alpine: no match for platform in manifest: not found

@namedgraph
Copy link
Contributor Author

Seems to build fine with eclipse-temurin:21-alpine and the original Dockerfile :)

@afs
Copy link
Member

afs commented Jan 15, 2025

Please send in a PR to update the Dockerfile to Java21, and Alpine, that is tested on Mac's.

@namedgraph namedgraph linked a pull request Jan 15, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Incrementally add new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants