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

Building with "docker-compose -d up" causes automatic abort. #69

Open
auladinglese opened this issue Mar 7, 2020 · 23 comments · May be fixed by #83
Open

Building with "docker-compose -d up" causes automatic abort. #69

auladinglese opened this issue Mar 7, 2020 · 23 comments · May be fixed by #83
Labels
help wanted Extra attention is needed

Comments

@auladinglese
Copy link

Hi Marceau,

I really like your application, but am having some issues building it with docker-compose. I'm trying to build on a arch linux system following the instructions provided,

ERROR: Service 'shaark' failed to build: The command '/bin/sh -c apk add --no-cache --update openssl zip unzip oniguruma-dev zlib-dev libpng-dev libzip-dev postgresql-dev && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && docker-php-ext-install pdo mbstring gd exif zip sockets pdo_mysql pgsql pdo_pgsql && cp .env.example .env && sed -i s/DB_HOST=127.0.0.1/DB_HOST=mariadb/ .env && sed -i s/REDIS_HOST=127.0.0.1/REDIS_HOST=redis/ .env && sed -i s/APP_ENV=local/APP_ENV=production/ .env && sed -i s/APP_DEBUG=true/APP_DEBUG=false/ .env && sed -i s/CACHE_DRIVER=file/CACHE_DRIVER=redis/ .env && sed -i s/QUEUE_CONNECTION=sync/QUEUE_CONNECTION=redis/ .env && sed -i s/SESSION_DRIVER=file/SESSION_DRIVER=redis/ .env && sed -i s/REDIS_HOST=127.0.0.1/REDIS_HOST=redis/ .env && composer install -o && php artisan optimize && php artisan view:clear && php artisan key:generate && php artisan storage:link && php artisan config:cache && php artisan migrate --seed' returned a non-zero code: 1
It's very possible that the problem is me and not the docker-compose file! Any help or suggestions would be greatly appreciated.

Please let me know if there is any further information you would require.

Congratulations on a beautiful app (based on the hosted versions I've seen)

Best wishes

Matt

@MarceauKa
Copy link
Owner

Hi! Thank you for your feedback. Unfortunately I can't help you with docker (I never used Shaark with it). Maybe @Pandry can help you.

@MarceauKa MarceauKa added the help wanted Extra attention is needed label Mar 7, 2020
@auladinglese
Copy link
Author

Thanks for getting back to me! I'll wait for @Pandry's input.

@johnatank
Copy link

Hi. This most likely happens because php artisan migrate --seed needs user interaction:
Do you really wish to run this command? (yes/no) [no]:
Docker doesn't support user interaction when building images so whole RUN command failed. --force should solve this - php artisan migrate --seed -n --force. Though build still failed due to SQL exception:

In Connection.php line 669:

  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name d
  oes not resolve (SQL: select * from information_schema.tables where table_s
  chema = homestead and table_name = migrations and table_type = 'BASE TABLE'
  )

While docker is building an image - no sql container is up so SQL exception seems to be expected. I tried moving php artisan migrate --seed -n --force and php artisan serve --host=0.0.0.0 --port=80 to sh script in entrypoint:

In Dockerfile - remove CMD and add ENTRYPOINT instead:
ENTRYPOINT ["/app/run.sh"]

in /app/run.sh (run.sh must have execute permission)
#!/bin/sh

cd /app
php artisan migrate --seed --force
php artisan serve --host=0.0.0.0 --port=80

Migration was executed when all containers were up (though shaark container was up before db so had to restart shaark contained for migration to happen). This did the trick and migration completed, however the problem is that migration happened each time container is restarted - that is not good. I still think docker-entrypoint.sh should be used and migration should happen there, however there should be a way to do it once (maybe reading some value in DB or reading env variable?).

PS. I still had problem with running shaark service and I found that app wasn't working due to missing gmp and/or bcmath php extension. I ended up with having this in Dockerfile as well:

RUN apk add --update --no-cache gmp gmp-dev \
    && docker-php-ext-install gmp bcmath

Hope above will help.
Thanks.

@auladinglese
Copy link
Author

Thanks @johnatank, I'll try what you've suggested.

@auladinglese
Copy link
Author

Hi @johnatank

Tried as you suggested (I think!), on my fork auladinglese/shaark (just so I could test the changes and keep them if they worked).

Got this:

Loading composer repositories with package information
Installing dependencies from lock file
Package operations: 90 installs, 0 updates, 0 removals

  • Installing doctrine/event-manager (1.1.0): Downloading (0%) Failed to download doctrine/event-manager from dist: Could not authenticate against github.com
    Now trying to download from source
  • Installing doctrine/event-manager (1.1.0): Cloning 6295728199

[RuntimeException]
Failed to clone https://github.com/doctrine/event-manager.git, git was not found, check that it is installed and in your PATH env.

sh: git: not found

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] []...

ERROR: Service 'shaark' failed to build: The command '/bin/sh -c apk add --no-cache --update openssl gmp gmp-dev zip unzip oniguruma-dev zlib-dev libpng-dev libzip-dev postgresql-dev && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && docker-php-ext-install gmp bcmath pdo mbstring gd exif zip sockets pdo_mysql pgsql pdo_pgsql && cp .env.example .env && sed -i s/DB_HOST=127.0.0.1/DB_HOST=mariadb/ .env && sed -i s/REDIS_HOST=127.0.0.1/REDIS_HOST=redis/ .env && sed -i s/APP_ENV=local/APP_ENV=production/ .env && sed -i s/APP_DEBUG=true/APP_DEBUG=false/ .env && sed -i s/CACHE_DRIVER=file/CACHE_DRIVER=redis/ .env && sed -i s/QUEUE_CONNECTION=sync/QUEUE_CONNECTION=redis/ .env && sed -i s/SESSION_DRIVER=file/SESSION_DRIVER=redis/ .env && sed -i s/REDIS_HOST=127.0.0.1/REDIS_HOST=redis/ .env && composer install --no-dev -o && php artisan optimize && php artisan view:clear && php artisan key:generate && php artisan storage:link && php artisan config:cache && ENTRYPOINT ["/app/run.sh"]' returned a non-zero code: 1`

As you've likely guessed I'm not sure what I'm actually doing. Tried to follow your instructions but probably did something wrong.

Wanted a dockerised version of Shaark because it means running my server is a little less challenging that way...in theory at least!

@Pandry
Copy link
Contributor

Pandry commented Mar 26, 2020

Damn, sorry!
When I read the message I was sick and I totally forgot about this.
Just gave it a quick run and it looks like it stops because of a needed user interaction as @johnatank said, and he's also right about the entrypoint.sh file.
The migration should obviosly happen just once.
I belive a good way to proceed would be creating a flag on build time (as a file) indicating that a migration is needed somewhere in the filesystem and removing it after applying the migration.
The main issue with that would be that a read-only filesystem could not be used with this approach.
Another way could be executing the migration manually, but that would imply a 2nd command from the user, but it would also ensure the cleanest possible image.
What do think @MarceauKa ?

@frenchvandal
Copy link

frenchvandal commented Mar 28, 2020

Since I found out about Shaark with the demo, I fell in ❤️

Everything in my server is dockerized, it has been very very challenging to install Shaark that way. I encountered most of the same issues as described above.

I already have Redis and MariaDB containers up and running (each of my services have their own docker-compose.yml separate file), so I removed them from the Shaark docker-compose.yml stack and added the existing common network. It seems that during image build, MariaDB cannot be accessed (even creating a homestead super user beforehand), so the image failed with the same In Connection.php line 669 error.

Then I tweaked a few things, I skipped MariaDB for SQLite. The time, the image build succeeded and the page was up at the URL but I got a different error, Shaark could not access my Redis host and port.

So I changed my .env and put every Redis value into file. I am almost there! Thing is, I got another error when I display Shaark on a browser:
Missing BC Math or GMP extension. (View: /var/www/shaark/resources/views/home.blade.php)

I felt like I am turning around but somehow I missed this point was already mentioned here too. So I added the extra:

RUN apk add --update --no-cache gmp gmp-dev \
    && docker-php-ext-install gmp bcmath

Now Shaark is up and running!

Just it is frustrating not being able to use my existing MariaDB and Redis services, but for now my solution will do the trick.

P.S. I talked too fast 😢 the new posts work but when I click on a link:
Call to undefined function Intervention\Image\Gd\imagettfbbox() (View: /var/www/shaark/resources/views/link.blade.php)

@Pandry
Copy link
Contributor

Pandry commented Mar 28, 2020

Hi @frenchvandal, try adding to the docker-php-ext-install gmp bcmath the gd extension
I honestly didn't do a great work in seeing the needed extensions for the project and I will probably try to do in better in the WE

@frenchvandal
Copy link

frenchvandal commented Mar 29, 2020

@Pandry
A quick note: in my case, I had to add this in my Dockerfile:
sed -i 's|APP_URL=http:\/\/dev.shaark|APP_URL=https:\/\/example.com|' .env && \
When I put the actual URL in this entry, Shaark works just fine, besides a few things I mentioned in #70

Regarding the extensions, is the PHP extension for Redis needed? I tried this in the RUN of my Dockerfile:

apk add --no-cache --update pcre-dev ${PHPIZE_DEPS} && \
pecl install -o -f redis && \
docker-php-ext-enable redis && \
apk del pcre-dev ${PHPIZE_DEPS} && \
rm -rf /tmp/* && \

My build was successful. Is there a way I can check if Redis is actually working with Shaark? I dot see any data in its volume.

@MarceauKa
Copy link
Owner

@frenchvandal Redis is usefull when using queues for link archiving, see the install doc :)

@frenchvandal
Copy link

@MarceauKa oh I see, sorry I missed that :)

With the current Dockerfile, I am not sure archiving could be executed since the dependencies mentioned in the doc are not installed?

@MarceauKa
Copy link
Owner

As mentioned in #70, we should bring Laradock to Shaark. As I'm a beginner with Docker, could somebody try to make a PR with it?

@frenchvandal
Copy link

I like playing with Docker but I am not very familiar with the whole Shaark architecture. I found this post that should be a good starting point. I will make some tests on my server this week.

@squ1rr3lly squ1rr3lly linked a pull request Aug 14, 2020 that will close this issue
6 tasks
@squ1rr3lly
Copy link

Let me know what you think about #83.

It should resolve all the issues discussed here, and add some nice usability features particularly for people that like to do development with docker-compose. I don't have much experience developing PHP and none with Laravel, but I think I kept things pretty clean.

Thanks for maintaining this awesome tool!

@squ1rr3lly
Copy link

I messed with getting archives to work and after achieving a solid bruise from banging my head against the wall have decided it's just not feasible with alpine. I'm starting to play with builds using Laradock, but still learning the basics. Definitely agree it looks like a good fit, though. If anyone else has done some work there hit me up.

@tborychowski
Copy link

@squ1rr3lly sorry, I'm confused...
does your PR work (I mean if I check it in, and run docker-compose up -d)?
can one survive without this "archives"?
I'd really love to get it working 😄

@squ1rr3lly
Copy link

Hey @tborychowski ,

Yes, it works as written. You can just run docker-compose up -d and you'll have a fully working instance except for the Media and PDF archiving (which isn't required and doesn't work with the current dockerfile either).

I've been running and using this as my production instance for about a week and it's smooth and stable.

@squ1rr3lly
Copy link

I think I've finished up the changes on this. Details in #83, but backups and archives work correctly and the storage directory is a docker volume so all the settings will persist through a rebuild/redeploy of the containers.

I also changed the library that's being used for PDF archiving from puphpeteer to browsershot. It seems better supported as puphpeteer is no longer maintained, and as far as I can tell has all the same functionality with less dependencies. If anyone has time to check that out and make sure everything works as expected, I'd appreciate it. I never actually got puphpeteer to work, but the archiving with browsershot seemed to do everything I'd want.

@kriss6557
Copy link

kriss6557 commented Nov 18, 2020

Hi, first congratulations for this featurefull and very clean GUI bookmark manager.
I'm trying to make is work locally with docker, that I use for most of my services.
As it works locally I skipped the nginx reverse proxy.
I just adapted the docker-compose file (see attachment), exposed port 9080 to 80 and set dependance to mariadb and redis.
docker-compose.yml.txt

All 3 containers run ok, but when connecting, I get the Shaark background with:
500 - Server Error
Whoops, something went wrong on our servers.

The console shows:
shaark | Laravel development server started: http://0.0.0.0:80
shaark | [Wed Nov 18 10:58:17 2020] PHP 7.4.12 Development Server (http://0.0.0.0:80) started
shaark | [Wed Nov 18 10:59:14 2020] 10.5.23.40:59018 Accepted
shaark | [Wed Nov 18 10:59:15 2020] 10.5.23.40:59018 Closing
shaark | [Wed Nov 18 10:59:15 2020] 10.5.23.40:59019 Accepted
shaark | [Wed Nov 18 10:59:15 2020] 10.5.23.40:59020 Accepted
shaark | [Wed Nov 18 10:59:15 2020] 10.5.23.40:59019 [200]: GET /js/manifest.js?id=3c768977c2574a34506e
shaark | [Wed Nov 18 10:59:15 2020] 10.5.23.40:59021 Accepted
shaark | [Wed Nov 18 10:59:15 2020] 10.5.23.40:59022 Accepted
shaark | [Wed Nov 18 10:59:15 2020] 10.5.23.40:59019 Closing
shaark | [Wed Nov 18 10:59:15 2020] 10.5.23.40:59020 [200]: GET /css/app.css?id=b8b03307e0cd699952d1
shaark | [Wed Nov 18 10:59:15 2020] 10.5.23.40:59022 [200]: GET /js/app.js?id=6454f6e14b5042d95985
shaark | [Wed Nov 18 10:59:15 2020] 10.5.23.40:59021 [200]: GET /js/vendor.js?id=11a927bf070f02d1f22c
shaark | [Wed Nov 18 10:59:15 2020] 10.5.23.40:59020 Closing
shaark | [Wed Nov 18 10:59:15 2020] 10.5.23.40:59022 Closing
shaark | [Wed Nov 18 10:59:16 2020] 10.5.23.40:59021 Closing

full console output
log.txt

Any clue on this ?

BTW do you plan to publish to docker hub ? Would be great to see it in "next version"

@tborychowski
Copy link

@kriss6557 I have exactly the same error. Could not make it work :-(

@drdm1
Copy link

drdm1 commented Apr 17, 2021

Hi all- I realize this thread is nearly 6 months old but I'm running into the same issues described above with what is currently posted. Any help to resolve would be great. screenshot

@walkxcode
Copy link

Same issue....

@rysuq
Copy link

rysuq commented Jan 15, 2022

I have the same problem like my previously colleagues (500 - Server Erorr). I just change .env file in working docker to work in local mode and turn on debug mode( I restarted docker after that changes. I got this error:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'homestead.walls' doesn't exist (SQL: select * from `walls` where `is_default` = 1 and `is_private` = 0 limit 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.