carlossg / docker-maven

Official Docker image with Maven
Apache License 2.0
515 stars 422 forks source link

Set JAVA_HOME manually for amazoncorretto-debian images #454

Closed anirbanmu closed 3 months ago

anirbanmu commented 3 months ago

Fixes https://github.com/carlossg/docker-maven/issues/452

I ended up doing it via a symlink of the deduced java home because sadly it seems you cannot use the result of running a shell command as the value for an ENV directive. See this issue.

carlossg commented 3 months ago

Isn't java home a known constant directory after package installation?

anirbanmu commented 3 months ago

Isn't java home a known constant directory after package installation?

It should be mostly constant I'd think. I did it this way just in case the package installation decides to change the directory in the future.

If you think this is overkill, I can just hardcode the specific paths for each Corretto version? let me know, and I can push up an update.

anirbanmu commented 3 months ago

Actually went ahead and changed the PR to just use hardcoded paths for JAVA_HOME. I think the simplicity is worth it and If it breaks in the future, we can fix it.

carlossg commented 3 months ago

the gpg removal is flaky, failing often with

#9 6.753 Running hooks in /etc/ca-certificates/update.d...
#9 6.754 done.
#9 6.778 gpg: keybox '/tmp/tmp.R31HI6uizI/pubring.kbx' created
#9 6.782   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#9 6.782                                  Dload  Upload   Total   Spent    Left  Speed
#9 6.782 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  1695  100  1695    0     0   7522      0 --:--:-- --:--:-- --:--:--  7533
#9 7.010 gpg: /tmp/tmp.R31HI6uizI/trustdb.gpg: trustdb created
#9 7.010 gpg: key A122542AB04F24E3: public key "Amazon Services LLC (Amazon Corretto release) <corretto-team@amazon.com>" imported
#9 7.014 gpg: Total number processed: 1
#9 7.014 gpg:               imported: 1
#9 7.018 rm: cannot remove '/tmp/tmp.R31HI6uizI/S.gpg-agent.extra': No such file or directory
#9 ERROR: process "/bin/sh -c apt-get update   && apt-get install -y curl gnupg   && export GNUPGHOME=\"$(mktemp -d)\"   && curl -fL https://apt.corretto.aws/corretto.key | gpg --batch --import   && gpg --batch --export '6DC3636DAE534049C8B94623A122542AB04F24E3' > /usr/share/keyrings/corretto.gpg   && rm -r \"$GNUPGHOME\"   && unset GNUPGHOME   && echo \"deb [signed-by=/usr/share/keyrings/corretto.gpg] https://apt.corretto.aws/ stable main\" > /etc/apt/sources.list.d/corretto.list   && apt-get update   && apt-get remove --purge --autoremove -y curl gnupg   && apt-get install -y java-1.8.0-amazon-corretto-jdk   && rm -rf /var/lib/apt/lists/*" did not complete successfully: exit code: 1