VGoshev / seafile-docker

Docker image for Seafile server
https://hub.docker.com/r/sunx/seafile/
MIT License
27 stars 19 forks source link

Make dir /home/seafile/ccnet error: Permission denied #1

Closed yangxuan8282 closed 7 years ago

yangxuan8282 commented 7 years ago

hi , when I use your Dockerfile to run seafile on raspberry pi 3 (on first run), got permission issues.

If don't mapping volume then everything works fine, but if trying to mount a volume will got:

Make dir /home/seafile/ccnet error: Permission denied

Dockerfile

ROM hypriot/rpi-alpine-scratch:v3.4

# SEAFILE_SERVER_DIR:
# Where we will store seafile-server settings
#  seafile user home directory.
# Default: /home/seafile
#
# SEAFILE_VERSION:
# Seafile-Server version do townload and install
#  See https://github.com/haiwen/seafile-server/releases
#  for latest avaliable version
# uUID - set UID of seafile user, default: 2016
# uGID - set GID of seafile user, default: 2016
ENV SEAFILE_SERVER_DIR="/home/seafile" \
        SEAFILE_VERSION="6.0.7"

# All installation proccess is in build.sh
# It is possible to do all work via RUN command(s)
# But it looks much better with all work in script
COPY build.sh /tmp/build.sh
COPY seafile-server.patch /tmp/seafile-server.patch
# Execute our build script and delete it because we won't need it anymore
RUN /tmp/build.sh "$SEAFILE_VERSION" "$SEAFILE_SERVER_DIR" && rm /tmp/build.sh

# Container initialization scripts ()
COPY docker-run.sh /bin/docker-run

EXPOSE 8000 8082
VOLUME $SEAFILE_SERVER_DIR

RUN set -xe \
  && chown -R seafile:seafile /home/seafile

USER seafile

RUN mkdir -p /home/seafile/ccnet

# Container will run /bin/docker-run with seafile user access
# to configure (if needed) and run Seafile server

CMD ["/bin/docker-run"]

build with:

docker build -t pi-seafile .

run with:

docker run --name seafile -v /home/pirate/seafile:/home/seafile -p 192.168.8.103:8000:8000 -p 192.168.8.103:8082:8082 -ti pi-seafile

I have use sh in container to check the owner of /home/seafile, it turn out that the owner is user seafile, so I don't know how to fix it.

VGoshev commented 7 years ago

When you are inside of container, what exactly says command: ls -la /home/seafile ?

yangxuan8282 commented 7 years ago
$ docker run --rm -ti pi-seafile sh
/ $ ls -la /home/seafile/
total 16
drwxr-xr-x    3 seafile  seafile       4096 Jan 29 11:55 .
drwxr-xr-x    3 root     root          4096 Jan 29 09:00 ..
-rw-------    1 seafile  seafile         22 Jan 29 11:55 .ash_history
drwxr-sr-x    2 seafile  seafile       4096 Jan 29 08:58 seafile-server
yangxuan8282 commented 7 years ago

fix it by:

cd ~ && chmod 777 seafile

then run the docker

I have another question, how can we set user and password when --env INTERACTIVE=0 ( non-interactive )?

VGoshev commented 7 years ago

It's weird, I'll try to test it on my RPi and will make a patch. Actually, using 777 permissions isn't secure.

As of setting user and password - it is impossible in non-interactive mode now =). I'll try to fix it as well.

yangxuan8282 commented 7 years ago

@jobenvil hi, if it's possible to setting admin email and password in non-interactive mode, or do it later in webui like btsync?

VGoshev commented 7 years ago

I've tested it in my RPi. If owner of /home/seafile is seafile:seafile, then everything should be ok (But I've used armfh/alpine as base image, not hypriot/rpi-alpine-scratch). I've added check of it to script in container. Also I've add ability to create images for ARM-based devices to script /docker-build.sh

As of creating user in non-interactive mode, I'll try to do it a bit later.

PS: Also I've added arm image to my Docker Hub page sunx/seafile:armhf

yangxuan8282 commented 7 years ago

Which OS do you use on host, raspbian or hypriot os?

VGoshev commented 7 years ago

I use Raspbian. But I don't think there should be any significant difference in it (Except of case if HypriotOS adds some security level which makes this issue).

yangxuan8282 commented 7 years ago

yes, they should basically same I'm not sure what caused I have to give 777 permission to the folder. I have saw your docker hub update, great works.

yangxuan8282 commented 7 years ago

@VGoshev Have you test seafile in docker write/read performance on raspberry pi? for me, it's about 2MB/s r/w, with built in Wi-Fi I'm not sure it's slow or normal.

VGoshev commented 7 years ago

I have not tested it yet, I want to make my home storage on Orange Pi (as it has faster CPU), but I'm waiting for kernel with better support of it (support of Orange Pi isn't very good in 4.x kernels, unfortunately). And I use my Raspberry Pi I for other purposes.

Where do you store your seafile data? On MicroSD or on external USB Flash/HDD/SSD? In case of MicroSD card it could be sd card issue, at least my sd card looks quite slow. So if you use MicroSD for seafile storage, then try to use some external USB storage (but choose good one, because cheap USB Sticks are also very slow, usually), it should improve read/write speed.

yangxuan8282 commented 7 years ago

I'm test it on a Samsung class 10 card, the IO speed is about 20MB/s. I guess the slow speed is related to container. I used to use docker install samba, the speed is about 1MB/s, compare to same network the samba on host speed is 4MB/s. USB hard disk should be faster, but I found the pi3 usb power supply is not really stable even with official 2.5A power supply. Those pi clone have better IO, like Banana Pi have SATA, but their community not so active, and the kernel is kind of outdated. Not sure if RPi4 released in this month will improve IO speed. Vladimir Goshev notifications@github.com于2017年2月5日 周日上午2:12写道:

I have not tested it yet, I want to make my home storage on Orange Pi (as it has faster CPU), but I'm waiting for kernel with better support of it (support of Orange Pi isn't very good in 4.x kernels, unfortunately). And I use my Raspberry Pi I for other purposes.

Where do you store your seafile data? On MicroSD or on external USB Flash/HDD/SSD? In case of MicroSD card it could be sd card issue, at least my sd card looks quite slow. So if you use MicroSD for seafile storage, then try to use some external USB storage (but choose good one, because cheap USB Sticks are also very slow, usually), it should improve read/write speed.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/VGoshev/seafile-docker/issues/1#issuecomment-277463989, or mute the thread https://github.com/notifications/unsubscribe-auth/AGpz0Mp2vdE_M1sNVrWBwxsmmZpKf_TWks5rZL94gaJpZM4LwwjV .

yangxuan8282 commented 7 years ago

@VGoshev if it's possible to run seafile in separator contianer? I'm trying to get seafile work with jwilder/nginx-proxy, the nginx-proxy will auto generate config file, so the seafile can be access at seafile.mydomain.com. But the problem is seafile need two ports, port 8000 for seahub, and 8082 for fileserver, while nginx-proxy don't support multi virtual ports. So I want to run seahub in one container, fileserver in another container. You are the author of Dockerfile, I guess you may have some clue.

VGoshev commented 7 years ago

I do not know easy way to split seafile to 2 containers. I'm not sure if it's possible at all, actually. The only thing I can think of is add some reverse-proxy to seafile container, like nginx or lighttpd or something else.

yangxuan8282 commented 7 years ago

yes, add a reverse proxy in container should be works, somebody mention this in nginx-proxy issues.

yangxuan8282 commented 7 years ago

ok, I have try put nginx-proxy in seafile container, but got 502 error

just replace seafile base image with nginx-proxy, and keep the rest

Nginx-proxy Dockerfile

FROM yangxuan8282/rpi-alpine-nginx:1.11.9

# Install wget and install/updates certificates
RUN apk add --no-cache --virtual .run-deps \
    ca-certificates bash wget curl \
    && update-ca-certificates

# Configure Nginx and apply fix for very long server names
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
 && sed -i 's/^http {/&\n    server_names_hash_bucket_size 128;/g' /etc/nginx/nginx.conf

# Install Forego
RUN curl -o /usr/local/bin/forego -L https://github.com/yangxuan8282/docker-image/blob/master/forego/forego?raw=true \ 
 && chmod u+x /usr/local/bin/forego

ENV DOCKER_GEN_VERSION 0.7.3

RUN wget --quiet https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-linux-armhf-$DOCKER_GEN_VERSION.tar.gz \
 && tar -C /usr/local/bin -xvzf docker-gen-linux-armhf-$DOCKER_GEN_VERSION.tar.gz \
 && rm /docker-gen-alpine-linux-armhf-$DOCKER_GEN_VERSION.tar.gz

COPY . /app/
WORKDIR /app/

ENV DOCKER_HOST unix:///tmp/docker.sock

VOLUME ["/etc/nginx/certs"]

ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["forego", "start", "-r"]

seafile Dockerfile

FROM yangxuan8282/rpi-nginx-proxy

# SEAFILE_SERVER_DIR:
# Where we will store seafile-server settings
#  seafile user home directory.
# Default: /home/seafile
#
# SEAFILE_VERSION:
# Seafile-Server version do townload and install
#  See https://github.com/haiwen/seafile-server/releases 
#  for latest avaliable version
# uUID - set UID of seafile user, default: 2016
# uGID - set GID of seafile user, default: 2016
ENV SEAFILE_SERVER_DIR="/home/seafile" \
    SEAFILE_VERSION="6.0.7"

# All installation proccess is in build.sh
# It is possible to do all work via RUN command(s)
# But it looks much better with all work in script
COPY build.sh /tmp/build.sh
COPY seafile-server.patch /tmp/seafile-server.patch
# Execute our build script and delete it because we won't need it anymore
RUN /tmp/build.sh "$SEAFILE_VERSION" "$SEAFILE_SERVER_DIR" && rm /tmp/build.sh

# Container initialization scripts ()
COPY docker-run.sh /bin/docker-run
COPY ./vhost.d/seafile.mydomain.com /etc/nginx/vhost.d/seafile.mydomain.com

EXPOSE 8088
VOLUME $SEAFILE_SERVER_DIR

RUN set -xe \
  && chown -R seafile:seafile /home/seafile \
  && chmod 777 /home/seafile

USER seafile

# Container will run /bin/docker-run with seafile user access 
# to configure (if needed) and run Seafile server

CMD ["/bin/docker-run"]

./vhost.d/seafile.mydomain.com

server {
    listen 80;
    server_name seafile.mydomain.com;

    proxy_set_header X-Forwarded-For $remote_addr;

    location / {
        fastcgi_pass    127.0.0.1:8000;
        fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;
        fastcgi_param   PATH_INFO           $fastcgi_script_name;

        fastcgi_param    SERVER_PROTOCOL        $server_protocol;
        fastcgi_param   QUERY_STRING        $query_string;
        fastcgi_param   REQUEST_METHOD      $request_method;
        fastcgi_param   CONTENT_TYPE        $content_type;
        fastcgi_param   CONTENT_LENGTH      $content_length;
        fastcgi_param    SERVER_ADDR         $server_addr;
        fastcgi_param    SERVER_PORT         $server_port;
        fastcgi_param    SERVER_NAME         $server_name;
        fastcgi_param   REMOTE_ADDR         $remote_addr;

        access_log      /var/log/nginx/seahub.access.log;
        error_log       /var/log/nginx/seahub.error.log;
        fastcgi_read_timeout 36000;
    }

    location /seafhttp {
        rewrite ^/seafhttp(.*)$ $1 break;
        proxy_pass http://127.0.0.1:8082;
        client_max_body_size 0;
        proxy_connect_timeout  36000s;
        proxy_read_timeout  36000s;
        proxy_send_timeout  36000s;
        send_timeout  36000s;
    }

    location /media {
        root /home/user/haiwen/seafile-server-latest/seahub;
    }
}

start docker mount with previous config folder, got failed to get blocks

start docker with new folder, it stop unexpectedly before setup domain