sethforprivacy / simple-monerod-docker

A simple and straightforward Dockerized monerod built from source and exposing standard ports.
https://sethforprivacy.com/guides/run-a-monero-node/
MIT License
98 stars 19 forks source link

fixuid breaks image #63

Closed samsapti closed 2 years ago

samsapti commented 2 years ago

After merging #62, my logs look like this:

$ docker-compose logs -f monerod
monerod  | /usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
monerod  | /usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
monerod  | /usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
monerod  | /usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
monerod  | /usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
monerod  | /usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
monerod  | /usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
monerod  | /usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
monerod  | /usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
monerod  | /usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
monerod exited with code 2

Adding user: "${FIXUID:-1000}:${FIXGID:-1000}" didn't help either. Image tag v0.17.3.2 works as expected.

This is on a Raspberry Pi 4B.

sethforprivacy commented 2 years ago

Ahhh, maybe fixuid doesn't support ARM on that binary... I'll work on a solution.

sethforprivacy commented 2 years ago

I've got a solution in mind, will push shortly.

sethforprivacy commented 2 years ago

Pushed a fix in https://github.com/sethforprivacy/simple-monerod-docker/commit/bb0836ffea6b0bce35981d29b121ab8dcd7f88de, please test ASAP once the image is pushed as I don't have an ARM device to test on.

sethforprivacy commented 2 years ago

@samsaptidev New image is pushed, please test and report back!

samsapti commented 2 years ago

@sethforprivacy Still doesn't work :(

sethforprivacy commented 2 years ago

@sethforprivacy Still doesn't work :(

Same error? Are you sure you pulled the latest?

samsapti commented 2 years ago

@sethforprivacy Yes, same error, I did pull the latest image.

$ docker-compose down
$ docker-compose pull
$ docker-compose up -d
samsapti commented 2 years ago

I do have an idea about what could be wrong though. I'll paste a diff below:

diff --git a/entrypoint.sh b/entrypoint.sh
index 2223794..6163c6e 100644
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -1,16 +1,16 @@
-#!/bin/ash
+#!/bin/sh
 # Credit for the bulk of this entrypoint script goes to cornfeedhobo
 # Source is https://github.com/cornfeedhobo/docker-monero/blob/master/entrypoint.sh
 set -e

 # Set require --non-interactive flag
-set -- monerod --non-interactive "$@"
+set -- "monerod" "--non-interactive" "$@"

 # Configure NUMA if present for improved performance
-numa='numactl --interleave=all'
-if $numa true &> /dev/null; then
-   set -- $numa "$@"
+if command -v numactl >/dev/null 2>&1; then
+    numa="numactl --interleave=all"
+    set -- "$numa" "$@"
 fi
 # Start the daemon using fixuid
 # to adjust permissions if needed
-exec fixuid -q "$@"
\ No newline at end of file
+exec fixuid -q "$@"

Basically, I've quoted some variables/strings and made the entrypoint.sh script POSIX compliant.

sethforprivacy commented 2 years ago

I do have an idea about what could be wrong though. I'll paste a diff below:


diff --git a/entrypoint.sh b/entrypoint.sh

index 2223794..6163c6e 100644

--- a/entrypoint.sh

+++ b/entrypoint.sh

@@ -1,16 +1,16 @@

-#!/bin/ash

+#!/bin/sh

 # Credit for the bulk of this entrypoint script goes to cornfeedhobo

 # Source is https://github.com/cornfeedhobo/docker-monero/blob/master/entrypoint.sh

 set -e

 # Set require --non-interactive flag

-set -- monerod --non-interactive "$@"

+set -- "monerod" "--non-interactive" "$@"

 # Configure NUMA if present for improved performance

-numa='numactl --interleave=all'

-if $numa true &> /dev/null; then

- set -- $numa "$@"

+if command -v numactl >/dev/null 2>&1; then

+    numa="numactl --interleave=all"

+    set -- "$numa" "$@"

 fi

 # Start the daemon using fixuid

 # to adjust permissions if needed

-exec fixuid -q "$@"

\ No newline at end of file

+exec fixuid -q "$@"

Basically, I've quoted some variables/strings and made the entrypoint.sh script POSIX compliant.

Great catch, if that works for you please PR it!

I'm traveling but can approve the PR and let the automatic builds push it.

samsapti commented 2 years ago

@sethforprivacy Maybe you could do that? I don't have time to build and push it myself.

samsapti commented 2 years ago

@sethforprivacy I've submitted a PR (#64).

sethforprivacy commented 2 years ago

@sethforprivacy I've submitted a PR (#64).

Thanks so much! Approved and running a test workflow before pushing a new image with the changes.

sethforprivacy commented 2 years ago

New image is building via https://github.com/sethforprivacy/simple-monerod-docker/runs/7529308323?check_suite_focus=true, should push within the next hour if you don't mind testing then.

sethforprivacy commented 2 years ago

@samsaptidev new image is live and working properly for me on amd64, please test on arm64 when you get the chance!

vdo commented 2 years ago

I just tried to install with xmr.sh in a RPi and I'm getting this bug (both with latest and v0.18.0.0):

root@raspberrypi:/opt/xmr.sh# docker logs monerod
/usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
/usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
/usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
/usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
/usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
/usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
/usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
/usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
/usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
root@raspberrypi:/opt/xmr.sh# docker ps | grep monerod
fbfbbfe78312   sethsimmons/simple-monerod:v0.18.0.0   "/entrypoint.sh --pu…"   58 seconds ago   Restarting (2) 19 seconds ago                                                                                  monerod
sethforprivacy commented 2 years ago

@vdo investigating the cause of this, I'm not sure why this would only happen on the ARM Alpine image at this point. If you have any tips I'm all ears as well!

vdo commented 2 years ago

I found the cause, the binary is not ARM64, but x86-64, probably the arch is not correctly detected in the Dockerfile. From within the image:

/home/monero # fixuid
/usr/local/bin/fixuid: line 1: syntax error: unterminated quoted string
/home/monero # file /usr/local/bin/fixuid
/usr/local/bin/fixuid: setuid ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=1125EmpZ5ZHTb2ews0ry/INFCnSqDFs1vjNZcIhEh/W8-_OIII-6_sSgui7YlP/uYp1bpCz_s4lay4rDCGl, not stripped
/home/monero # uname -a
Linux 43da0eeaa3d6 5.15.32-v8+ #1538 SMP PREEMPT Thu Mar 31 19:40:39 BST 2022 aarch64 Linux
vdo commented 2 years ago

This could related with buildx:

https://github.com/docker/buildx/issues/1234

sethforprivacy commented 2 years ago

Ahh, so even my change didn't pull the right binary... Thanks for digging into it, will keep doing the same and see if I can push a fix.

sethforprivacy commented 2 years ago

Idk if it's this simple or not, but I was missing an ARG in the final image build for TARGETARCH:

https://github.com/sethforprivacy/simple-monerod-docker/commit/7623618220fbf6597eb6eccbdf8830f082a373ea

That may (or may not) fix it, but needed to be added anyways. If you can test with a local image build please do so @vdo.

vdo commented 2 years ago

Ok I'm building it locally with buildx to see if the issue is solved in the emulated container

sethforprivacy commented 2 years ago

It seems to be grabbing arm64 binaries properly on the ARM image now: https://github.com/sethforprivacy/simple-monerod-docker/runs/7546320235?check_suite_focus=true#step:11:285

Edit: I also now see on old runs that it was still grabbing amd64 binaries for the ARM build: https://github.com/sethforprivacy/simple-monerod-docker/runs/7529308323?check_suite_focus=true#step:9:529

I think this should be resolved now once it finishes pushing.

vdo commented 2 years ago

Unfortunately there's no way (afaik) to post-build load an image from another arch using buildx... so I will just wait until it finishes to confirm it works on the RPi

sethforprivacy commented 2 years ago

@vdo @samsaptidev new image is pushed, please test and report back when you can!

vdo commented 2 years ago

Works now, up and syncing :cocktail:

sethforprivacy commented 2 years ago

Awesome! Closing this out, thanks so much for the help finding the root cause here :D

samsapti commented 2 years ago

Sorry I'm late to the party. Can confirm it works now, thanks @vdo and @sethforprivacy!

sethforprivacy commented 2 years ago

Sorry I'm late to the party. Can confirm it works now, thanks @vdo and @sethforprivacy!

Np, thanks for validating!