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

Compile error for javafx on alpine docker #12717

Closed
Susucre opened this issue Aug 24, 2024 · 10 comments
Closed

Compile error for javafx on alpine docker #12717

Susucre opened this issue Aug 24, 2024 · 10 comments
Assignees
Labels

Comments

@Susucre
Copy link
Contributor

Susucre commented Aug 24, 2024

I'm compiling the project on an amaretto docker. The recent changes have broken the build.

It seems that the javafx introduced for the what's new dialog is causing issue:

image

Is there a version not strict enough in one of the pom.xml file?

@Susucre
Copy link
Contributor Author

Susucre commented Aug 24, 2024

On second thought, is that a java 11 / java 8 discrepency?

@JayDi85
Copy link
Member

JayDi85 commented Aug 24, 2024

52 - java 8
54 - java 10

Xmage uses JavaFX 11 — it’s compatible with java 8. I’m testing it with diff versions of OpenJDK (adoptium: https://adoptium.net/ ).

Maybe your system has another default java (not 8). Try check your JAVA_HOME and maven’s java version from here: https://stackoverflow.com/a/65290634

@Susucre
Copy link
Contributor Author

Susucre commented Aug 24, 2024

I think I'm setup properly:

image

I compile and bundle with the following docker file:

FROM amazoncorretto:8-alpine

ENV JAVA_MIN_MEMORY=768M \
    JAVA_MAX_MEMORY=1536M \
    GLIBC_VERSION=2.27-r0 \
    GLIBC_REPO=https://github.com/sgerrand/alpine-pkg-glibc \
    LANG=C.UTF-8

RUN set -ex && \
    apk upgrade --update && \
    apk add --update \
        bash \
        procps \
        curl \
        tar \
        perl \
        perl-utils \
        perl-app-cpanminus \
        make \
        git \
        gcompat

ENV PERL_PATH=/perl/
ENV PERL5LIB=$PERL_PATH:$PERL_PATH/lib/perl5:$PERL5LIB
RUN cpanm --notest -l $PERL_PATH \
        Archive::Extract \
        Archive::Zip

# common for all images
ENV MAVEN_HOME /usr/share/maven

COPY --from=maven:3.9.6-eclipse-temurin-11 ${MAVEN_HOME} ${MAVEN_HOME}
COPY --from=maven:3.9.6-eclipse-temurin-11 /usr/local/bin/mvn-entrypoint.sh /usr/local/bin/mvn-entrypoint.sh
COPY --from=maven:3.9.6-eclipse-temurin-11 /usr/share/maven/ref/settings-docker.xml /usr/share/maven/ref/settings-docker.xml

RUN ln -s ${MAVEN_HOME}/bin/mvn /usr/bin/mvn

ARG MAVEN_VERSION=3.9.6
ARG USER_HOME_DIR="/root"
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"

RUN git clone https://github.com/Susucre/mage.git
WORKDIR /mage
RUN git fetch
RUN git config --global user.email "[email protected]"
RUN git config --global user.name "noname"
RUN git checkout origin/master

WORKDIR /mage/Utils
RUN perl build-and-package.pl

(Then I extract the mage-bundle.jar and use it in another docker)

My current workaround is to remove everything about the what's new button. Since everything else is compiling correctly, I do suspect a mis-configuration on xmage's side, not the docker.

@JayDi85 JayDi85 self-assigned this Aug 24, 2024
@JayDi85 JayDi85 added the dev label Aug 24, 2024
@xenohedron
Copy link
Contributor

I don't think the "what's new" page is worth adding javafx back as a dependency. Removing javafx was a good call and it should be removed again.

@JayDi85
Copy link
Member

JayDi85 commented Aug 24, 2024

Nope, it was bad. No more removes.

@xenohedron
Copy link
Contributor

Nope, it was bad. No more removes.

I don't understand your point.

@JayDi85
Copy link
Member

JayDi85 commented Aug 27, 2024

Release files must be build with oracle's java 8 (xmage's default java) or another distr with javafx like zulu.

Here are fully workable docker image and script to build release files on linux systems. Warning, it's just a proof of concept and not production ready.

How-to use:

  1. Prepare machine with 4GB memory and installed docker (it's a minimum system requirements to build project);
  2. Create working folder for docker and temp files:
  • mkdir /xmage
  • cd /xmage
  1. Create project builder as Dockerfile:
  • nano Dockerfile
  • insert docker file content and save
FROM odinuge/maven-javafx:3-jdk-8

RUN echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list

# additional tools
RUN apt update && apt install -y \
                    build-essential

RUN echo "MAVEN_OPTS='-Xmx3g'" > ~/.mavenrc

WORKDIR /mage
ENTRYPOINT ["/bin/sh", "-c"]
  1. Make sure no temp files exists (on second+ running):
  • rm -rf temp
  • echo temp > .dockerignore
  1. Build docker image:
  • docker build -t mage/builder .
  1. Clone repo to temp folder:
  • docker run --rm -it -v "$(pwd)/temp":/mage mage/builder "git clone https://github.com/magefree/mage.git ."
  1. Build project and put prepared zip-files in temp/deploy folder:
  • docker run --rm -it -v "$(pwd)/temp":/mage mage/builder "make install"
  1. All done, files ready:
  • shot_240827_230338

P.S. Parent docker image already has maven and all needed tools. Also it contains perl, but without exported archive/extract and other features (it required by perl build script). That's why I used make tools instead, but it can be modified to use perl too (see old docker script above with cpanminus install commands).

@Grath
Copy link
Contributor

Grath commented Aug 27, 2024

But why do we need to go back to having a dependency on JavaFX in the first place? This adds complexity to building, releasing, and developing (it broke my ability to compile within IntelliJ, because I don't have JavaFX in the SDK in IntelliJ) for a very tiny upside (opening the "what's new?" page inside the client on some systems, rather than a browser window - but it's broken on Macs so it opens in a browser window there.)

@JayDi85
Copy link
Member

JayDi85 commented Aug 27, 2024

it broke my ability to compile within IntelliJ

Use oracle’s jdk 8 or openjdk 11+ like adoption/temurin. No needs in pom or source file changes, it’s fully compatible.

@JayDi85
Copy link
Member

JayDi85 commented Sep 3, 2024

Closed due workable scripts above.

For devs: if some build tools failed on diff IDEs, OSes, JDKs or environments then report new issue about it to find a possible solution.

@JayDi85 JayDi85 closed this as completed Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants