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

docker-compose build fails on initial install #263

Closed
edwhardo opened this issue Dec 27, 2023 · 15 comments
Closed

docker-compose build fails on initial install #263

edwhardo opened this issue Dec 27, 2023 · 15 comments

Comments

@edwhardo
Copy link

docker-compose build fails

14.72 Reading package lists...
15.11 W: GPG error: http://apt.postgresql.org/pub/repos/apt jammy-pgdg InRelease: Unknown error executing apt-key
15.11 E: The repository 'http://apt.postgresql.org/pub/repos/apt jammy-pgdg InRelease' is not signed.

failed to solve: executor failed running [/bin/bash -o pipefail -c echo "deb [signed-by=/etc/apt/keyrings/pgdg.asc] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
apt-get update
apt-get install --no-install-recommends -qy cpanminus bzip2 gettext g++ git libdb-dev libexpat1-dev libicu-dev liblocal-lib-perl libpq-dev libssl-dev libxml2-dev make nodejs pkg-config postgresql-client-${POSTGRES_VERSION} python2-minimal xz-utils zlib1g-dev && rm -rf /var/lib/apt/lists/*
corepack enable]: exit code: 100

@edwhardo edwhardo changed the title docker-compose build fails on inital install docker-compose build fails on iniitial install Dec 27, 2023
@edwhardo edwhardo changed the title docker-compose build fails on iniitial install docker-compose build fails on initial install Dec 27, 2023
@satvikx
Copy link

satvikx commented Dec 27, 2023

I would like to work on this issue!

@edwhardo
Copy link
Author

The issue seems to be with a few of the Dockerfile RUN statements. After doing the initial clone with

git clone https://github.com/metabrainz/musicbrainz-docker.git

it appears the the problems come from 3 files
build/musicbrainz/Dockerfile
build/musicbrainz-dev/Dockerfile
build/postgres/Dockerfile
some tweaking of these to change apt-key to gpg import leads a bit further down the path to build success, but I haven't been able to find the right combination.

@yvanzo
Copy link
Contributor

yvanzo commented Jan 2, 2024

Hi @edwhardo,

It could have been an issue before v-2023-11-13 but I’m unable to reproduce it since then, including with the latest v-2023-12-20.

Can you please provide more information on your Docker/Compose installation?

echo MusicBrainz Docker: `git describe --always --broken --dirty --tags`
echo Docker Compose: `docker-compose version --short` && \
sudo docker version -f 'Docker Client/Server: {{.Client.Version}}/{{.Server.Version}}'

Also what is your host platform and version?

lsb_release -a

Please try building images with no cache as follows and provide full logs as attachments:

sudo docker-compose build --no-cache

Regards

@edwhardo
Copy link
Author

edwhardo commented Jan 2, 2024

Hi @yvanzo ,


MusicBrainz Docker: v-2023-12-20-dirty
Docker Compose: 2.21.0
Docker Client/Server: 20.10.24/20.10.24

I'm running Unraid 6.12.5 with the docker-compose plugin

I finally managed to get it to build by editing the Dockerfiles to change the gpg key install for nodejs and postgresql, but when I try to start it, there are permissions errors due to my OS (Unraid) not letting the entrypoint scripts run due to their location on the rootfs. I was also using when the build was successful

sudo docker-compose build --no-cache

# docker-compose up -d
[+] Running 6/6
 ✔ Container musicbrainz-docker-redis-1        Running                                                                                                       0.0s
 ✔ Container musicbrainz-docker-mq-1           Started                                                                                                       2.4s
 ✔ Container musicbrainz-docker-search-1       Running                                                                                                       0.0s
 ✔ Container musicbrainz-docker-db-1           Running                                                                                                       0.0s
 ✔ Container musicbrainz-docker-musicbrainz-1  Recreated                                                                                                     4.1s
 ✔ Container musicbrainz-docker-indexer-1      Started                                                                                                       3.6s
Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "docker-entrypoint.sh": executable file not found in $PATH: unknown

So, it seems that my issue now has everything to do with the idiosyncracies of my OS and chosen method of running docker-compose (as a plugin). I'll seek assistance with the author of the plugin, but it seems strange that I was having the gpp key issues.

Should we close this, or would you like to see the edits I made for a successful compile?

@yvanzo
Copy link
Contributor

yvanzo commented Jan 3, 2024

At least your Docker version is recent enough as I have one test VM running Docker 20.10.12 (on Ubuntu focal).

Please check the base image used to build the image for the db service as follows:

sudo docker images --filter reference=postgres

Here is what I get:

REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
postgres     12        c4a7b5d790eb   3 weeks ago   412MB

Otherwise I don’t have other hint, so it might be related to your host system which I don’t know anything about.

As for the GPG keys, we made changes to how these are handled just two months ago; See 4513294. Your changes shouldn’t be needed. My guess is that the root cause is more likely one the above (either the base image is not recent enough or the host system has some issue).

@edwhardo
Copy link
Author

edwhardo commented Jan 3, 2024

That command returned nothing. The only db entry is:
musicbrainz-docker_db 12 f1e3dd1f497c 4 hours ago 1.43GB

I've manually updated docker-compose to Docker Compose: 2.21.0

I'll just wipe it and start over. Its good to know that GPG stuff is sorted. Will advise if I have success.

@yvanzo
Copy link
Contributor

yvanzo commented Jan 3, 2024

That’s weird. Try building with pulling the latest version of the base image as follows:

sudo docker-compose build --no-cache --pull db

Please share the full log, especially the Step 2/9 at the beginning.

@edwhardo
Copy link
Author

edwhardo commented Jan 3, 2024

That built, but there were only 4 Steps.

Please share the full log, especially the Step 2/9 at the beginning.

I'm pretty new to Docker (not to Linux), and I can't work out how to see the full log. I tried
docker-compose logs --no-color > logs.txt
to no avail.

I also followed the documented steps on a Ubuntu machine and it worked, so it must be my Unraid environment. I should have another machine around that has enough grunt to run musicbrainz.

I think its time to go pruning the dangling images and contrainers.

@yvanzo
Copy link
Contributor

yvanzo commented Jan 3, 2024

The logs command stands for containers’ logs, not image builds.

You have to copy the output of the build command, either by hand or through a redirect as follows:

sudo docker-compose build --no-cache --pull db 2>&1 | tee build.db.log

I think its time to go pruning the dangling images and contrainers.

It can’t hurt indeed.

@edwhardo
Copy link
Author

edwhardo commented Jan 4, 2024

Thanks for the redirect and pipe to tee tip.
The db built fine. The problem occurs at the build of musicbrainz.
logs attached.
build.musicbrainz.log.gz
build.db.log.gz

@yvanzo
Copy link
Contributor

yvanzo commented Jan 4, 2024

I just noticed that all the errors are related to files being copied from the build/musicbrainz/ directory.
Might it be that these are not copied with the expected ownership and permissions using your Docker installation?

Can you please provide the output of the following added ls command when building?

diff --git a/build/musicbrainz/Dockerfile b/build/musicbrainz/Dockerfile
index 04686425..0236e091 100644
--- a/build/musicbrainz/Dockerfile
+++ b/build/musicbrainz/Dockerfile
@@ -16,6 +16,7 @@ RUN curl -sSLO --retry 5 https://github.com/jwilder/dockerize/releases/download/
     rm -f dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
 
 COPY keyrings/* /etc/apt/keyrings/
+RUN ls -all /etc/apt/keyrings/ && exit 1
 ARG NODE_MAJOR_VERSION=20
 ARG POSTGRES_VERSION=12
 SHELL ["/bin/bash", "-o", "pipefail", "-c"]

@edwhardo
Copy link
Author

edwhardo commented Jan 5, 2024

#8 [musicbrainz  4/12] RUN ls -all /etc/apt/keyrings/ && exit 1
#8 7.795 total 12
#8 7.795 drwxr-xr-x 1 root root   44 Jan  4 23:29 .
#8 7.795 drwxr-xr-x 1 root root  162 Sep 17  2022 ..
#8 7.795 -rw------- 1 root root 1684 Jan  3 07:42 nodesource.asc
#8 7.795 -rw------- 1 root root 4812 Jan  3 07:42 pgdg.asc
#8 ERROR: executor failed running [/bin/sh -c ls -all /etc/apt/keyrings/ && exit 1]: exit code: 1

@edwhardo
Copy link
Author

edwhardo commented Jan 5, 2024

this Dockerfile edit gets a lot further down the road to a successful build.

diff --git a/build/musicbrainz/Dockerfile b/build/musicbrainz/Dockerfile
index e3e4e9c..6b3b077 100644
--- a/build/musicbrainz/Dockerfile
+++ b/build/musicbrainz/Dockerfile
@@ -16,11 +16,14 @@ RUN curl -sSLO --retry 5 https://github.com/jwilder/dockerize/releases/download/
     rm -f dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

 COPY keyrings/* /etc/apt/keyrings/
+RUN apt-get update && apt-get install -y curl
+RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
+    curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/keyrings/postgresql.gpg
 ARG NODE_MAJOR_VERSION=20
 ARG POSTGRES_VERSION=12
 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
-RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.asc] https://deb.nodesource.com/node_${NODE_MAJOR_VERSION}.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
-    echo "deb [signed-by=/etc/apt/keyrings/pgdg.asc] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
+RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR_VERSION}.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
+    echo "deb [signed-by=/etc/apt/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
     apt-get update && \
     apt-get install --no-install-recommends -qy \
         cpanminus \

@edwhardo
Copy link
Author

edwhardo commented Jan 8, 2024

@yvanzo , you were certainly correct about the files not being copied with the correct permissions. I'm doing this on an Unraid server with the Docker Compose Manager Plugin. Unraid doesn't allow any exe files in /boot and plugins are installed in /boot/config/plugins

Not sure why I needed to change the way the postgresql and nodejs repositories were added, but if it doesn't affect others, there isn't any reason to change it.

These are the changes that I needed to get things built:

diff --git a/build/musicbrainz/Dockerfile b/build/musicbrainz/Dockerfile
index e3e4e9c..91059b5 100644
--- a/build/musicbrainz/Dockerfile
+++ b/build/musicbrainz/Dockerfile
@@ -16,11 +16,14 @@ RUN curl -sSLO --retry 5 https://github.com/jwilder/dockerize/releases/download/
     rm -f dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

 COPY keyrings/* /etc/apt/keyrings/
+RUN apt-get update && apt-get install -y curl
+RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
+    curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/keyrings/postgresql.gpg
 ARG NODE_MAJOR_VERSION=20
 ARG POSTGRES_VERSION=12
 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
-RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.asc] https://deb.nodesource.com/node_${NODE_MAJOR_VERSION}.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
-    echo "deb [signed-by=/etc/apt/keyrings/pgdg.asc] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
+RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR_VERSION}.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
+    echo "deb [signed-by=/etc/apt/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
     apt-get update && \
     apt-get install --no-install-recommends -qy \
         cpanminus \
@@ -71,6 +74,19 @@ RUN eval "$(perl -Mlocal::lib)" \

 COPY DBDefs.pm /musicbrainz-server/lib/
 COPY scripts/* /usr/local/bin/
+RUN ls -all /usr/local/bin
+RUN ["chmod", "+x", "/usr/local/bin/createdb.sh"]
+RUN ["chmod", "+x", "/usr/local/bin/docker-entrypoint.sh"]
+RUN ["chmod", "+x", "/usr/local/bin/fetch-dump.sh"]
+RUN ["chmod", "+x", "/usr/local/bin/indexer-triggers.sh"]
+RUN ["chmod", "+x", "/usr/local/bin/load-crontab-only.sh"]
+RUN ["chmod", "+x", "/usr/local/bin/recreatedb.sh"]
+RUN ["chmod", "+x", "/usr/local/bin/replication.sh"]
+RUN ["chmod", "+x", "/usr/local/bin/snippet.perllocallib.bashrc"]
+RUN ["chmod", "+x", "/usr/local/bin/start.sh"]
+RUN ["chmod", "+x", "/usr/local/bin/start_mb_renderer.pl"]
+RUN ["chmod", "+x", "/usr/local/bin/upgrade-db-schema.sh"]
+
 RUN cat /usr/local/bin/snippet.perllocallib.bashrc >> ~/.bashrc \
     && rm /usr/local/bin/snippet.perllocallib.bashrc \
     && ln -s /usr/local/bin/docker-entrypoint.sh /
@@ -99,5 +115,5 @@ RUN yarn install \
     && eval "$(perl -Mlocal::lib)" \
     && /musicbrainz-server/script/compile_resources.sh

-ENTRYPOINT ["docker-entrypoint.sh"]
+ENTRYPOINT ["/docker-entrypoint.sh"]
 CMD ["start.sh"]
diff --git a/build/rabbitmq/Dockerfile b/build/rabbitmq/Dockerfile
index 1300d53..8c4d5b5 100644
--- a/build/rabbitmq/Dockerfile
+++ b/build/rabbitmq/Dockerfile
@@ -9,5 +9,7 @@ ARG RABBITMQ_TAG
 LABEL org.metabrainz.based-on-image="rabbitmq:${RABBITMQ_TAG}"

 COPY [ "scripts/*", "/" ]
+RUN ["chmod", "+x", "/docker-entrypoint-wrapper.sh"]

-ENTRYPOINT ["/docker-entrypoint-wrapper.sh"]
+#ENTRYPOINT ["/docker-entrypoint-wrapper.sh"]
+ENTRYPOINT ["/bin/bash","/docker-entrypoint-wrapper.sh"]
diff --git a/build/sir-dev/Dockerfile b/build/sir-dev/Dockerfile
index 1c18ece..aab3b93 100644
--- a/build/sir-dev/Dockerfile
+++ b/build/sir-dev/Dockerfile
@@ -57,5 +57,7 @@ ENV POSTGRES_PASSWORD=musicbrainz
 ENV PYTHONUSERBASE="/code/venv-musicbrainz-docker"
 ENV PATH="/code/venv-musicbrainz-docker/bin:$PATH"

-ENTRYPOINT ["docker-entrypoint.sh"]
+#ENTRYPOINT ["docker-entrypoint.sh"]
+#ENTRYPOINT ["/bin/bash","/docker-entrypoint-wrapper.sh"]
+ENTRYPOINT ["/bin/bash","/docker-entrypoint.sh"]
 CMD unset PYTHONUSERBASE; my_init
diff --git a/build/solr/Dockerfile b/build/solr/Dockerfile
index 525f7c9..7591664 100644
--- a/build/solr/Dockerfile
+++ b/build/solr/Dockerfile
@@ -5,3 +5,6 @@ ARG MB_SOLR_VERSION
 LABEL org.metabrainz.based-on-image="metabrainz/mb-solr:${MB_SOLR_VERSION}"

 COPY [ "scripts/*", "/usr/local/bin/" ]
+USER root
+RUN ["chmod", "+x", "/usr/local/bin/load-search-indexes.sh"]
+USER solr

@yvanzo
Copy link
Contributor

yvanzo commented Jan 8, 2024

You might encounter similar permission issues with helper scripts under admin/ that are supposed to be executable and that copy files or bind mount directories. We won’t make changes for systems that do not preserve file permissions, but at least I listed this error in TROUBLESHOOTING.md through the pull request #266 so that it will be documented for others.

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

No branches or pull requests

3 participants