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

Feedback welcome on custom Docker image #70

Closed
frenchvandal opened this issue Mar 29, 2020 · 10 comments
Closed

Feedback welcome on custom Docker image #70

frenchvandal opened this issue Mar 29, 2020 · 10 comments
Labels
help wanted Extra attention is needed

Comments

@frenchvandal
Copy link

frenchvandal commented Mar 29, 2020

I decided to create this spin-off not to pollute #69

Despite all the tips provided on the former issue, I have not managed to install Shaark with MariaDB so for now I stick to SQLite.

Here is my Dockerfile:

FROM alpine/git as builder
WORKDIR /tmp
RUN set -x \
    && git clone https://github.com/MarceauKa/shaark.git shaark

FROM php:7-alpine
WORKDIR /app
COPY --from=builder /tmp/shaark /app
RUN set -x && \
        touch database/shaark.sqlite && \
        mv .env.example .env && \
        \
        sed -i s/APP_ENV=local/APP_ENV=production/ .env && \
        sed -i s/APP_DEBUG=true/APP_DEBUG=false/ .env && \
        sed -i 's|APP_URL=http:\/\/dev.shaark|APP_URL=https:\/\/normco.re|' .env && \
        sed -i s/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/ .env && \
        sed -i 's|DB_DATABASE=homestead|DB_DATABASE=\/app\/database\/shaark\.sqlite|' .env && \
        #test with Redis
        sed -i s/REDIS_HOST=127.0.0.1/REDIS_HOST=redis/ .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 && \
        #test with Redis
        \
        apk -U upgrade && \
        apk add --no-cache --update openssl \
        zip \
        unzip \
        oniguruma-dev \
        zlib-dev libpng-dev \
        libzip-dev \
        postgresql-dev \
        gmp \
        gmp-dev \
        nodejs \
        npm && \
        echo "**** install Python ****" && \
        apk add --no-cache python3 && \
        if [ ! -e /usr/bin/python ]; then ln -sf python3 /usr/bin/python ; fi && \
        \
        curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/bin/youtube-dl && \
        chmod a+rx /usr/bin/youtube-dl && \
        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 gmp bcmath && \
        apk --no-cache add pcre-dev ${PHPIZE_DEPS} && \
        pecl install -o -f redis && \
        docker-php-ext-enable redis && \
        apk del pcre-dev ${PHPIZE_DEPS} && \
        rm -rf /tmp/* && \
        \
        composer install --no-dev -o && \
        npm install -g @nesk/puphpeteer --no-save --unsafe-perm=true --allow-root && \
        php artisan optimize && \
        php artisan view:clear && \
        \
        php artisan key:generate && \
        php artisan storage:link && \
        php artisan config:cache && \
        php artisan migrate --seed -n --force

VOLUME /app

CMD php artisan serve --host=0.0.0.0 --port=80
EXPOSE 80

My docker-compose.yml file:

version: "3.7"

volumes:
  app:
  data:

services:
  shaark:
    #image: frenchvandal/shaark:attack
    image: shaark:attack
    build: .
    container_name: shaark
    restart: always
    depends_on:
      - redis
    volumes:
      - app:/app:rw
      - data:/data:rw

  redis:
    image: redis:alpine3.11
    container_name: redis
    restart: unless-stopped
    volumes:
      - data:/data:rw

networks:
  default:
    external:
      name: firefly

(firefly is the default network of all my containers)

A few comments about things I added but not sure really sure if they are actually needed:

  • I included the git clone directly in the Dockerfile
  • I added the PHP extension for Redis,
  • For archiving with Redis, I added Python 3, youtube-dl with curl, npm/nodejs for puphpeteer

The image builds successfully and Shaark is up when I hit the URL.

Globally it is functional, except a few things:

  • Shaark does not display correctly if I do not put the actual URL in the APP_URL entry in .env
  • if I enable the comments in the settings, clicking on any permalink leads to 500 error
  • pictures sometimes fail to load when I drop a picture in the new album form
  • search only display results if SQL is enabled
  • hitting save when adding a new album generates a server error message, though when I go back to the front page, the new album is actually published
  • archiving seems not to work, using the Test buttons gets a server error message for medias and Puppeteer dependencies not installed, run npm install @nesk/pupheteer --no-save (which is done in the Dockerfile???)

Any feedback on my Dockerfile is welcome, and obviously any part of it can be reused for the repo.

@MarceauKa
Copy link
Owner

@frenchvandal Thank you for your PR! I'm just a simple user with Docker so I can't help you with that. Maybe you should have a look at Laradock, it's a docker config for Laravel. It can help you to create your docker config.

FYI, I use these env to run Shaark.

Env HTTP PHP DB Redis ext Jobs driver
dev Apache PHP 7.2 MySQL 5.7 (pdo_mysql) phpredis in database
prod Apache + nginx proxy PHP 7.1 MariaDB 10.2 predis in redis

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

Thank you 😄 I will check this info.

I made some quick tests with my new install. Everything seems functional, except:

  • the search returns results only with SQL activated
  • when the comments are enabled, clicking on a post permalink gets a 500 error

I love Shaarli but I do not think I can go back to it now that I have found out about Shaark!

@MarceauKa do you happen to have a SVG version of the Shaark icon?

@MarceauKa
Copy link
Owner

Can you give me the 500 error you get? (see it in storage/logs/laravel.log).
Nope, I don't have the logo in svg format :(

@frenchvandal
Copy link
Author

frenchvandal commented Mar 29, 2020

Here it is:
laravel-2020-03-29.log

I have noticed another thing: when I add an album with a simple image, after I hit Send, I get a server error message. Though if I leave and go back to the front page, the album is published (so each time I hit Send, the message shows up and the image is published)

Here are the logs.

On a side note, I did not find the pattern yet but the upload of images sometimes fail: logs
image

@frenchvandal
Copy link
Author

@MarceauKa is it possible to share with me an example of Apache prod conf?
I am trying to reverse proxy with Caddy (similar to nginx) but something is wrong with Apache, when I hit the URL I got:

Forbidden
You don't have permission to access this resource.

Apache/2.4.38 (Debian) Server at normco.re Port 80

I am not familiar with Apache. I put all the content of the /shaark folder in /var/www/html

Thank you a lot!

@MarceauKa
Copy link
Owner

@frenchvandal Just put the document root to /public

@frenchvandal
Copy link
Author

Thank you @MarceauKa eventually I managed directly with my web server and without Apache.

I have some issues for displaying images posted with albums. I can see they are stored correctly in their storage path, but they get a 404 error when displayed in a browser.

Is there any specific directive to deal with images in nginx or Apache?

@MarceauKa
Copy link
Owner

Call php artisan storage:link as mentionned in the doc. All uploaded files are stored outsite document root. This command will create a symlink in the public path to the storage folder.

@frenchvandal
Copy link
Author

Thanks man, I actually did the command during install. I am so dumb, the symlink was broken because I change afterwards the root path of Shaark inside the container.

I managed to get a working dockerized Shaark with MariaDB (but includes manual steps from the user). I still have 2 issues to solve before pushing anything: getting mail sent and a functional Redis archiving.

@tborychowski
Copy link

tborychowski commented Aug 18, 2020

Hi @frenchvandal,
did you get around to fixing this?
would you have a copy of your changes anywhere online, or maybe steps to reproduce?
I'd really love to make it work 😄

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

No branches or pull requests

3 participants