Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 681b11bbc1 | |||
| 310eb9028c | |||
| 4dcac70520 | |||
| 6eadca4041 | |||
| 8a0b1abfe7 | |||
| a7ef878490 | |||
| d8438e13f5 | |||
| e73c62d034 | |||
| 6048280983 | |||
| e35cf0efa5 | |||
| ebf7574bde | |||
| e4268c0b21 | |||
| 91758903e9 | |||
| e1d84f2d75 | |||
| 10f6a5ec32 |
53
.github/workflows/docker-publish.yml
vendored
Normal file
53
.github/workflows/docker-publish.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
name: Docker
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
if [ -f docker-compose.test.yml ]; then
|
||||||
|
docker-compose --file docker-compose.test.yml build
|
||||||
|
docker-compose --file docker-compose.test.yml run sut
|
||||||
|
else
|
||||||
|
docker build . --file Dockerfile
|
||||||
|
fi
|
||||||
|
|
||||||
|
push:
|
||||||
|
needs: test
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- uses: docker/build-push-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
repository: snegov/seafile-client
|
||||||
|
tag_with_ref: true
|
||||||
|
add_git_labels: true
|
||||||
|
push: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||||
|
|
||||||
|
- uses: docker/build-push-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
repository: snegov/seafile-client
|
||||||
|
tags: latest
|
||||||
|
add_git_labels: true
|
||||||
|
push: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||||
10
Dockerfile
10
Dockerfile
@@ -1,10 +1,10 @@
|
|||||||
FROM python:3-slim
|
FROM python:3-slim
|
||||||
|
|
||||||
RUN apt-get update && apt-get install gnupg -y && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install gnupg curl -y && rm -rf /var/lib/apt/lists/*
|
||||||
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8756C4F765C9AC3CB6B85D62379CE192D401AB61 && \
|
RUN curl https://linux-clients.seafile.com/seafile.asc | apt-key add - && \
|
||||||
echo deb http://deb.seadrive.org buster main | tee /etc/apt/sources.list.d/seafile.list && \
|
echo 'deb [arch=amd64] https://linux-clients.seafile.com/seafile-deb/buster/ stable main' > /etc/apt/sources.list.d/seafile.list && \
|
||||||
apt-get update -y && \
|
apt-get update -y && \
|
||||||
apt-get install -y seafile-cli procps curl grep && \
|
apt-get install -y seafile-cli procps grep && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /seafile-client
|
WORKDIR /seafile-client
|
||||||
@@ -20,4 +20,6 @@ RUN chmod +x /seafile-client/start.py && \
|
|||||||
chown seafile:seafile -R /seafile-client && \
|
chown seafile:seafile -R /seafile-client && \
|
||||||
su - seafile -c "seaf-cli init -d /seafile-client"
|
su - seafile -c "seaf-cli init -d /seafile-client"
|
||||||
|
|
||||||
|
VOLUME /seafile-client/seafile-data
|
||||||
|
|
||||||
CMD ["./start.py"]
|
CMD ["./start.py"]
|
||||||
|
|||||||
37
README.md
37
README.md
@@ -1,35 +1,42 @@
|
|||||||
# docker-seafile-client
|
# docker-seafile-client
|
||||||
Run a seafile client inside docker witch can sync files from seafile repositories
|
Runs a seafile client in docker with possibility to sync seafile repositories.
|
||||||
|
|
||||||
See docker-compose how to use.
|
|
||||||
|
|
||||||
## Docker-compose example:
|
## Docker-compose example:
|
||||||
```yaml
|
```yaml
|
||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
seafile-client:
|
seafile-client:
|
||||||
restart: always
|
restart: always
|
||||||
image: snegov/seafile-client
|
image: snegov/seafile-client
|
||||||
container_name: seafile-client
|
|
||||||
environment:
|
environment:
|
||||||
- LIBRARY_ID=<your-library-id-here>
|
- LIBRARY_ID=<your-library-id-here>
|
||||||
- SERVER_HOST=<server-host>
|
- SERVER_HOST=<server-host>
|
||||||
- SERVER_PORT=<server-port>
|
|
||||||
- USERNAME=<username>
|
- USERNAME=<username>
|
||||||
- PASSWORD=<password>
|
- PASSWORD=<password>
|
||||||
- DATA_DIR=<directory-path-to-sync>
|
|
||||||
- SEAFILE_UID=<your_uid>
|
- SEAFILE_UID=<your_uid>
|
||||||
- SEAFILE_GID=<your_gid>
|
- SEAFILE_GID=<your_gid>
|
||||||
|
hostname: docker-seafile-client
|
||||||
volumes:
|
volumes:
|
||||||
- <host-volume-path>:<directory-path-to-sync>
|
- seafile-data:/seafile-client/seafile-data
|
||||||
|
- <host-volume-path>:/data
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
seafile-data:
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Library id could be found from "My Libraries" page in Seafile webUI - link to each library contains library ID in it.
|
||||||
|
|
||||||
|
Inside container libraries' content will be put in `/data` directory, so map your host directory to it.
|
||||||
|
|
||||||
|
`hostname` parameter in docker-compose will set client name in Seafile's "Linked devices" admin page. Resulting name will be prefixed by "terminal-".
|
||||||
|
|
||||||
|
Also you could check [docker-compose example](docker-compose.example.yml).
|
||||||
|
|
||||||
## Environment variables:
|
## Environment variables:
|
||||||
- `LIBRARY_ID=<your-library-id-here>` ID of library to sync; multiple libraries could be separated by colon `:`
|
- `LIBRARY_ID=<your-library-id-here>` ID of library to sync; multiple libraries could be separated by colon `:`.
|
||||||
- `SERVER_HOST=<server-host>` Hostname of your seafile server, eg: seafile.example.com
|
- `SERVER_HOST=<server-host>` Hostname of your seafile server, eg: `seafile.example.com`. If you're using non-standart port, specify it here, eg: `seafile.example.com:8080`.
|
||||||
- `SERVER_PORT=<server-port>` Which port the server is hosted on: usually 443 (https) or 80 (http)
|
- `USERNAME=<username>` Seafile account username.
|
||||||
- `USERNAME=<username>` Seafile account username
|
- `PASSWORD=<password>` Seafile account password.
|
||||||
- `PASSWORD=<password>` Seafile account password
|
- `SEAFILE_UID=<uid>` Downloaded files will have this uid.
|
||||||
- `DATA_DIR=<directory-path-to-sync>` The path where to put the files
|
- `SEAFILE_GID=<gid>` Downloaded files will have this gid.
|
||||||
- `SEAFILE_UID=<uid>` Downloaded files will have this uid
|
|
||||||
- `SEAFILE_GID=<gid>` Downloaded files will have this gid
|
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
seafile-client:
|
seafile-client:
|
||||||
restart: always
|
restart: always
|
||||||
image: snegov/seafile-client
|
image: snegov/seafile-client
|
||||||
container_name: seafile-client
|
|
||||||
environment:
|
environment:
|
||||||
- LIBRARY_ID=<your-library-id-here>
|
- LIBRARY_ID="79867cbf-2944-488d-9105-859463ecdf9e:8078e3ff-b2a0-450a-b4dd-c1ed9ef18294"
|
||||||
- SERVER_HOST=<server-host>
|
- SERVER_HOST=seafile.example.com
|
||||||
- SERVER_PORT=<server-port>
|
- USERNAME=user
|
||||||
- USERNAME=<username>
|
- PASSWORD=password
|
||||||
- PASSWORD=<password>
|
- SEAFILE_UID=1000
|
||||||
- DATA_DIR=<directory-path-to-sync>
|
- SEAFILE_GID=100
|
||||||
- SEAFILE_UID=<your_uid>
|
hostname: docker-seafcli
|
||||||
- SEAFILE_GID=<your_gid>
|
|
||||||
volumes:
|
volumes:
|
||||||
- <host-volume-path>:<directory-path-to-sync>
|
- seafile-data:/seafile-client/seafile-data
|
||||||
|
- /home/johndow/seafile:/data
|
||||||
|
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
seafile-data:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
@@ -14,8 +15,9 @@ logging.basicConfig(format="%(asctime)s %(message)s",
|
|||||||
|
|
||||||
|
|
||||||
class SeafileClient:
|
class SeafileClient:
|
||||||
def __init__(self, host: str, port: int, user: str, passwd: str):
|
def __init__(self, host: str, user: str, passwd: str):
|
||||||
self.url = f"https://{host}:{port}"
|
up = urlparse(requests.get(f"http://{host}").url)
|
||||||
|
self.url = f"{up.scheme}://{up.netloc}"
|
||||||
self.user = user
|
self.user = user
|
||||||
self.password = passwd
|
self.password = passwd
|
||||||
self.__token = None
|
self.__token = None
|
||||||
|
|||||||
9
start.py
9
start.py
@@ -11,11 +11,10 @@ from seafile_client.misc import setup_uid, create_dir
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("--uid", default=os.getenv("SEAFILE_UID"), type=int)
|
parser.add_argument("--uid", default=os.getenv("SEAFILE_UID", default=1000), type=int)
|
||||||
parser.add_argument("--gid", default=os.getenv("SEAFILE_GID"), type=int)
|
parser.add_argument("--gid", default=os.getenv("SEAFILE_GID", default=100), type=int)
|
||||||
parser.add_argument("--data-dir", default=os.getenv("DATA_DIR"))
|
parser.add_argument("--data-dir", default=os.getenv("DATA_DIR", default="/data"))
|
||||||
parser.add_argument("--host", default=os.getenv("SERVER_HOST"))
|
parser.add_argument("--host", default=os.getenv("SERVER_HOST"))
|
||||||
parser.add_argument("--port", default=os.getenv("SERVER_PORT"), type=int)
|
|
||||||
parser.add_argument("--username", default=os.getenv("USERNAME"))
|
parser.add_argument("--username", default=os.getenv("USERNAME"))
|
||||||
parser.add_argument("--password", default=os.getenv("PASSWORD"))
|
parser.add_argument("--password", default=os.getenv("PASSWORD"))
|
||||||
parser.add_argument("--libs", default=os.getenv("LIBRARY_ID"))
|
parser.add_argument("--libs", default=os.getenv("LIBRARY_ID"))
|
||||||
@@ -24,7 +23,7 @@ def main():
|
|||||||
setup_uid(args.uid, args.gid)
|
setup_uid(args.uid, args.gid)
|
||||||
start_seaf_daemon()
|
start_seaf_daemon()
|
||||||
create_dir(args.data_dir)
|
create_dir(args.data_dir)
|
||||||
client = SeafileClient(args.host, args.port, args.username, args.password)
|
client = SeafileClient(args.host, args.username, args.password)
|
||||||
for lib_id in args.libs.split(sep=":"):
|
for lib_id in args.libs.split(sep=":"):
|
||||||
client.sync_lib(lib_id, args.data_dir)
|
client.sync_lib(lib_id, args.data_dir)
|
||||||
client.watch_status()
|
client.watch_status()
|
||||||
|
|||||||
Reference in New Issue
Block a user