mujx / hakatime

Wakatime server implementation & analytics dashboard
https://hakatime.mtx-dev.xyz
The Unlicense
631 stars 47 forks source link

Fix: psql not found #68

Closed enricodeleo closed 1 year ago

enricodeleo commented 1 year ago

Due to missing packages the error

/app/start.sh: line 22: psql: command not found

Appears until we make psql available via postgresql-contrib.

mujx commented 1 year ago

Thanks

rriski commented 1 year ago

I'm still experiencing this issue with mujx/hakatime:latest-arm

mujx commented 1 year ago

@rriski Are you using the latest version? Can you try pull the image again just in case?

rriski commented 1 year ago

Yep, latest version. Tried removing the image locally and pulling again. The digest matches the latest image version in Dockerhub sha256:c0645c73a209534740822e55b68acc90c13f8667f5d4e5c3cb7b3af4b997714f so I'm definitely using the latest version. I also built an image from git master and that has the same issue.

mujx commented 1 year ago

Btw what is the context of needing the psql command in the container since the app will only need the library.

rriski commented 1 year ago

It is used in the start.sh script: https://github.com/mujx/hakatime/blob/fa8cf08545179830c9fbc5a82015e1280bf95e1f/docker/start.sh#L18

mujx commented 1 year ago

@rriski I've added the correct package in the image that should fix the problem.

rriski commented 1 year ago

The issue is still present and I've narrowed the problem down to the following line: https://github.com/mujx/hakatime/blob/master/Dockerfile.arm#L47 (apt-get remove -y perl). Apparently there is some dependency chain between psql and perl and removing perl leads to postgresql-client also being removed. See the following logs obtained by running docker buildx build --platform=linux/arm64 -f Dockerfile.arm . -t hakatime:test --progress plain --no-cache

#13 [stage-2 2/7] RUN apt-get update -y -qq &&     apt-get install --no-install-recommends -y netcat libffi-dev libgmp-dev libpq-dev zlib1g-dev postgresql postgresql-client ca-certificates curl &&     apt-get remove -y perl &&     apt-get autoremove -y &&     apt-get autoclean &&     rm -rf /usr/lib/x86_64-linux-gnu/libLLVM* /usr/lib/x86_64-linux-gnu/libicudata.so*
#13 71.05 Setting up postgresql-client (14+238) ...
#13 71.29 Setting up postgresql (14+238) ...
#13 71.45 Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
#13 71.51 Processing triggers for ca-certificates (20211016ubuntu0.22.04.1) ...
#13 71.53 Updating certificates in /etc/ssl/certs...
#13 72.91 0 added, 0 removed; done.
#13 72.91 Running hooks in /etc/ca-certificates/update.d...
#13 72.91 done.
#13 73.28 Reading package lists...
#13 73.95 Building dependency tree...
#13 74.16 Reading state information...
#13 74.50 The following packages were automatically installed and are no longer required:
#13 74.50   libedit2 libgdbm-compat4 libgdbm6 libicu70 libllvm14 libperl5.34
#13 74.51   libreadline8 libxml2 libxslt1.1 locales netbase perl-modules-5.34
#13 74.51   readline-common ssl-cert tzdata ucf
#13 74.51 Use 'apt autoremove' to remove them.
#13 74.53 The following packages will be REMOVED:
#13 74.53   libjson-perl perl postgresql postgresql-14 postgresql-client
#13 74.53   postgresql-client-14 postgresql-client-common postgresql-common
#13 74.70 0 upgraded, 0 newly installed, 8 to remove and 0 not upgraded.
#13 74.70 After this operation, 49.2 MB disk space will be freed.
(Reading database ... 13329 files and directories currently installed.)
#13 74.73 Removing postgresql (14+238) ...
#13 74.78 Removing postgresql-14 (14.5-0ubuntu0.22.04.1) ...
#13 74.79 invoke-rc.d: could not determine current runlevel
#13 74.80 invoke-rc.d: policy-rc.d denied execution of stop.
#13 75.00 Removing postgresql-common (238) ...
#13 75.05 Removing 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
#13 75.15 Removing libjson-perl (4.04000-1) ...
#13 75.24 Removing postgresql-client (14+238) ...
#13 75.32 Removing postgresql-client-14 (14.5-0ubuntu0.22.04.1) ...
#13 75.41 Removing postgresql-client-common (238) ...
#13 75.47 Removing perl (5.34.0-3ubuntu1.1) ...
#13 75.62 Reading package lists...
#13 76.33 Building dependency tree...
#13 76.50 Reading state information...
#13 76.71 The following packages will be REMOVED:
#13 76.71   libedit2 libgdbm-compat4 libgdbm6 libicu70 libllvm14 libperl5.34
#13 76.71   libreadline8 libxml2 libxslt1.1 locales netbase perl-modules-5.34
#13 76.71   readline-common ssl-cert tzdata ucf
#13 76.88 0 upgraded, 0 newly installed, 16 to remove and 0 not upgraded.
#13 76.88 After this operation, 209 MB disk space will be freed

Notice the line "#13 75.24 Removing postgresql-client".

Opened a PR with the fix: https://github.com/mujx/hakatime/pull/71