173 Commits

Author SHA1 Message Date
Florian Anceau
3670ad2fb8 Merge branch '75-libraries-name-fetched-from-the-environment-variables-are-not-formatted-to-lower-case' into 'master'
Format librairies name fetched from envvars to lower case.

Closes #75

See merge request flrnnc-oss/docker-seafile-client!22
2024-09-24 11:32:25 +00:00
Florian Anceau
062f57f002 Format librairies name fetched from envvars to lower case. 2024-09-24 11:32:24 +00:00
Florian Anceau
0b49050521 Fix build badge script ordering 2024-09-19 22:40:30 +00:00
Florian Anceau
62c80d3cac Merge branch 'fix--skip-ssl-cert' into 'master'
Fix skip SSL certificate parameter

Close #72

See merge request flrnnc-oss/docker-seafile-client!21
2024-09-19 21:51:17 +00:00
Florian Anceau
a86c629d64 Fix skip SSL certificate parameter 2024-09-19 21:51:17 +00:00
Florian Anceau
085e2db3d9 Fix usage of full_description. 2024-09-18 14:25:48 +00:00
Florian Anceau
327ee22307 Fix the docker-old filename, move the short description to CI/CD variables. 2024-09-17 21:42:02 +00:00
flowgunso
10e004a92d Update all links, close #70 2024-08-24 22:46:19 +02:00
flowgunso
0c186bea29 Apply proper documentation 2024-08-24 20:50:56 +02:00
flowgunso
fc3991a9cd Use appropriate document 2024-08-24 20:47:33 +02:00
flowgunso
377831b972 Fix path 2024-08-24 20:31:53 +02:00
flowgunso
afedea4c72 Fix the filename again 2024-08-24 20:18:29 +02:00
flowgunso
944c8c4ea9 Fix filename 2024-08-24 20:03:21 +02:00
flowgunso
e4e95c3bbc Push licencing years 2024-08-24 19:40:16 +02:00
flowgunso
7cd3eabdd6 Debug 2024-08-24 19:40:03 +02:00
flowgunso
95daece6a3 Add missing suffix for Docker tags 2024-08-24 19:08:40 +02:00
flowgunso
3323912c61 Fix CI/CD variables 2024-08-24 18:47:55 +02:00
Florian Anceau
0570e3965e Log changes 2024-08-24 14:42:12 +00:00
Florian Anceau
f423949bff Merge branch '68-migrate-to-flrnnc-docker-hub-organization' into 'master'
Migrate to flrnnc Docker Hub organization.

Closes #60 and #69

See merge request florian.anceau-oss/docker-seafile-client!20
2024-08-24 14:19:24 +00:00
Florian Anceau
659e102935 Migrate to flrnnc Docker Hub organization. 2024-08-24 14:19:24 +00:00
Florian Anceau
3375aca7dd Merge branch '61-create-a-last-build-date-badge' into 'master'
Update the build badge date on builds

Closes #61

See merge request florian.anceau-oss/docker-seafile-client!19
2024-06-27 06:37:33 +00:00
Florian Anceau
b2e855ec52 Update the build badge date on builds 2024-06-27 06:37:32 +00:00
Florian Anceau
214bb03a2b typo 2024-06-09 21:28:58 +00:00
Florian Anceau
a49cfccc7b Improve #53 2024-06-09 21:27:55 +00:00
Florian Anceau
b1a1c11676 Improved the readme #53 2024-06-09 21:14:15 +00:00
Florian Anceau
3bcd083837 Remove badges from the README 2024-06-09 21:03:54 +00:00
Florian Anceau
4cec73c7b8 Merge branch '54-latest-tag-was-not-published-on-docker-hub' into 'master'
Allow latest tag to be published, restrict SAST jobs to approved MR

Closes #54 and #58

See merge request florian.anceau-oss/docker-seafile-client!18
2024-06-09 12:57:15 +00:00
Florian Anceau
fe793698e7 Allow latest tag to be published, restrict SAST jobs to approved MR 2024-06-09 12:57:15 +00:00
Florian Anceau
bd098de313 Merge branch '62-use-the-badge-from-the-project-itself-rely-on-the-api-to-build-the-document' into 'master'
Use the badge from the project itself. Rely on the API to build the document

Closes #62

See merge request florian.anceau-oss/docker-seafile-client!17
2024-06-09 10:38:03 +00:00
Florian Anceau
0743bd7c21 Use the badge from the project itself. Rely on the API to build the document 2024-06-09 10:38:03 +00:00
Florian Anceau
eaa8a1edeb Merge branch '64-using-gid-100-early-exit-with-code-4' into 'master'
Change the users group GID from 100 to 90

Closes #64

See merge request florian.anceau-oss/docker-seafile-client!16
2024-06-06 20:56:51 +00:00
Florian Anceau
95aacc7847 Change the users group GID from 100 to 90 2024-06-06 20:56:51 +00:00
Florian Anceau
b192910a2f Merge branch '63-rpc-client-does-not-get-instanciated' into 'master'
Instanciate the RPC at initialization

Closes #63

See merge request florian.anceau/docker-seafile-client!14
2024-06-02 13:41:01 +00:00
Florian Anceau
1928ec8190 Instanciate the RPC at initialization 2024-06-02 13:41:01 +00:00
Florian Anceau
e6bbd483cc Merge branch '51-build-badge-does-not-work' into 'master'
Use working pipeline badge

Closes #51

See merge request florian.anceau/docker-seafile-client!12
2024-05-27 21:43:38 +00:00
Florian Anceau
b2a60e2041 Use working pipeline badge 2024-05-27 21:43:37 +00:00
Florian Anceau
415024b1e2 Merge branch '56--moving-to-gitlab-open-source-program' into 'master'
Apply to open source programs. (#56)

See merge request florian.anceau/seafile-client!11
2024-05-26 21:44:25 +00:00
Florian Anceau
20e321d930 Apply to open source programs. 2024-05-26 21:44:25 +00:00
Florian Anceau
3cf6b608b2 Merge branch 'fix--documents-rendering' into 'master'
Fix documents renderings, except for the missing changelog in the Seafile forum render

See merge request florian.anceau/seafile-client!10
2024-05-26 20:00:49 +00:00
flow.gunso
772b8ca89d Fix documents renderings, except for the missing changelog in the Seafile forum render 2024-05-26 20:00:49 +00:00
flow.gunso
5230067d82 Add LiberaPay sponsoring (#50) 2024-04-07 09:01:51 +00:00
flow.gunso
8dbe494b87 Merge branch 'milestone--v3' into 'master'
Version 3

Closes #24, #10, #38, #39, #6, #42, #9, #25, #44, #43, #41, and #37

See merge request flwgns-docker/seafile-client!9
2024-03-16 21:58:04 +00:00
flow.gunso
f25b0182d2 Version 3
Support for multiple libraries synchronization (#44, #43, #41)
Support for Docker Secrets (#25)
Support for Seafile client's version through Docker tags (#9)
Mock Seafile server for testings (#6)
Revised project layout and workflow (#38, #39)
Working Docker Hub description publishing (#10)
2024-03-16 21:58:04 +00:00
flow.gunso
4c347b9156 Downgrade dependencies 2022-08-26 17:03:10 +02:00
flow.gunso
b09641641c Fix path 2022-08-26 16:52:37 +02:00
flow.gunso
4fe0e733a2 Reference to MR 2022-08-26 13:02:51 +02:00
flow.gunso
f43a0ecd41 Bump to v2.2.0 2022-08-26 13:00:14 +02:00
flow.gunso
35dda1c9e0 Merge branch 'master' into 'master'
Updated debian to bullseye and improved client installation

See merge request flwgns-docker/seafile-client!7
2022-08-23 05:29:35 +00:00
Patrick Bußmann
710b3818f1 Updated debian to bullseye and improved client installation 2022-08-23 05:29:35 +00:00
flow.gunso
2c9b66e5f3 Add a contributing page 2020-09-25 20:22:09 +02:00
flow.gunso
fe73a237ae Merge branch '#20--typo-package-update-notifier' into 'master'
Merge fix for issue #20

See merge request flwgns-docker/seafile-client!1
2020-05-18 12:39:12 +00:00
flow.gunso
f597db2f1b Fix typo in issue_id variable, see #20 2020-05-18 14:34:54 +02:00
flow.gunso
f3af39896c Refactor RpcClient instantiation parameters 2020-05-11 17:41:10 +02:00
flow.gunso
a30097bdde Move up description template stage with other build stages 2020-03-14 11:35:48 +01:00
flow.gunso
ed41ec6415 Add missing licence headers 2020-03-14 11:35:47 +01:00
flow.gunso
4e3e17fbd7 Merge #18--notify-with-issue-on-package-update
Close #18
2020-03-14 11:35:42 +01:00
flow.gunso
2470dcb124 Remove tests (#18) 2020-03-14 10:16:45 +01:00
flow.gunso
7b02f7c360 Fix Bash syntax 2020-03-14 09:58:39 +01:00
flow.gunso
13d2ca6f78 Testing some hard to reach instrunctions 2020-03-13 23:14:26 +01:00
flow.gunso
ba77217235 Fix Bash syntax 2020-03-13 21:38:06 +01:00
flow.gunso
cdd6d82a45 Add the stage report, remove schedules from test stage, add bot:package_update_notification to report stage 2020-03-13 21:31:22 +01:00
flow.gunso
9483b81767 Move the check script down into the bulid stage 2020-03-13 21:22:02 +01:00
flow.gunso
9f7ab04cda Add first draft of the package update notification 2020-03-13 19:59:15 +01:00
flow.gunso
be076f9a89 Change status of #14 in v2.1.1 to closed 2020-03-13 12:09:07 +01:00
flow.gunso
c5dca12cb2 Merge enhancement--tweak-readme-badges into master 2020-03-12 08:31:35 +01:00
flow.gunso
556e9f5228 Remove the request to the MicroBadger update webhook (#15) 2020-03-12 08:29:49 +01:00
flow.gunso
46eaa93de9 Merge enhancement--tweak-readme-badges into master
Close #15.
2020-03-11 18:06:12 +01:00
flow.gunso
dd9ea8df75 Drop Microbadger badges in favor of shields.io badges (#15) 2020-03-11 17:54:20 +01:00
flow.gunso
fcd691ad97 Log #5 status 2020-03-10 22:56:59 +01:00
flow.gunso
03499c491c Log #16 status 2020-03-10 22:56:01 +01:00
flow.gunso
c270ab3713 Merge changes from enhance--documentations-templates into master, close #16 2020-03-10 22:53:46 +01:00
flow.gunso
50b1da8a00 Enable templater stage on tags only 2020-03-10 22:48:55 +01:00
flow.gunso
a24300b7a5 Fix the path to the Python templater script 2020-03-10 22:42:36 +01:00
flow.gunso
9ccbd7b7a3 Fix image name of templater stage 2020-03-10 22:38:54 +01:00
flow.gunso
ee35c0d9b8 Enable the templater on it's branch 2020-03-10 22:37:02 +01:00
flow.gunso
6b52b102c8 Add a templater for both Docker Hub and Seafile's forum project description 2020-03-10 22:34:43 +01:00
flow.gunso
878887361a Log and push v2.1.1 2020-03-10 14:21:49 +01:00
flow.gunso
fa3bc5e596 Merge changes from bug--restart-fail-infinitely into master 2020-03-10 14:17:57 +01:00
flow.gunso
8d46c1de76 Prevent initializing/synchronizing if container is restarted and not deleted, see #14 2020-03-10 14:13:39 +01:00
flow.gunso
4b0af17cec Log #14, push version to 2.1.0 2020-01-30 21:42:08 +01:00
flow.gunso
7c39ab53ed Merge changes from bug--restart-fail-infinitely into master 2020-01-30 21:39:26 +01:00
flow.gunso
9438004c9d Implement a workaround with debugging, see #14 2020-01-30 21:38:33 +01:00
flow.gunso
1f5fcf8c29 Remove obsolete file, see #13 2020-01-30 18:10:47 +01:00
flow.gunso
0197cf898e Log changes from bug--unhealthy-healthchecks 2020-01-30 18:08:45 +01:00
flow.gunso
00e14bd3c8 Merge changes from bug--unhealthy-healthchecks into master, closing #13 2020-01-30 18:03:06 +01:00
flow.gunso
0cff1f8247 Ignore docker-compose test file 2020-01-30 17:47:54 +01:00
flow.gunso
ca82cd5aec Tweak to run the healthchecks 2020-01-30 17:46:59 +01:00
flow.gunso
959749d6ed Call the Python healthcheck script as the seafile user 2020-01-30 17:45:59 +01:00
flow.gunso
7efb910719 Check the repo sync/transfer task states 2020-01-30 17:45:22 +01:00
flow.gunso
a4100b50ae Test a direct approach to healtchecking 2020-01-29 09:23:56 +01:00
flow.gunso
c695fe2a87 Copy updated healthcheck scripts, set Python script as executable 2020-01-29 09:23:26 +01:00
flow.gunso
91a31bfa00 Rename healthcheck.py into seafile-healthcheck.py 2020-01-29 09:22:18 +01:00
flow.gunso
d82f7e47ad Update Seafile healthcheck script with the new python script 2020-01-29 09:17:26 +01:00
flow.gunso
46bd227b90 Draft new healthcheck script that use seafile's python module 2020-01-29 09:15:32 +01:00
flow.gunso
254722f3ad Ignore Python byte codes 2020-01-29 09:14:15 +01:00
flow.gunso
1c9f036a1b Fix the line breaks in the Docker CLI example 2020-01-15 21:22:27 +01:00
flow.gunso
fe1ca24a49 Add UID/GID environment variables to the all configurations example 2020-01-15 21:01:52 +01:00
flow.gunso
c6451a9429 Remove stage name suffix 2020-01-15 21:00:03 +01:00
flow.gunso
6fe8a5d533 Merge change from enhancement--microbadger-badges into master, close #5 2020-01-15 20:59:12 +01:00
flow.gunso
cd332a8691 Add the badge! 2020-01-15 20:57:32 +01:00
flow.gunso
fcd5c71820 Push and log changes coming in v2.0.3 2020-01-14 22:22:20 +01:00
flow.gunso
c387f0fcea Merge changes from enhancement--microbadger-badges into master, ongoing #5 2020-01-14 22:19:50 +01:00
flow.gunso
dc984b0ea1 I've read the docs now, define passed variable with the ARG instruction 2020-01-14 22:18:47 +01:00
flow.gunso
aa98abafc2 Push and log changes coming in v2.0.2 2020-01-14 22:03:29 +01:00
flow.gunso
f1de7f880e Merge changes from enhancement--microbadger-badges into master, ongoing #5 2020-01-14 21:57:05 +01:00
flow.gunso
f46ea7746f Propagate environment variables into the Dockerfile 2020-01-14 21:55:40 +01:00
flow.gunso
57fbd7d483 Merge changes from bug--missing-curl-to-trigger-microbadger into master, fix #12 2020-01-14 21:48:20 +01:00
flow.gunso
eec8d0aa38 Install the curl package to trigger an update on MicroBadger 2020-01-14 21:47:05 +01:00
flow.gunso
ac7426e879 Push and log changes coming in v2.0.1 2020-01-14 21:30:38 +01:00
flow.gunso
186ffd1f45 Merge changes from bug--chown-issues into master, fix #11 2020-01-14 21:20:15 +01:00
flow.gunso
648df8b9cb Fix the ownership change to the library path 2020-01-14 21:18:48 +01:00
flow.gunso
8dc4c9d234 Comment the healthcheck since it's not in the image anymore 2020-01-14 21:18:02 +01:00
flow.gunso
46b3729639 Merge changes from enhancement--microbadger-badges into master, related to #5 2020-01-14 21:15:43 +01:00
flow.gunso
95b5de700e Remove debugging stage 2020-01-14 21:14:26 +01:00
flow.gunso
832618477e Pass the CI_PROJECT_URL as a build argument 2020-01-14 21:14:05 +01:00
flow.gunso
92ebbee242 Debug the content of Gitlab's $CI_PROJECT_URL 2020-01-14 21:08:25 +01:00
flow.gunso
6e0d51d735 Add comments 2020-01-08 14:11:26 +01:00
flow.gunso
578676d121 Post the MicroBadger webhook to trigger an update (#5) 2020-01-08 14:03:57 +01:00
flow.gunso
3455c65959 Remove scheduled CI jobs 2020-01-08 11:46:46 +01:00
flow.gunso
c63fa89e23 Fix the loop that generate the version tags 2020-01-07 22:01:00 +01:00
flow.gunso
a11a6ad68d Fix Docker image version tagging 2020-01-07 21:53:11 +01:00
flow.gunso
dfd6229f3f Fix docker tag parameter order 2020-01-07 21:46:09 +01:00
flow.gunso
e2bf73a78b Disable the Docker Hub description update job 2020-01-07 21:39:44 +01:00
flow.gunso
2ba6477d90 Fix the image being tagged 2020-01-07 21:38:20 +01:00
flow.gunso
fe1df17b65 Add missing ;then, remove obsolete symlink 2020-01-07 21:29:41 +01:00
flow.gunso
0e7c402b82 Merge changes from milestone--2.0 into master 2020-01-07 21:02:55 +01:00
flow.gunso
474a2f26ad Uncomment the Docker tag/push 2020-01-07 20:58:47 +01:00
flow.gunso
7712fb8066 Add pre-check, remove milestone--2.0 from CI jobs 2020-01-07 12:21:28 +01:00
flow.gunso
2344c6027e Add the milestone--2.0 branch to the CI publish job 2020-01-07 12:14:20 +01:00
flow.gunso
a2ad2990ea Fix path to tests 2020-01-07 10:34:49 +01:00
flow.gunso
ff117e8b95 Display successful tests 2020-01-07 10:34:35 +01:00
flow.gunso
34df27de8f Fix the scripts paths 2020-01-07 10:16:10 +01:00
flow.gunso
84e299e4dd Divide jobs and scripts by use case 2020-01-07 10:13:25 +01:00
flow.gunso
f2783a04b3 Install git in before_script, run script with -e flag to catch failures 2020-01-06 23:29:22 +01:00
flow.gunso
0e15bc856d Fix the artifact paths key 2020-01-06 23:16:57 +01:00
flow.gunso
29c0dac564 Enable build and tests for the milestone--2.0 branch 2020-01-06 23:13:00 +01:00
flow.gunso
c24858ce59 Log the changes for 2.0 2020-01-06 23:12:35 +01:00
flow.gunso
4cbeea381d Revise and reword 2020-01-06 23:12:21 +01:00
flow.gunso
6d020b4c2a Rename the volume for consistency 2020-01-06 22:59:57 +01:00
flow.gunso
b0afee7b64 Move into documentations directory 2020-01-06 22:54:52 +01:00
flow.gunso
7a7187deef Remove the restart parameter 2020-01-06 22:53:51 +01:00
flow.gunso
ce0e30b50c Revert to the default healthcheck interval 2020-01-06 22:53:32 +01:00
flow.gunso
642e98cc12 Comment the cron-based healthcheck 2020-01-06 22:52:47 +01:00
flow.gunso
dcceb61730 Change the synchronized path to /library for consistency 2020-01-06 22:51:50 +01:00
flow.gunso
00e72634da Add new environment variables, format to yaml 2020-01-06 20:40:06 +01:00
flow.gunso
59cf0d11ac Switch to double bracket tests, improve readability 2020-01-06 20:20:46 +01:00
flow.gunso
fc271c8722 Remove the cron binary from tests 2020-01-06 20:20:46 +01:00
flow.gunso
87c40f3f95 Switch to double bracket tests, reduce redundancy 2020-01-06 20:20:45 +01:00
flow.gunso
9bae0fafc9 Improve minor comments and instructions 2020-01-06 20:20:45 +01:00
flow.gunso
179c70a4fa Explicitly close entrypoint options 2020-01-06 20:20:45 +01:00
flow.gunso
7543a06f51 Implement a basic healthcheck 2020-01-06 20:20:44 +01:00
flow.gunso
eb5c9a1650 Create the .seafile directory at moment of build 2020-01-06 20:20:44 +01:00
flow.gunso
8b00ea6bcb Do not install cron 2020-01-06 20:20:43 +01:00
flow.gunso
c882874383 Add the label maintainer 2020-01-06 20:20:43 +01:00
flow.gunso
4b18dc7d6a Remove cron in favor of tailing the log as a keep-alive method 2020-01-06 20:20:43 +01:00
flow.gunso
db9546f71b Fix healthcheck path 2020-01-06 20:20:42 +01:00
flow.gunso
39007bf56e Remove obsolete 2fa setup 2020-01-06 20:20:42 +01:00
flow.gunso
a3d1580c6a Push years 2020-01-06 20:20:42 +01:00
flow.gunso
d16a21758f Move Dockerfile and assets, add labels for MicroBadger 2020-01-04 10:07:24 +01:00
flow.gunso
1741ddb98d Add basic test scripts 2020-01-04 10:05:34 +01:00
flow.gunso
bf2d04f036 Implement the new CI scripts 2020-01-04 10:05:14 +01:00
flow.gunso
cc9273a982 Add new CI scripts that check, build, test and publish the images, move the .utilities 2020-01-04 10:04:52 +01:00
flow.gunso
67ecaa91b5 Remove supervisord and bash versions 2020-01-04 10:03:23 +01:00
flow.gunso
9f526467fe Implement upload/download limits, disable_verify_certificates config keys 2019-12-30 10:09:06 +01:00
flow.gunso
8e33c7431e Create as a symlink to asset/cron/Dockerfile 2019-12-30 09:58:03 +01:00
flow.gunso
8267535a97 Remove hard file 2019-12-30 09:57:30 +01:00
flow.gunso
06f184d1ad Add an envvar to skip ssl certificates that default to false 2019-12-30 09:56:32 +01:00
flow.gunso
9af5f1bde9 Move changes from the project's Dockerfile here 2019-12-30 09:55:52 +01:00
flow.gunso
2412ada16a Merge change from staging into master closing #4 2019-12-30 00:11:57 +01:00
flow.gunso
f53f798e82 Push version to 1.2.1 and log associated changes 2019-12-30 00:00:50 +01:00
flow.gunso
0899bc6609 Merge changes from fix--unmet-dependencies into staging that close #4 2019-12-29 23:52:17 +01:00
flow.gunso
8663b11112 Switch to Debian Buster, install/uninstall gpg to import repo keys, improve cleanup 2019-12-29 23:49:43 +01:00
flow.gunso
755d019a65 Switch from colons to double ampersands to raise failures 2019-12-29 23:47:06 +01:00
53 changed files with 1754 additions and 981 deletions

6
.gitignore vendored
View File

@@ -1 +1,5 @@
.idea/
*.pyc
.env/
tarballs/
VERSIONS.txt
documentations/*.md

View File

@@ -1,40 +1,161 @@
image: docker:latest
services:
- docker:dind
- docker:dind
.parallel:
parallel:
matrix:
- TARGET: [oldstable, stable, unstable]
stages:
- build_publish
- schedule
- build
- test
- release
before_script:
- apk add bash
include:
- template: Jobs/Code-Quality.gitlab-ci.yml
- template: Jobs/SAST.latest.gitlab-ci.yml
cron_or_supervisord:
stage: build_publish
build:
stage: build
before_script:
- apk add bash git curl jq make
script:
- /bin/bash utils/publish/feature--cron-or-supervisord.sh
only:
- feature--cron-or-supervisord
- make build
- make save
extends: .parallel
rules:
- if: $CI_COMMIT_TAG
- if: $CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE !~ /^Draft/
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE == "weekly-build"
artifacts:
paths:
- "tarballs/"
staging:
stage: build_publish
test:
stage: test
before_script:
- apk add bash git curl jq make
script:
- /bin/bash utils/publish/staging.sh
only:
- staging
- make load
- make build-test
- make test
extends: .parallel
needs:
- job: build
parallel:
matrix:
- TARGET: oldstable
- TARGET: stable
- TARGET: unstable
rules:
- if: $CI_COMMIT_TAG
- if: $CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE !~ /^Draft/
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE == "weekly-build"
artifacts:
paths:
- tarballs/
production:
stage: build_publish
publish-images:
stage: release
before_script:
- apk add bash git curl jq make
script:
- /bin/bash utils/publish/production.sh
only:
- tags
except:
- branches
- export
- make load
- make publish-images
needs:
- job: build
parallel:
matrix:
- TARGET: oldstable
- TARGET: stable
- TARGET: unstable
- job: test
extends: .parallel
rules:
- if: $CI_COMMIT_TAG
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE == "weekly-build"
- when: never
artifacts:
paths:
- tarballs/
- versions/*
variables:
CI_DEBUG_TRACE: "true"
update_docker_hub_full_description:
stage: build_publish
make-documents:
stage: release
before_script:
- apk add bash git curl jq make py3-jinja2 py3-gitlab
script:
- /bin/bash utils/publish/update-docker-hub-full-description.sh
only:
- master
- make documents
needs:
- job: publish-images
parallel:
matrix:
- TARGET: oldstable
- TARGET: stable
- TARGET: unstable
rules:
- if: $CI_COMMIT_TAG
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE == "weekly-build"
- when: never
artifacts:
paths:
- versions/*
- documentations/*.md
publish-documents:
stage: release
before_script:
- apk add bash git curl jq make py3-gitlab
script:
- make publish-documents
needs:
- job: make-documents
rules:
- if: $CI_COMMIT_TAG
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE == "weekly-build"
- when: never
artifacts:
paths:
- documentations/*.md
weekly-build-disable:
stage: release
needs:
- job: publish-documents
before_script:
- apk add bash git curl jq make py3-requests py3-gitlab
script:
- make unschedule-weekly-build
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE == "weekly-build"
- when: never
weekly-build-scheduler:
stage: schedule
before_script:
- apk add bash git curl jq make py3-requests py3-gitlab
script:
- make schedule-weekly-build
rules:
- if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE == "weekly-build-scheduler"
- when: never
artifacts:
reports:
metrics: metrics.txt
code_quality:
rules:
- if: $CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE !~ /^Draft/
- when: never
semgrep-sast:
rules:
- if: $CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE !~ /^Draft/
- when: never

View File

@@ -1,35 +1,223 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
<!-- To log a new version, copy, uncomment, add your changes, then add the tag shortcut at the end of the file -->
<!-- Unreleased --/>
## [Unreleased] - year-month-date
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security
[Unreleased]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/Unreleased
<!-- /Unreleased /-->
<!-- 3.4.0 -->
## [3.4.0] - 2024-09-24
### Added
- Explicit project name to mock Docker Compose.
### Fixed
- Librairies name are formatted to lower case (#75).
- Use for $TARGET in mock Docker Compose.
- Fix pipeline jobs rules, specifically on Draft MR.
[3.4.0]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/3.4.0
<!-- /3.4.0 -->
<!-- 3.3.0 -->
## [3..0]
### Modified
* Add TARGET environment variable to Makefile commands.
### Fixed
* Fix the TypeError for the skip SSL certificates parameters.
[3.3.0]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/3.3.0
<!-- /3.3.0 -->
<!-- 3.2.5 -->
## [3.2.5]
### Modified
* Use CI/CD environment variables for the Docker Hub short description
### Fixed
* The file name used for the Docker Hub full description
[3.2.5]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/3.2.5
<!-- /3.2.5 -->
<!-- 3.2.4 -->
## [3.2.4]
### Added
* Publish to the new flrnnc/seafile-client repository.
* Write notices regarding the Docker repository move.
### Changed
* Use new CI/CD variables.
* Do not run pipelines on Draft MR. (#69)
### Removed
* Remove the changelog from the Seafile documentation.
[3.2.4]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/3.2.4
<!-- /3.2.4 -->
## [3.2.3] - 2024/06/27
### Changed
- Update the build badge date on builds. (#61)
[3.2.3]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/3.2.3
<!-- /3.2.3 -->
## [3.2.2] - 2024/06/09
### Fixed
- Allow the latest tag to be applied to the v9 versions. (#54)
- Restricted SAST jobs to approved pipelines. (#58)
[3.2.2]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/3.2.2
<!-- /3.2.2 -->
## [3.2.1] - 2024/06/09
### Added
- Merge requests pipeline only runs when merge request has been approved.
### Changed
- Badges are rendered from the Gitlab project itself, not from code. (#62)
[3.2.1]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/3.2.1
<!-- /3.2.1 -->
## [3.2.0] - 2024/06/06
### Changed
- Changed the group _users_ GID from 100 to 90. This allow to use the GID 100. (#64)
[3.2.0]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/3.2.0
<!-- /3.2.0 -->
## [3.1.0] - 2024/06/02
### Changed
- Disable pipelines on approved merge requests
### Fixed
- Instanciate the RPC client at the initialization (#63)
[3.1.0]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/3.1.0
<!-- /3.1.0 -->
## [3.0.1] - 2024/05/27
### Added
* New script to schedule the best possible time to run the build. It relies on WattTime Load Shift feature (#56)
* Weekly build through pipeline schedules. (#56)
### Changed
* Every links pointing to the previous repository flwgns-docker/seafile-client are pointing now to flrnnc-oss/docker-seafile-client. (#56)
[3.0.1]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/3.0.1
<!-- /3.0.1 -->
## [3.0.0] - 2024/03/16
### Added
- Support for multiple libraries synchronization (#44, #43, #41)
- Support for Docker Secrets (#25)
- Support for Seafile client's version through Docker tags (#9)
- Build documentation with Jinja2 templates (#42)
- Manage the project with a Makefile (#38)
- Mock Seafile server for testings (#6)
### Changed
- Revised project layout and workflow (#38, #39)
### Fixed
- Fixed the Docker Hub description publish through their API (#10)
- Add ca-certificates and gnupg to support more HTTP certificates (#24)
[3.0.0]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/3.0.0
<!-- /3.0.0 -->
## [2.2.0] - 2022/08/26
- Update from Debian Buster to Debian Bullseye (!7)
- Improved Seafile apt source installation (!7)
## [2.1.1] - 2020/03/10
- Prevent re-initialization and re-synchronization of the container if it's life cycle change but is not deleted (#14)
## [2.1.0] - 2020/01/30
- Replace previous Bash script that parse `seaf-cli status` with a Python script that use pysearpc to run checks (#13)
- Implement a workaround to probable issue, waiting for the issue to appear (#14)
## [2.0.3] - 2020/01/14
- Read [the docs](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg) a bit more (#5)
## [2.0.2] - 2020/01/14
- Propagate the CI_COMMIT_TAG and CI_PROJECT_URL environment variables into the Dockerfile as [the docs states](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg) (#5)
## [2.0.1] - 2020/01/14
- Update chown path to library, comment chown to an obsolete healthcheck.sh (#11)
- Pass $CI_PROJECT_URL to the Dockerfile as a build argument (#5)
## [2.0.0] - 2020/01/06
- Support 2FA authentication through `oathtool` using the secret key
- Support for upload/download limits
- Support for Seafile library password
- Allow skipping SSL certificates verifications
- Drop Bash/supervisord/cron implementations in favor of showing seafile's log
- Implement basic integration tests that check expected binairies
- Improve continuous integration though splitted jobs
- Revise README
- Change the volume path from /volume to /library for consistency
## [1.2.1] - 2019/12/29
- Switch base image from Debian oldoldstable Jessie to Debian stable Buster to fix unmet dependencies of `seafile-cli` to `python-future` and `python-searpc` (#4)
- Replace `;` with `&&` as commands separators in the Dockerfile's `RUN` to properly report failed commands at CI (#4)
## [1.2.0] - 2019/05/02
- Replace _supervisord_ with _cron_ for running the front job that keeps the container up. It uses less resources.
- Improve the __infinite-seaf-cli-start.sh__ into __seafile-healthcheck.sh__. The Seafile daemon will not be restarted if it's state are either _downloading_ or _committing_, which otherwise is problematic.
- Improve the infinite-seaf-cli-start.sh into seafile-healthcheck.sh. The Seafile daemon will not be restarted if it's state are either _downloading_ or _committing_, which otherwise is problematic.
### [1.1.2] - 2019/04/18
## [1.1.2] - 2019/04/18
- Slim down the Docker image, from 102MB to 67MB, gaining 35MB, reducing size by 34%.
### [1.1.1] - 2019/04/18
## [1.1.1] - 2019/04/18
- Because of the infinite-seaf-cli-start loop, within the container was running many seaf-daemons. Now, the infinite loop stop the current seaf-daemon before starting it again. (see #3)
## [1.1.0] - 2019/04/09
- The container now actually use the UID/GID provided to it:
The container entrypoint is run with root, then another entrypoint is run by the container's user, seafuser, to run the Seafile client.
### [1.0.6] - 2019/03/25
## [1.0.6] - 2019/03/25
- More minor fixes from v1.0.4
### [1.0.5] - 2019/03/25
## [1.0.5] - 2019/03/25
- Minor fixes from v1.0.4
### [1.0.4] - 2019/03/25
## [1.0.4] - 2019/03/25
- Fix the build target detection (@a52559ddb38a64d7fceaa8bf9b8afd7356ccc439)
- Login to the Docker Hub from within the script, not the gitlab-ci.yml, using (@72bab017c1167b8ab35cef3cc709ff83686eaca4, @f69483354a4cf8afdbea89ef2bb1d9a9b7b2ac10)
- Require Bash on all Gitlab CI stages (@72bab017c1167b8ab35cef3cc709ff83686eaca4)
- Add a script to push the README.md into the Docker Hub repository's full_description (@8cb49cbc8253368701d718c2e38017790c78ceca, @ca6128fb96602da71f3b7a560e834d1b7587abac)
### [1.0.3] - 2019/03/19
## [1.0.3] - 2019/03/19
- Restrict staging pipelines to pushed pipelines
- Restrict production pipelines to pushed and triggered pipelines
- Require a build target on triggered production pipelines
### [1.0.2] - 2019/03/18
## [1.0.2] - 2019/03/18
- Fix a minor issue when testing for requested production build.
### [1.0.1] - 2019/03/18
## [1.0.1] - 2019/03/18
- Add failsafe when importing Seafile's APT-key
- Restrict production build to latest, majors, minors and revisions version, on-demand.
# [1.0.0] - 2019/03/15
## [1.0.0] - 2019/03/15
- Release to Docker Hub
# [0.9.2] - 2019/03/15
## [0.9.2] - 2019/03/15
- Test release on GitLab, before Docker Hub
[2.2.0]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/2.2.0
[2.1.1]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/2.1.1
[2.1.0]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/2.1.0
[2.0.3]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/2.0.2
[2.0.2]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/2.0.2
[2.0.1]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/2.0.1
[2.0.0]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/2.0.0
[1.2.1]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/1.2.1
[1.2.0]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/1.2.0
[1.1.2]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/1.1.2
[1.1.1]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/1.1.1
[1.1.0]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/1.1.0
[1.0.6]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/1.0.6
[1.0.5]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/1.0.5
[1.0.4]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/1.0.4
[1.0.3]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/1.0.3
[1.0.2]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/1.0.2
[1.0.1]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/1.0.1
[1.0.0]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/1.0.0
[0.9.2]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/releases/0.9.2

115
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,115 @@
**Do you want to contribute ? Please do!**
* [How to help?](#how-to-help?)
* [Report issues, propose features](#report-issues-propose-features)
* [Solve problems](#solve-problems)
* [Say thanks](#say-thanks)
* [Project workflow](#project-workflow)
* [Environment](#environment)
* [Development](#development)
* [CI/CD](#ci/cd)
# How to help?
They are several ways to help and improve this project.
## Report issues, propose features
You think you found a bug ? You think something is missing out ? Check that it has not been [already reported](https://gitlab.com/flrnnc-oss/docker-seafile-client/-/issues). If it has not, [report it](https://gitlab.com/flrnnc-oss/docker-seafile-client/-/issues/new?issue).
## Solve problems
You can't wait for a problem to be solved ? Pick one from the [already reported problems](https://gitlab.com/flrnnc-oss/docker-seafile-client/-/issues) and solve it. It will be greatly appreciated!
## Say thanks
One great way to help is simply to say thanks. You can do that by [adding a star to the Docker Hub repository](https://hub.docker.com/r/flrnnc/seafile-client) or [just saying thanks in the project topic on Seafile's forum](https://forum.seafile.com/t/docker-client-to-sync-files-with-containers/8573).
# Project workflow
The ins and outs of the project, from setting up a local environment for developments to notifying users of changes.
To provide the different Seafile's client versions, the project rely on the [`seafile` package available throughout the different Debian versions][packages]. Check out [Debian Developer's Package Overview][ddpo] and [Debian Package Tracker][tracker] for in depth details regarding that package.
[packages]: https://packages.debian.org/search?keywords=seafile-cli
[ddpo]: https://qa.debian.org/developer.php?login=team%2Bseafile%40tracker.debian.org
[tracker]: https://tracker.debian.org/pkg/seafile
The following state diagram describe essentially the project workflow for a release.
```mermaid
stateDiagram-v2
feature: Checkout new branch from main
changes: Apply changes
mr: Create a Merge Request
pipelines: CI/CD pipelines must be successful
log: Changes must be documented
merge: Branch is squash merged into main
release: Release is created
[*] --> feature
feature --> changes
changes --> mr
mr --> pipelines
pipelines --> log
log --> merge
merge --> release
release --> [*]
```
## Environment
The following is required to develop:
* Docker engine
* Bash
* Make
## Management
The project managemenet is mostly run through the Makefile.
The parameter `TARGET` define on which Debian version the instructions are run.
The following instructions are available:
### mock
Start the Docker Compose mock for a Seafile server.
### unmock
Start the Docker Compose mock for a Seafile server.
### client
Purge and start the client service on the Docker Compose mock for a Seafile server.
### logs
Continuously display the logs from the client service on the Docker Compose mock for a Seafile server.
### build
Build the Seafile Docker client image depending on the `TARGET`.
### build-test
Build the Seafile Docker client test image depending on the `TARGET`.
### test
Run the Seafile Docker client test container.
### documents
Build the documentation for both Docker Hub and Seafile's forum.
### publish-images
Publish the Docker Seafile client image, properly tagged with the appropriate Seafile cliens versions.
### publish-documents
Publish the generated documentation on Docker Hub only
### save
Export the Seafile Docker client image as a tarball.
### load
Load the Seafile Docker client image from a tarball
## Pipelines
Pipelines are run either on merge requests or on commit tags.
The pipelines are divided into three stages:
* Build
* Test
* Release
Release jobs are obviously not run on merge requests.

View File

@@ -1,61 +0,0 @@
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM debian:jessie-slim
# Prevent the packages installation to halt.
ENV DEBIAN_FRONTEND noninteractive
# Create the seafile client user.
ENV UNAME=seafuser
ENV UID=1000
ENV GID=1000
# Copy over the Docker related files.
COPY utils/build/import-seafile-apt-key.sh /
COPY assets/cron/docker-entrypoint.sh /entrypoint.sh
# Safely import Seafile APT key, then install both seafile-cli and supervisord.
RUN mkdir -p /etc/apt/sources.list.d/ ;\
echo "deb http://deb.seadrive.org jessie main" \
> /etc/apt/sources.list.d/seafile.list ;\
bash /import-seafile-apt-key.sh ;\
apt-get update ;\
apt-get install \
-o Dpkg::Options::="--force-confold" \
-y \
seafile-cli \
cron ;\
apt-get clean ;\
apt-get autoclean \
-o APT::Clean-Installed=true ;\
rm \
-f \
/var/log/fsck/*.log \
/var/log/apt/*.log \
/var/cache/debconf/*.dat-old \
/import-seafile-apt-key.sh ;\
mkdir /volume/ ;\
echo "seafuser" > /etc/cron.allow ;\
echo "*/20 * * * * /bin/bash /home/seafuser/seafile-healthcheck.sh" \
> /var/spool/cron/crontabs/seafuser ;\
groupadd -g $GID -o $UNAME ;\
useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME
# Copy over the required files for Seafile/SupervisorD.
COPY assets/cron/seafile-healthcheck.sh /home/seafuser/seafile-healthcheck.sh
COPY assets/cron/seafile-entrypoint.sh /home/seafuser/entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

View File

@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2019 flow.gunso@gmail.com
Copyright (C) 2019-2024 florian.anceau@gmail.com
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

64
Makefile Normal file
View File

@@ -0,0 +1,64 @@
TARGET?=stable
# Mocking
mock:
TARGET=${TARGET} docker compose -f tests/mock/compose.yaml up -d
unmock:
TARGET=${TARGET} docker compose -f tests/mock/compose.yaml down
client:
TARGET=${TARGET} docker compose -f tests/mock/compose.yaml rm -fs client
TARGET=${TARGET} docker compose -f tests/mock/compose.yaml up -d client
shell:
TARGET=${TARGET} docker compose -f tests/mock/compose.yaml exec client bash
logs:
TARGET=${TARGET} docker compose -f tests/mock/compose.yaml logs -f client
ps:
TARGET=${TARGET} docker compose -f tests/mock/compose.yaml ps
# Build
build:
TARGET=${TARGET} CI_COMMIT_TAG=${CI_COMMIT_TAG} bash scripts/build-images.sh
build-test:
docker build --build-arg TARGET=${TARGET} -t seafile-client:test tests/image
test:
docker run seafile-client:test
# CI/CD
documents:
python scripts/update-build-badge.py
python scripts/make-documents.py docker.md.j2
python scripts/make-documents.py docker-old.md.j2
python scripts/make-documents.py seafile.md.j2
publish-images:
TARGET=${TARGET} \
DOCKER_REGISTRY_USERNAME=${DOCKER_REGISTRY_USERNAME} \
DOCKER_REGISTRY_TOKEN=${DOCKER_REGISTRY_TOKEN} \
DOCKER_REGISTRY_IMAGE_FLOWGUNSO=${DOCKER_REGISTRY_IMAGE_FLOWGUNSO} \
DOCKER_REGISTRY_IMAGE_FLRNNC=${DOCKER_REGISTRY_IMAGE_FLRNNC} \
bash scripts/publish-images.sh
publish-documents:
bash scripts/publish-documents.sh
save:
mkdir -p tarballs/
docker save --output tarballs/${TARGET}-flowgunso.tar seafile-client:${TARGET}-flowgunso
docker save --output tarballs/${TARGET}-flrnnc.tar seafile-client:${TARGET}-flrnnc
load:
docker load --input tarballs/${TARGET}-flowgunso.tar
docker load --input tarballs/${TARGET}-flrnnc.tar
schedule-weekly-build:
python scripts/schedule-build.py
unschedule-weekly-build:
python scripts/schedule-build.py --disable

203
README.md
View File

@@ -1,98 +1,159 @@
[![1.2.0 build status](https://gitlab.com/flwgns-docker/seafile-client/badges/1.2.0/pipeline.svg)](https://gitlab.com/flwgns-docker/seafile-client/commits/1.2.0)
[![Docker pulls](https://img.shields.io/docker/pulls/flowgunso/seafile-client.svg)](https://hub.docker.com/r/flowgunso/seafile-client)
[![Licensed under GPLv3](https://img.shields.io/badge/License-GPLv3-red.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![@gitlab.com/flwgns-docker/seafile-client](https://img.shields.io/badge/Source%20code-GitLab-red.svg)](https://gitlab.com/flwgns-docker/seafile-client/)
> ⚠️ Please consider sponsoring this project to help me maintaining and improving it. As of right now, you can support me through Liberay, available in the project badges
# Available tags
> This project is switching namespaces. The sources previously in [flwgnso-docker/docker-seafile-client](https://gitlab.com/flwgns-docker/seafile-client) are now in [flrnnc-oss/docker-seafile-client](https://gitlab.com/flrnnc-oss/docker-seafile-client). The Docker image can still be found at [flowgunso/seafile-client](https://hub.docker.com/r/flowgunso/seafile-client) but it will be deprecated, the image [flrnnc/seafile-client](https://hub.docker.com/r/flrnnc/seafile-client) should be used instead.
Weekly stable release are built every Monday at 6AM UTC+2.
Permanent stable releases will not be built again.
# Quick informations
## Weekly stable releases.
[`1`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.0),
[`1.2`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.0),
[`1.2.0`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.0),
[`latest`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.0)
_Docker Seafile client_ is a Docker image that provides a Seafile client to sync one or more library as volumes to other containers.
## Developmental releases.
[`staging`](https://gitlab.com/flwgns-docker/seafile-client/tree/staging):
The purpose of this release is to test feature and make them available to anyone.
## Features
* Synchronize one or more Seafile libraries.
* Support password protected librairies.
* Support two factor authentication.
* Configure upload and download limits.
* Skip SSL certificates.
* Set file ownership with user/group ID
# Purpose
Docker Seafile Client allow you to sync a Seafile library within a container.
## Quick links
**Essentially, you can share a Seafile library as a volume to other containers**.
## Seafile?
[Seafile is a cloud storage software](https://www.seafile.com/).
* Check out the [roadmap](https://gitlab.com/flrnnc-oss/docker-seafile-client/-/wikis/home#roadmap) to see what is anticipated.
* Check out how to [contribute](CONTRIBUTING.md).
* Report issues on [Gitlab](https://gitlab.com/flrnnc-oss/docker-seafile-client/).
* Ask questions on [Seafile forum](https://forum.seafile.com/t/docker-client-to-sync-files-with-containers/8573).
# Usage
The *Seafile* daemon is running as the user `seafuser` from it's directories `~/.seafile/` and `~/.ccnet`.
The library is synced at `/volume/`.
## Start a Seafile client
The *Seafile* daemon is managed with *supervisord* since it can't run as a foreground process.
The *supervisord* is running from `~/.supervisord/`, the `supervisord.conf`, `supervisord.log` and `supervisord.pid` can be found there.
*supervisord* also manage a shell script, `~/infinite-seaf-cli-start.sh` which stop then start the Seafile daemon every 20 minutes: the synchronisation might not work properly if the Seafile daemon is not restarted from times to times, for an unresolved reason.
## Examples
You would have to share the path `/volume/` to other containers, with the following approaches:
### Docker CLI
```
### Docker command-line
The following command start the Seafile client with one library:
```bash
docker run \
-e SEAF_SERVER_URL= \ # The URL to your Seafile server.
-e SEAF_USERNAME= \ # Your Seafile username.
-e SEAF_PASSWORD= \ # Your Seafile password
-e SEAF_LIBRARY_UUID= \ # The Seafile library UUID you want to sync with.
-e UID= \ # Default is 1000.
-e GID= \ # Default is 1000.
-v your/shared/volume:/volume \
flowgunso/seafile-client:latest
-e SEAF_SERVER_URL="https://seafile.example/" \
-e SEAF_USERNAME="a_seafile_user" \
-e SEAF_PASSWORD="SoMePaSSWoRD" \
-e SEAF_LIBRARY="an-hexadecimal-library-uuid" \
-v path/to/library:/library \
-v path/to/client/data:/seafile \
flrnnc/seafile-client:latest
```
### docker-compose
### Docker Compose
The following Docker Compose start a Seafile client with two libraries, with one password protected:
```yaml
version: "3.4"
version: "3"
services:
seafile-client:
image: flowgunso/seafile-client:latest
restart: on-failure
image: flrnnc/seafile-client:latest
volumes:
- your_shared_volume:/volume
- audio:/library/audio
- documents:/library/documents
- client:/seafile
environment:
- SEAF_SERVER_URL= # The URL to your Seafile server.
- SEAF_USERNAME= # Your Seafile username.
- SEAF_PASSWORD= # Your Seafile password.
- SEAF_LIBRARY_UUID= # The Seafile library UUID you want to sync with.
- UID= # Default is 1000.
- GID= # Default is 1000.
SEAF_SERVER_URL: "https://seafile.example/"
SEAF_USERNAME: "a_seafile_user"
SEAF_PASSWORD: "SoMePaSSWoRD"
SEAF_LIBRARY_AUDIO: "audio-library-uuid"
SEAF_LIBRARY_AUDIO_PASSWORD: "auDioLiBRaRyPaSSWoRD"
SEAF_LIBRARY_DOCUMENTS: "documents-library-uuid"
volumes:
your_shared_volume:
audio:
documents:
client:
```
## Librairies
Environment variables allows librairies configuration, as shown in the examples above.
# Environment variables
The following environment variable are available.
You can configure either a single librairy or multiple librairies.
## Seafile
This Docker **must be configured with the following**, **otherwise** it **will not run**:
### SEAF_SERVER_URL
The URL to your Seafile server.
### SEAF_USERNAME
Your Seafile account's username.
### SEAF_PASSWORD
Your Seafile account's password.
### SEAF_LIBRARY_UUID
The Seafile library UUID you want to use.
### Single library
To synchronize a single library, use the environment variables `SEAF_LIBRARY` and `SEAF_LIBRARY_PASSWORD`. The library will be synchronized in _/library_.
## User permissions
This Docker is **not running as `root` but as `seafuser`**. You can override the user/group ID used with:
### UID
The user ID defaults to `1000`. You may want to override this variable to prevent permission issues.
### GID
The group ID defaults to `1000`. Similarly, you may want to override this variable to prevent permission issues.
### Multiple librairies
To synchronise multiple librairies, use the same environment variable as above but suffixed with a single identifier word. That word will be used for the library password and it's synchronization path as well.
# Source code
This Docker image is licensed under GPLv3.
The source code is available in [gitlab.com/flwgns-docker/seafile-client](https://gitlab.com/flwgns-docker/seafile-client/).
Hence, to synchronise a library identified as **audio**, the environment variables would be `SEAF_LIBRARY_AUDIO` for the library UUID and `SEAF_LIBRARY_AUDIO_PASSWORD` for the library password. The library will be then synchronized in _/library/audio_.
Identifiers allows to add as many libraries as possible. Identifier are single word only.
## Environment variables
Environment variable allows you to configure the Seafile client.
### `SEAF_SERVER_URL`
> This variable is mandatory.
The Seafile server URL.
### `SEAF_USERNAME`
> This variable is mandatory.
The username for the Seafile account.
### `SEAF_PASSWORD`
> This variable is mandatory.
The password for the Seafile account.
### `SEAF_LIBRARY`, `SEAF_LIBRARY_[IDENTIFIER]`
> This variable is mandatory.
The UUID of the library, libraries to synchronize.
Replace `[IDENTIFIER]` with the a unique single word identifier for each library you want to synchronize.
### `SEAF_LIBRARY_PASSWORD`, `SEAF_LIBRARY_[IDENTIFIER]_PASSWORD`
The password of the library, libraries to synchronize.
Replace `[IDENTIFIER]` with the a unique single word identifier for each library you want to synchronize corresponding to the `SEAF_LIBRARY_[IDENTIFIER]`.
### `SEAF_2FA_SECRET`
_Two factor authentication is supported but your secret key must be provided._ That key can be found on your Seafile web interface, only at the 2FA setup, when the QR code is shown. The secret key is embedded in the QR or available as a cookie.
### `SEAF_UPLOAD_LIMIT`, `SEAF_DOWNLOAD_LIMIT`
Set upload and download speeds limits. Limits are in bytes.
### `SEAF_SKIP_SSL_CERT`
Skip SSL certificates verifications.
> Any string is considered true, omit the variable to set to false. Enable this if you have synchronization failures regarding SSL certificates.
### `UID`, `GID`
Override the _UID_ and _GID_ for user running the Seafile client, hence the volume ownership.
## Docker Secrets
All environments variable supports Docker Secrets, as environment variable variant suffixed with `_FILE` as files.
## Full example
```bash
version: "3"
services:
seafile-client:
image: flrnnc/seafile-client:latest
volumes:
- audio:/library/audio
- documents:/library/documents
- client:/seafile
environment:
SEAF_SERVER_URL: "https://seafile.example/"
SEAF_USERNAME: "a_seafile_user"
SEAF_PASSWORD: "SoMePaSSWoRD"
SEAF_LIBRARY_AUDIO: "audio-library-uuid"
SEAF_LIBRARY_AUDIO_PASSWORD: "auDioLiBRaRyPaSSWoRD"
SEAF_LIBRARY_DOCUMENTS: "documents-library-uuid"
SEAF_2FA_SECRET: "JBSWY3DPEHPK3PXPIXDAUMXEDOXIUCDXWC32CS"
SEAF_UPLOAD_LIMIT: "1000000"
SEAF_DOWNLOAD_LIMIT: "1000000"
SEAF_SKIP_SSL_CERT: "true"
UID: "1000"
GID: "1000"
volumes:
audio:
documents:
client:
```

View File

@@ -1,56 +0,0 @@
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM debian:jessie-slim
# Prevent the packages installation to halt.
ENV DEBIAN_FRONTEND noninteractive
# Specify the user running Seafile.
ENV UNAME=seafuser
ENV UID=1000
ENV GID=1000
# Copy over the Docker related files.
COPY utils/build/import-seafile-apt-key.sh /
COPY assets/bash/docker-entrypoint.sh /entrypoint.sh
# Safely import Seafile APT key, then install both seafile-cli and supervisord.
RUN mkdir -p /etc/apt/sources.list.d/ ;\
echo "deb http://deb.seadrive.org jessie main" \
> /etc/apt/sources.list.d/seafile.list ;\
/bin/bash /import-seafile-apt-key.sh ;\
apt-get update ;\
apt-get install \
-o Dpkg::Options::="--force-confold" \
-y seafile-cli ;\
apt-get clean ;\
apt-get autoclean \
-o APT::Clean-Installed=true ;\
rm \
-f \
/var/log/fsck/*.log \
/var/log/apt/*.log \
/var/cache/debconf/*.dat-old \
/import-seafile-apt-key.sh ;\
mkdir /volume ;\
groupadd -g $GID -o $UNAME ;\
useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME
# Copy over the required files for Seafile/SupervisorD.
COPY assets/bash/seafile-healthcheck.sh /home/seafuser/
COPY assets/bash/seafile-entrypoint.sh /home/seafuser/entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

View File

@@ -1,54 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Check mandatory Seafile configuration have been properly set.
if [ -z $SEAF_SERVER_URL ]; then echo "The \$SEAF_SERVER_URL was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_USERNAME ]; then echo "The \$SEAF_USERNAME was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_PASSWORD ]; then echo "The \$SEAF_PASSWORD was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_LIBRARY_UUID ]; then echo "The \$SEAF_LIBRARY_UUID was not defined. Stopping container..."; exit 1; fi
# Update the user ID, if the $UID changed.
if [ "$UID" != "1000" ]; then
usermod -u $UID $UNAME
# What if the $UID already exists ?
fi
# Change the group, if the $GID changed.
if [ "$GID" != "1000" ]; then
getent group | grep ":$GID:" >/dev/null
if [ $? -eq 0 ]; then
usermod -g $GID -G 1000 $UNAME
else
groupmod -g $GID $UNAME
fi
fi
# Set the files ownership.
chown $UID.$GID -R /home/seafuser/seafile-healthcheck.sh
chown $UID.$GID -R /home/seafuser/entrypoint.sh
chown $UID.$GID -R /volume
# Run the Seafile client as the container user.
su - $UNAME << EO
export SEAF_SERVER_URL=$SEAF_SERVER_URL
export SEAF_USERNAME=$SEAF_USERNAME
export SEAF_PASSWORD=$SEAF_PASSWORD
export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID
export UNAME=$UNAME
/bin/bash /home/seafuser/entrypoint.sh
EO

View File

@@ -1,38 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Define variable shortcuts for readability purposes.
seafile_ini=~/.ccnet/seafile.ini
seafile_sock=~/.seafile/seafile-data/seafile.sock
# Prepare the directories.
mkdir ~/.seafile
# Safely initialise the Seafile client.
/usr/bin/seaf-cli init -d ~/.seafile
while [ ! -f $seafile_ini ]; do sleep 1; done
# Safely start the Seafile daemon.
/usr/bin/seaf-cli start
while [ ! -S $seafile_sock ]; do sleep 1; done
# Start the synchronisation.
/usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume
# Run the infinite Seafile restart.
source ~/seafile-healthcheck.sh

View File

@@ -1,47 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# `seaf-cli status` output csv-like information with tabulates as separators and columns named in comment lines.
# The Seafile client should not be restarted while some statuses are occuring, such as "downloading" or "committing".
#
# This script grabs the output while ignoring the comments to iterate over the informations set to their columns,
# then it compares the statuses, when not empty, to the ones that do not require a restart. Finally either restart or don't.
seaf=/usr/bin/seaf-cli
dont_restart_on=("downloading" "committing")
restart=true
sleep 10s
while true; do
while IFS=$'\t' read -r name status progress; do
if [ $status ]; then
for dont_restart_on_status in "${dont_restart_on[@]}"; do
if [ "$status" == "$dont_restart_on_status" ]; then
restart=false; break; break
fi
done
fi
done < <($seaf status | grep -v "^#")
if $restart; then
$seaf stop
$seaf start
fi
sleep 10m
done

View File

@@ -1,61 +0,0 @@
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM debian:jessie-slim
# Prevent the packages installation to halt.
ENV DEBIAN_FRONTEND noninteractive
# Create the seafile client user.
ENV UNAME=seafuser
ENV UID=1000
ENV GID=1000
# Copy over the Docker related files.
COPY utils/build/import-seafile-apt-key.sh /
COPY assets/cron/docker-entrypoint.sh /entrypoint.sh
# Safely import Seafile APT key, then install both seafile-cli and supervisord.
RUN mkdir -p /etc/apt/sources.list.d/ ;\
echo "deb http://deb.seadrive.org jessie main" \
> /etc/apt/sources.list.d/seafile.list ;\
bash /import-seafile-apt-key.sh ;\
apt-get update ;\
apt-get install \
-o Dpkg::Options::="--force-confold" \
-y \
seafile-cli \
cron ;\
apt-get clean ;\
apt-get autoclean \
-o APT::Clean-Installed=true ;\
rm \
-f \
/var/log/fsck/*.log \
/var/log/apt/*.log \
/var/cache/debconf/*.dat-old \
/import-seafile-apt-key.sh ;\
mkdir /volume/ ;\
echo "seafuser" > /etc/cron.allow ;\
echo "*/20 * * * * /bin/bash /home/seafuser/seafile-healthcheck.sh" \
> /var/spool/cron/crontabs/seafuser ;\
groupadd -g $GID -o $UNAME ;\
useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME
# Copy over the required files for Seafile/SupervisorD.
COPY assets/cron/seafile-healthcheck.sh /home/seafuser/seafile-healthcheck.sh
COPY assets/cron/seafile-entrypoint.sh /home/seafuser/entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

View File

@@ -1,56 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Check mandatory Seafile configuration have been properly set.
if [ -z $SEAF_SERVER_URL ]; then echo "The \$SEAF_SERVER_URL was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_USERNAME ]; then echo "The \$SEAF_USERNAME was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_PASSWORD ]; then echo "The \$SEAF_PASSWORD was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_LIBRARY_UUID ]; then echo "The \$SEAF_LIBRARY_UUID was not defined. Stopping container..."; exit 1; fi
# Update the user ID, if the $UID changed.
if [ "$UID" != "1000" ]; then
usermod -u $UID $UNAME
# What if the $UID already exists ?
fi
# Change the group, if the $GID changed.
if [ "$GID" != "1000" ]; then
getent group | grep ":$GID:" >/dev/null
if [ $? -eq 0 ]; then
usermod -g $GID -G 1000 $UNAME
else
groupmod -g $GID $UNAME
fi
fi
# Set the files ownership.
chown $UID.$GID /home/seafuser/seafile-healthcheck.sh
chown $UID.$GID /home/seafuser/entrypoint.sh
chown $UID.$GID -R /volume
# Run the Seafile client as the container user.
su - $UNAME << EO
export SEAF_SERVER_URL=$SEAF_SERVER_URL
export SEAF_USERNAME=$SEAF_USERNAME
export SEAF_PASSWORD=$SEAF_PASSWORD
export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID
export UNAME=$UNAME
/bin/bash /home/seafuser/entrypoint.sh
EO
cron -f

View File

@@ -1,42 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# `seaf-cli status` output csv-like information with tabulates as separators and columns named in comment lines.
# The Seafile client should not be restarted while some statuses are occuring, such as "downloading" or "committing".
#
# This script grabs the output while ignoring the comments to iterate over the informations set to their columns,
# then it compares the statuses, when not empty, to the ones that do not require a restart. Finally either restart or don't.
seaf=/usr/bin/seaf-cli
dont_restart_on=("downloading" "committing")
restart=true
while IFS=$'\t' read -r name status progress; do
if [ $status ]; then
for dont_restart_on_status in "${dont_restart_on[@]}"; do
if [ "$status" == "$dont_restart_on_status" ]; then
restart=false; break; break
fi
done
fi
done < <($seaf status | grep -v "^#")
if $restart; then
$seaf stop
$seaf start
fi

View File

@@ -1 +0,0 @@
deb http://deb.seadrive.org jessie main

View File

@@ -1,58 +0,0 @@
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM debian:jessie-slim
# Prevent the packages installation to halt.
ENV DEBIAN_FRONTEND noninteractive
# Specify the user running Seafile.
ENV UNAME=seafuser
ENV UID=1000
ENV GID=1000
# Copy over the Docker related files.
COPY utils/build/import-seafile-apt-key.sh /
COPY assets/supervisord/dockerentrypoint.sh /entrypoint.sh
# Safely import Seafile APT key, then install both seafile-cli and supervisord.
RUN mkdir -p /etc/apt/sources.list.d/ ;\
echo "deb http://deb.seadrive.org jessie main" \
> /etc/apt/sources.list.d/seafile.list ;\
/bin/bash /import-seafile-apt-key.sh ;\
apt-get update ;\
apt-get install \
-o Dpkg::Options::="--force-confold" \
-y \
seafile-cli \
supervisor ;\
apt-get clean ;\
apt-get autoclean \
-o APT::Clean-Installed=true ;\
rm \
-f \
/var/log/fsck/*.log \
/var/log/apt/*.log \
/var/cache/debconf/*.dat-old \
/import-seafile-apt-key.sh ;\
mkdir /volume ;\
groupadd -g $GID -o $UNAME ;\
useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME
# Copy over the required files for Seafile/SupervisorD.
COPY assets/supervisord/supervisord.conf assets/supervisord/seafile-healthcheck.sh /home/seafuser/
COPY assets/supervisord/seafile-entrypoint.sh /home/seafuser/entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

View File

@@ -1,55 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Check mandatory Seafile configuration have been properly set.
if [ -z $SEAF_SERVER_URL ]; then echo "The \$SEAF_SERVER_URL was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_USERNAME ]; then echo "The \$SEAF_USERNAME was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_PASSWORD ]; then echo "The \$SEAF_PASSWORD was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_LIBRARY_UUID ]; then echo "The \$SEAF_LIBRARY_UUID was not defined. Stopping container..."; exit 1; fi
# Update the user ID, if the $UID changed.
if [ "$UID" != "1000" ]; then
usermod -u $UID $UNAME
# TODO: What if the $UID already exists ?
fi
# Change the group, if the $GID changed.
if [ "$GID" != "1000" ]; then
getent group | grep ":$GID:" >/dev/null
if [ $? -eq 0 ]; then
usermod -g $GID -G 1000 $UNAME
else
groupmod -g $GID $UNAME
fi
fi
# Set the files ownership.
chown $UID.$GID -R /home/seafuser/supervisord.conf
chown $UID.$GID -R /home/seafuser/seafile-healthcheck.sh
chown $UID.$GID -R /home/seafuser/entrypoint.sh
chown $UID.$GID -R /volume
# Run the Seafile client as the container user.
su - $UNAME << EO
export SEAF_SERVER_URL=$SEAF_SERVER_URL
export SEAF_USERNAME=$SEAF_USERNAME
export SEAF_PASSWORD=$SEAF_PASSWORD
export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID
export UNAME=$UNAME
/bin/bash /home/seafuser/entrypoint.sh
EO

View File

@@ -1,42 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Define variable shortcuts for readability purposes.
seafile_ini=~/.ccnet/seafile.ini
seafile_sock=~/.seafile/seafile-data/seafile.sock
supervisord_conf=~/supervisord.conf
supervisord_pid=~/.supervisord/supervisord.pid
supervisord_log=~/.supervisord/supervisord.log
# Prepare the directories.
mkdir ~/.seafile
mkdir ~/.supervisord
# Safely initialise the Seafile client.
/usr/bin/seaf-cli init -d ~/.seafile
while [ ! -f $seafile_ini ]; do sleep 1; done
# Safely start the Seafile daemon.
/usr/bin/seaf-cli start
while [ ! -S $seafile_sock ]; do sleep 1; done
# Start the synchronisation.
/usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume
# Start the supervisord.
/usr/bin/supervisord -u $UNAME -c $supervisord_conf -j $supervisord_pid -l $supervisord_log

View File

@@ -1,47 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# `seaf-cli status` output csv-like information with tabulates as separators and columns named in comment lines.
# The Seafile client should not be restarted while some statuses are occuring, such as "downloading" or "committing".
#
# This script grabs the output while ignoring the comments to iterate over the informations set to their columns,
# then it compares the statuses, when not empty, to the ones that do not require a restart. Finally either restart or don't.
seaf=/usr/bin/seaf-cli
dont_restart_on=("downloading" "committing")
restart=true
sleep 10s
while true; do
while IFS=$'\t' read -r name status progress; do
if [ $status ]; then
for dont_restart_on_status in "${dont_restart_on[@]}"; do
if [ "$status" == "$dont_restart_on_status" ]; then
restart=false; break; break
fi
done
fi
done < <($seaf status | grep -v "^#")
if $restart; then
$seaf stop
$seaf start
fi
sleep 10m
done

View File

@@ -1,30 +0,0 @@
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Run in the foreground to keep the container running.
[supervisord]
nodaemon=true
# Manage the Seafile daemon.
[unix_http_socket]
file=~/.seafile/seafile-data/seafile.sock
# Manage the infinite `seaf-cli start`.
[program:seaf-cli-start-loop]
command=/bin/bash /home/seafuser/seafile-healthcheck.sh
process_name=%(program_name)s
numprocs=1
autostart=true

View File

@@ -1,18 +0,0 @@
version: "3.4"
services:
seafile-client:
image: flowgunso/seafile-client:latest
restart: on-failure
volumes:
- your_shared_volume:/volume
environment:
- SEAF_SERVER_URL= # The URL to your Seafile server.
- SEAF_USERNAME= # Your Seafile username.
- SEAF_PASSWORD= # Your Seafile password.
- SEAF_LIBRARY_UUID= # The Seafile library UUID you want to sync with.
- UID= # Default is 1000.
- GID= # Default is 1000.
volumes:
your_shared_volume:

View File

@@ -0,0 +1,8 @@
docker run \
-e SEAF_SERVER_URL="https://seafile.example/" \
-e SEAF_USERNAME="a_seafile_user" \
-e SEAF_PASSWORD="SoMePaSSWoRD" \
-e SEAF_LIBRARY="an-hexadecimal-library-uuid" \
-v path/to/library:/library \
-v path/to/client/data:/seafile \
flrnnc/seafile-client:latest

View File

@@ -0,0 +1,28 @@
version: "3"
services:
seafile-client:
image: flrnnc/seafile-client:latest
volumes:
- audio:/library/audio
- documents:/library/documents
- client:/seafile
environment:
SEAF_SERVER_URL: "https://seafile.example/"
SEAF_USERNAME: "a_seafile_user"
SEAF_PASSWORD: "SoMePaSSWoRD"
SEAF_LIBRARY_AUDIO: "audio-library-uuid"
SEAF_LIBRARY_AUDIO_PASSWORD: "auDioLiBRaRyPaSSWoRD"
SEAF_LIBRARY_DOCUMENTS: "documents-library-uuid"
SEAF_2FA_SECRET: "JBSWY3DPEHPK3PXPIXDAUMXEDOXIUCDXWC32CS"
SEAF_UPLOAD_LIMIT: "1000000"
SEAF_DOWNLOAD_LIMIT: "1000000"
SEAF_SKIP_SSL_CERT: "true"
UID: "1000"
GID: "1000"
volumes:
audio:
documents:
client:

View File

@@ -0,0 +1,22 @@
version: "3"
services:
seafile-client:
image: flrnnc/seafile-client:latest
volumes:
- audio:/library/audio
- documents:/library/documents
- client:/seafile
environment:
SEAF_SERVER_URL: "https://seafile.example/"
SEAF_USERNAME: "a_seafile_user"
SEAF_PASSWORD: "SoMePaSSWoRD"
SEAF_LIBRARY_AUDIO: "audio-library-uuid"
SEAF_LIBRARY_AUDIO_PASSWORD: "auDioLiBRaRyPaSSWoRD"
SEAF_LIBRARY_DOCUMENTS: "documents-library-uuid"
volumes:
audio:
documents:
client:

View File

@@ -0,0 +1,15 @@
{% include "parts/notices.md.j2" %}
{% include "parts/badges.md.j2" %}
**Share one or more Seafile libraries as a volume to other containers.**
{% include "parts/supported_tags.md.j2" %}
{% include "parts/features.md.j2" %}
{% include "parts/usage.md.j2" %}
{% include "parts/troubleshooting.md.j2" %}
{% include "parts/moving-to-another-namespace.md.j2" %}

View File

@@ -0,0 +1,11 @@
{% include "parts/badges.md.j2" %}
**Share one or more Seafile libraries as a volume to other containers.**
{% include "parts/supported_tags.md.j2" %}
{% include "parts/features.md.j2" %}
{% include "parts/usage.md.j2" %}
{% include "parts/troubleshooting.md.j2" %}

View File

@@ -0,0 +1,9 @@
{% include "parts/badges.md.j2" %}
**Share a Seafile library as a volume to other containers.**
{% include "parts/features.md.j2" %}
{% include "parts/usage.md.j2" %}
{% include "parts/troubleshooting.md.j2" %}

View File

@@ -0,0 +1,3 @@
{% for name, links in badges.items() -%}
[![{{name}}]({{links.image}})]({{links.link}})
{% endfor %}

View File

@@ -0,0 +1,9 @@
# Features
* Synchronize one or more Seafile libraries.
* Support password protected librairies.
* Support two factor authentication.
* Configure upload and download limits.
* Skip SSL certificates.
* Set file ownership with user/group ID
The Docker image is built weekly to keep up with security updates.

View File

@@ -0,0 +1,5 @@
# Moving to another namespace
This repository is being moved to a new namespace [flrnnc](https://hub.docker.com/u/flrnnc).
I am applying to open source software programs on the service providers I rely on such as Gitlab and Docker. It means that my project must be reorganized. The `flrnnc` namespace is dedidacted to open source software I publish on Docker.

View File

@@ -0,0 +1,2 @@
> This repository will be moved to another namespace [flrnnc/seafile-client](https://hub.docker.com/repository/docker/flrnnc/seafile-client/).
> See [moving to another namespace](#moving-to-another-namespace]) for explanations.

View File

@@ -0,0 +1,9 @@
# Supported tags
The versions match Seafile versions.
{% for version in versions %}
[{{ version | join(", ")}}][Dockerfile]
{% endfor %}
[Dockerfile]: https://gitlab.com/flrnnc-oss/docker-seafile-client/-/blob/master/seafile-client/Dockerfile

View File

@@ -0,0 +1,3 @@
# Troubleshooting
* Ask questions on [Seafile forum](https://forum.seafile.com/t/docker-client-to-sync-files-with-containers/8573).
* Contribute and report issues on [Gitlab](https://gitlab.com/flrnnc-oss/docker-seafile-client/).

View File

@@ -0,0 +1,80 @@
# Usage
## Start a Seafile client
### Docker command-line
The following command start the Seafile client with one library:
```bash
{% include "assets/cli.bash" %}
```
### Docker Compose
The following Docker Compose start a Seafile client with two libraries, with one password protected:
```yaml
{% include "assets/compose.yaml" %}
```
## Librairies
Environment variables allows librairies configuration, as shown in the examples above.
You can configure either a single librairy or multiple librairies.
### Single library
To synchronize a single library, use the environment variables `SEAF_LIBRARY` and `SEAF_LIBRARY_PASSWORD`. The library will be synchronized in _/library_.
### Multiple librairies
To synchronise multiple librairies, use the same environment variable as above but suffixed with a single identifier word. That word will be used for the library password and it's synchronization path as well.
Hence, to synchronise a library identified as **audio**, the environment variables would be `SEAF_LIBRARY_AUDIO` for the library UUID and `SEAF_LIBRARY_AUDIO_PASSWORD` for the library password. The library will be then synchronized in _/library/audio_.
Identifiers allows to add as many libraries as possible. Identifier are single word only.
## Environment variables
Environment variable allows you to configure the Seafile client.
### `SEAF_SERVER_URL`
> This variable is mandatory.
The Seafile server URL.
### `SEAF_USERNAME`
> This variable is mandatory.
The username for the Seafile account.
### `SEAF_PASSWORD`
> This variable is mandatory.
The password for the Seafile account.
### `SEAF_LIBRARY`, `SEAF_LIBRARY_[IDENTIFIER]`
> This variable is mandatory.
The UUID of the library, libraries to synchronize.
Replace `[IDENTIFIER]` with the a unique single word identifier for each library you want to synchronize.
### `SEAF_LIBRARY_PASSWORD`, `SEAF_LIBRARY_[IDENTIFIER]_PASSWORD`
The password of the library, libraries to synchronize.
Replace `[IDENTIFIER]` with the a unique single word identifier for each library you want to synchronize corresponding to the `SEAF_LIBRARY_[IDENTIFIER]`.
### `SEAF_2FA_SECRET`
_Two factor authentication is supported but your secret key must be provided._ That key can be found on your Seafile web interface, only at the 2FA setup, when the QR code is shown. The secret key is embedded in the QR or available as a cookie.
### `SEAF_UPLOAD_LIMIT`, `SEAF_DOWNLOAD_LIMIT`
Set upload and download speeds limits. Limits are in bytes.
### `SEAF_SKIP_SSL_CERT`
Skip SSL certificates verifications.
> Any string is considered true, omit the variable to set to false. Enable this if you have synchronization failures regarding SSL certificates.
### `UID`, `GID`
Override the _UID_ and _GID_ for user running the Seafile client, hence the volume ownership.
## Docker Secrets
All environments variable supports Docker Secrets, as environment variable variant suffixed with `_FILE` as files.
## Full example
```bash
{% include "assets/compose-full.yaml" %}
```

View File

@@ -0,0 +1,29 @@
Hello everyone,
I wanted to use files from my Seafile server within Docker containers.
I started looking for existing image featuring a Seafile client on Docker Hub. There are some, but with issues such as non-existant/vague documentation or improper tagging.
I don't know if it's something that people are looking for, but I made one. It's available at flowgunso/seafile-client in Docker Hub.
Example usage with docker-compose and for the docker cli are provided. Essentially, it runs `seaf-cli sync`, but you have to pass to the container your Seafile server URL, your credentials and the library ID you want to sync with. Then you can share the path `/library` as a volume to your containers for your own usages.
Feedback is welcome so I can keep improving it.
# Quick informations
{% include "parts/badges.md.j2" %}
**Please use [u][flrnnc/seafile-client](https://hub.docker.com/r/flrnnc/seafile-client)[/u] instead of [u][flowgunso/seafile-client](https://hub.docker.com/r/flowgunso/seafile-client)[/u] from now on.**
This project is switching namespaces. The sources previously in [flwgnso-docker/docker-seafile-client](https://gitlab.com/flwgns-docker/seafile-client) are now in [flrnnc-oss/docker-seafile-client](https://gitlab.com/flrnnc-oss/docker-seafile-client). The Docker image can still be found at [flowgunso/seafile-client](https://hub.docker.com/r/flowgunso/seafile-client) but it will be deprecated, the image [flrnnc/seafile-client](https://hub.docker.com/r/flrnnc/seafile-client) should be used instead.
[flowgunso/seafile-client](https://hub.docker.com/r/flowgunso/seafile-client) will still be updated until usage is low enough to be archived.
{% include "parts/supported_tags.md.j2" %}
{% include "parts/features.md.j2" %}
{% include "parts/usage.md.j2" %}
{% include "parts/troubleshooting.md.j2" %}

View File

@@ -1,7 +1,7 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
# Copyright (C) 2019-2024, florian.anceau@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,20 +16,26 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Define variable shortcuts for readability purposes.
seafile_ini=~/.ccnet/seafile.ini
seafile_sock=~/.seafile/seafile-data/seafile.sock
# Prepare the build arguments
build_args=(CREATED=$(date -u +"%Y-%m-%dT%H:%M:%SZ"))
[[ "$CI_COMMIT_SHA" ]] && build_args+=(REVISION=$CI_COMMIT_SHA)
[[ "$CI_COMMIT_TAG" ]] && build_args+=(VERSION=$CI_COMMIT_TAG)
[[ "$TARGET" ]] && build_args+=(TARGET=$TARGET)
# Prepare the directories.
mkdir ~/.seafile
# Build the build argumets string.
build_arguments=""
for build_arg in "${build_args[@]}"; do
build_arguments+="--build-arg $build_arg "
done
# Safely initialise the Seafile client.
/usr/bin/seaf-cli init -d ~/.seafile
while [ ! -f $seafile_ini ]; do sleep 1; done
docker build \
$build_arguments \
--build-arg IMAGE=flowgunso \
--tag seafile-client:$TARGET-flowgunso \
seafile-client/
# Safely start the Seafile daemon.
/usr/bin/seaf-cli start
while [ ! -S $seafile_sock ]; do sleep 1; done
# Start the synchronisation.
/usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume
docker build \
$build_arguments \
--build-arg IMAGE=flrnnc \
--tag seafile-client:$TARGET-flrnnc \
seafile-client/

93
scripts/make-documents.py Executable file
View File

@@ -0,0 +1,93 @@
# !/usr/bin/env python
from pathlib import Path
import argparse
import os
from jinja2 import Environment, FileSystemLoader
from gitlab import Gitlab
REPOSITORY_PATH = Path(__file__).parent.parent
class DocumentMaker:
def __init__(self, filename: str) -> None:
# Intanciate the Jinja2 renderer.
self.directory = REPOSITORY_PATH.joinpath("documentations")
loader = FileSystemLoader(self.directory)
environment = Environment(loader=loader)
self.filename = filename
self.template = environment.get_template(filename)
# Instanciate the Gitlab session.
gitlab_project_id=os.environ["CI_PROJECT_ID"]
gitlab_private_token=os.environ["WEEKLY_BUILD_PRIVATE_TOKEN"]
self.gitlab = Gitlab(private_token=gitlab_private_token)
self.project = self.gitlab.projects.get(gitlab_project_id)
self.versions = []
self.badges = {}
def get_versions(self):
versions = []
for path in Path("versions").iterdir():
with open(path, "rt") as fo:
versions.append(fo.read().strip())
versions.sort(reverse=True)
# Prepare the render context.
latest = True
self.versions = []
for version in versions:
version = version.strip()
parts = version.split(".")
increments = []
blocks = []
for part in parts:
increments.append(part)
section = ".".join(increments)
blocks.append(f"`{section}`")
if latest:
blocks.append("`latest`")
latest = False
self.versions.append(blocks)
def get_badges(self):
badges = self.project.badges.list()
for badge in badges:
name = badge.name
link = badge.rendered_link_url
image = badge.rendered_image_url
links = {"link": link, "image": image}
self.badges[name] = links
def render(self):
# Render
# TODO: read and adapt the CHANGELOG and insert into the render.
content = self.template.render(versions=self.versions, badges=self.badges)
#content = template.render() # When version/ is unavailable.
filename = Path(self.filename).with_suffix("")
path = self.directory.joinpath(filename)
# Write to file
with open(path, mode="w") as fo:
fo.write(content)
if __name__ == "__main__":
# Argument parsing.
parser = argparse.ArgumentParser(prog="Seafile Docker client documentation renderer")
parser.add_argument("template", type=str)
args = parser.parse_args()
maker = DocumentMaker(args.template)
maker.get_versions()
maker.get_badges()
maker.render()

View File

@@ -0,0 +1,30 @@
# Get a token from hub.docker.com with the owner credentials.
token=$(curl -s \
-X POST \
-H "Content-Type: application/json" \
-d '{"username": "'"$DOCKER_REGISTRY_USERNAME"'", "password": "'"$DOCKER_REGISTRY_TOKEN"'"}' \
https://hub.docker.com/v2/users/login/ | jq -r .token)
# Generate a JSON with the README.md as the full_description.
json=$(jq -n \
--arg readme "$(<documentations/docker.md)" \
'{"full_description": $readme,"description": "'"$DOCKER_REGISTRY_DESCRIPTION_FLRNNC"'"}')
jsonOld=$(jq -n \
--arg readme "$(<documentations/docker-old.md)" \
'{"full_description": $readme,"description": "'"$DOCKER_REGISTRY_DESCRIPTION_FLOWGUNSO"'"}')
# Update the Docker Hub repository's full_description.
curl -siL \
-X PATCH \
-d "$jsonOld" \
-H "Content-Type: application/json" \
-H "Authorization: JWT $token" \
"https://hub.docker.com/v2/repositories/$DOCKER_REGISTRY_IMAGE_FLOWGUNSO/"
curl -siL \
-X PATCH \
-d "$json" \
-H "Content-Type: application/json" \
-H "Authorization: JWT $token" \
"https://hub.docker.com/v2/repositories/$DOCKER_REGISTRY_IMAGE_FLRNNC/"

54
scripts/publish-images.sh Normal file
View File

@@ -0,0 +1,54 @@
# !/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019-2024, florian.anceau@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
set -ex
raise() {
echo $1
exit 1
}
# Grab version with the container
version="$(docker run --rm seafile-client:$TARGET-flrnnc cat -s /SEAFILE_VERSION)"
version="$(echo ${version%-*})"
# Output the version to an artifact for documentation rendering.
mkdir -p versions/
echo $version >> "versions/$TARGET"
# Generate version tags.
tags=()
[[ "$TARGET" =~ "unstable" ]] && tags+=("latest")
for version_component in $(echo $version | tr '.' '\n'); do
tag+="$version_component"
tags+=("$tag")
tag+="."
done
# Tag then push to the Docker Hub registry.
echo $DOCKER_REGISTRY_TOKEN | docker login --password-stdin --username $DOCKER_REGISTRY_USERNAME
for tag in "${tags[@]}"; do
docker tag seafile-client:$TARGET-flowgunso $DOCKER_REGISTRY_IMAGE_FLOWGUNSO:$tag
docker push $DOCKER_REGISTRY_IMAGE_FLOWGUNSO:$tag
done
for tag in "${tags[@]}"; do
docker tag seafile-client:$TARGET-flrnnc $DOCKER_REGISTRY_IMAGE_FLRNNC:$tag
docker push $DOCKER_REGISTRY_IMAGE_FLRNNC:$tag
done

132
scripts/schedule-build.py Normal file
View File

@@ -0,0 +1,132 @@
# !/usr/bin/env python
import os
import argparse
import sys
from datetime import datetime
import requests
from requests.auth import HTTPBasicAuth
from gitlab import Gitlab
class Scheduler:
WATTTIME_SIGNAL_TYPE="co2_moer"
def __init__(self, watttime_username, watttime_password, gitlab_private_token,
gitlab_project_id, gitlab_scheduled_pipeline_id):
# Instanciate the WattTime session.
url = "https://api.watttime.org/login"
response = requests.get(url, auth=HTTPBasicAuth(watttime_username, watttime_password))
payload = response.json()
token = payload["token"]
headers = {"Authorization": f"Bearer {token}"}
self.watttime = requests.session()
self.watttime.headers = headers
# Instanciate the Gitlab session and grab the Weekly build scheduled pipeline.
self.gitlab = Gitlab(private_token=gitlab_private_token)
project = self.gitlab.projects.get(gitlab_project_id)
self.pipeline = project.pipelineschedules.get(gitlab_scheduled_pipeline_id)
def geolocate(self):
url = "https://ipinfo.io"
response = requests.get(url)
payload = response.json()
geolocation = payload["loc"]
self.latitude, self.longitude = geolocation.split(",")
def load_shift(self):
# Get region from geolocation.
# TODO: uncomment once premium plan
# url = "https://api.watttime.org/v3/region-from-loc"
# params = {
# "latitude": self.latitude,
# "longitude": self.longitude,
# "signal_type": self.WATTTIME_SIGNAL_TYPE}
# response = self.watttime.get(url, params=params)
# payload = response.json()
# region = payload["region"]
# Get the forecast for said region.
# TODO: don't override the region, get a premium plan
url = "https://api.watttime.org/v3/forecast"
region = "CAISO_NORTH" # Override the region until I get a premium plan
params = {"region": region, "signal_type": self.WATTTIME_SIGNAL_TYPE}
response = self.watttime.get(url, params=params)
payload = response.json()
data = payload["data"]
# Look for the lowest value and it's datetime. Store the current value to know improvements.
lowest_value: float = None
for obj in data:
value = obj["value"]
point_time = datetime.fromisoformat(obj["point_time"])
if not lowest_value:
self.now_value = self.lowest_value = value
self.now = self.then = point_time
continue
if value < lowest_value:
lowest_value = value
self.then = point_time
def metrics(self):
# Write WattTime metrics.
metrics = {}
metrics["watttime_now"] = self.now_value
metrics["watttime_lowest"] = self.lowest_value
metrics["now"] = self.now
metrics["self.then"] = self.then
with open("metrics.txt", "wt") as fileobject:
for metric, value in metrics.items():
fileobject.write(f"{metric} {value}\n")
# TODO: track the metrics of energy cost/gain
def schedule(self):
# Test ownership prior to overtaking ownership.
self.gitlab.auth()
if self.pipeline.owner["id"] != self.gitlab.user.id:
self.pipeline.take_ownership()
# Set pipeline cron schedule to WattTime's Load Shift best moment.
cron = f"{self.then.minute} {self.then.hour} {self.then.day} {self.then.month} *"
self.pipeline.cron = cron
self.pipeline.active = True
self.pipeline.save()
def unschedule(self):
self.pipeline.active = False
self.pipeline.save()
if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog="",
description="",
epilog=""
)
parser.add_argument("--disable", action="store_true")
args = parser.parse_args()
disable = args.disable
scheduler = Scheduler(
watttime_username=os.environ["WATTTIME_USERNAME"],
watttime_password=os.environ["WATTTIME_PASSWORD"],
gitlab_project_id=os.environ["CI_PROJECT_ID"],
gitlab_private_token=os.environ["WEEKLY_BUILD_PRIVATE_TOKEN"],
gitlab_scheduled_pipeline_id=os.environ["WEEKLY_BUILD_PIPELINE_ID"]
)
if disable:
scheduler.unschedule()
sys.exit()
scheduler.geolocate()
scheduler.load_shift()
scheduler.metrics()
scheduler.schedule()

View File

@@ -0,0 +1,34 @@
# !/usr/bin/env python
import os
from datetime import datetime
from gitlab import Gitlab
class BuildBadgeUpdater:
def __init__(self, gitlab_private_token, gitlab_project_id, gitlab_build_badge_id):
# Instanciate the Gitlab session and grab the Weekly build scheduled pipeline.
self.gitlab = Gitlab(private_token=gitlab_private_token)
project = self.gitlab.projects.get(gitlab_project_id)
self.badge = project.badges.get(gitlab_build_badge_id)
def update(self):
now = datetime.now()
date = now.strftime(r"%Y--%m--%d")
image_url = f"https://img.shields.io/badge/_-{date}-_?label=last%20build&color=light-green"
self.badge.image_url = image_url
self.badge.save()
if __name__ == "__main__":
build_badge_updater = BuildBadgeUpdater(
gitlab_project_id=os.environ["CI_PROJECT_ID"],
gitlab_private_token=os.environ["WEEKLY_BUILD_PRIVATE_TOKEN"],
gitlab_build_badge_id=os.environ["BUILD_BADGE_ID"]
)
build_badge_updater.update()

58
seafile-client/Dockerfile Normal file
View File

@@ -0,0 +1,58 @@
ARG TARGET=unstable
FROM debian:${TARGET}-slim
ARG UID
ARG GID
ARG IMAGE
ENV UID 1000
ENV GID 1000
ENV PYTHONUNBUFFERED 1
ENV IMAGE ${IMAGE}
RUN apt-get update && \
apt-get install \
--no-install-recommends \
--yes \
seafile-cli \
oathtool \
ca-certificates \
gnupg \
sudo && \
apt-get clean && apt-get autoclean && \
rm -rf \
/var/log/fsck/*.log \
/var/log/apt/*.log \
/var/cache/debconf/*.dat-old \
/var/lib/apt/lists/* && \
groupmod -g 90 users
COPY --chmod=755 entrypoint-docker.sh /entrypoint.sh
COPY issue /etc/issue
RUN echo '[ ! -z $TERM ] && cat /etc/issue' >> /root/.bashrc && \
groupadd --gid $GID seafile && \
useradd --uid $UID --gid $GID --shell /bin/bash --create-home seafile && \
mkdir /library /seafile && \
chown seafile:seafile /seafile /library && \
apt-cache show seafile-cli | grep 'Version: ' | awk '{print $2}' > /SEAFILE_VERSION
COPY --chmod=755 --chown=seafile:seafile entrypoint-seafile.py /home/seafile/entrypoint.py
ARG CREATED
ARG REVISION
ARG VERSION
LABEL org.opencontainers.image.created=${CREATED}
LABEL org.opencontainers.image.authors="florian.anceau@gmail.com"
LABEL org.opencontainers.image.url="https://hub.docker.com/r/flrnnc/seafile-client"
LABEL org.opencontainers.image.documentation="https://gitlab.com/flrnnc-oss/docker-seafile-client"
LABEL org.opencontainers.image.source="https://gitlab.com/flrnnc-oss/docker-seafile-client"
LABEL org.opencontainers.image.version=${VERSION}
LABEL org.opencontainers.image.revision=${REVISION}
LABEL org.opencontainers.image.licenses="GPL-3.0"
LABEL org.opencontainers.image.title="Seafile Docker client"
LABEL org.opencontainers.image.description="Sync Seafile librairies within Docker containers."
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/home/seafile/entrypoint.py"]
HEALTHCHECK \
CMD ["/entrypoint.sh", "/home/seafile/entrypoint.py", "--healthcheck"]

View File

@@ -0,0 +1,42 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019-2024, florian.anceau@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#!/bin/bash
set -e
groupmod -g $GID seafile &> /dev/null
usermod -u $UID -g $GID seafile &> /dev/null
if [ "$IMAGE" == "flowgunso" ]; then
echo
echo -e "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"
echo -e "┃ \e[1mPlease use \e[4mflrnnc/seafile-client\e[24m instead of \e[4mflowgunso/seafile-client\e[24m which will be deprecated...\e[0m ┃"
echo -e "┃ See the information notices at: ┃"
echo -e "┃ \thttps://forum.seafile.com/t/docker-client-to-sync-files-with-containers/8573 ┃"
echo -e "┃ \thttps://gitlab.com/flrnnc-oss/docker-seafile-client ┃"
echo -e "┃ \thttps://hub.docker.com/r/flowgunso/seafile-client ┃"
echo -e "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"
echo
fi
sudo \
-HE \
-u seafile \
-- "$@"

View File

@@ -0,0 +1,312 @@
#!/usr/bin/env python3
from pathlib import Path
from typing import Any
import argparse
import logging
import os
import subprocess
import sys
import time
import seafile
class BadConfiguration(Exception):
pass
def get_configuration(variable: str, *args) -> Any:
"""Helper function to get a configuration.
see https://gitlab.com/-/snippets/1941025
"""
# Assign the default value from the first item of *args.
if args:
default = args[0]
# Try to get the variable from a Docker Secret.
try:
file = os.environ[f"{variable}_FILE"]
except KeyError:
pass
else:
with open(file, "rt") as fo:
return fo.read()
# Try to get the variable from an environment variable.
try:
return os.environ[variable]
except KeyError:
pass
# Try to return the default value,
# if no default exist, then it is a required variable.
try:
return default
except UnboundLocalError:
raise BadConfiguration(
f"Environment variable {variable} was not found but is required."
)
class Client:
def __init__(self) -> None:
# Client configuration
self.username: str = get_configuration("SEAF_USERNAME")
self.password: str = get_configuration("SEAF_PASSWORD")
self.url: str = get_configuration("SEAF_SERVER_URL")
self.skip_ssl_cert: bool = bool(get_configuration("SEAF_SKIP_SSL_CERT", None))
self.upload_limit: int = get_configuration("SEAF_UPLOAD_LIMIT", None)
self.download_limit: int = get_configuration("SEAF_DOWNLOAD_LIMIT", None)
self.mfa_secret: str = get_configuration("SEAF_2FA_SECRET", None)
# Paths
self.ini = Path.home().joinpath(".ccnet", "seafile.ini")
self.log = Path.home().joinpath(".ccnet", "logs", "seafile.log")
self.seafile = Path("/seafile")
self.socket = self.seafile.joinpath("seafile-data", "seafile.sock")
self.target = Path("/library")
# Binaries, instances.
if self.socket.exists():
self.rpc = seafile.RpcClient(str(self.socket))
self.binary = ["seaf-cli"]
self._get_librairies()
def _get_librairies(self):
self.libraries = {}
# Single library use case. Mutually exclusive to mulitple labraries use case.
single_library_variables = ["SEAF_LIBRARY", "SEAF_LIBRARY_UUID", "SEAF_LIBRARY_PASSWORD"]
if any(environ in single_library_variables for environ in os.environ):
logger.info("Single library detected. Multiple libraries will be ignored.")
library = {}
# Grab the UUID, usin both the
uuid = None
if legacy := os.getenv("SEAF_LIBRARY_UUID", None):
logger.warning("SEAF_LIBRARY_UUID is obsolete, please use SEAF_LIBRARY instead.")
uuid = legacy
if current := os.getenv("SEAF_LIBRARY", None):
uuid = current
# Exit if no UUID was provided, continue otherwise.
if uuid is None:
raise Exception("Please provide an UUID with SEAF_LIBRARY for single library usage.")
library["uuid"] = uuid
if password := os.getenv("SEAF_LIBRARY_PASSWORD", None):
library["password"] = password
# Assign and return a default library.
self.libraries["_"] = library
return
# Multiple libraries use case.
# Loop over all sorted variables prefixed with SEAF_LIBRARY.
for variable in sorted(os.environ):
if variable.startswith("SEAF_LIBRARY"):
# Get the variable name.
name = variable.split("_")[2].lower()
# Read the password as a secret.
if "_PASSWORD" in variable:
password = get_configuration(variable, None)
try:
if password:
self.libraries[name]["password"] = password
except KeyError:
logger.warning(f"Cannot set a password to unknown library {name}")
# Or got the name, build the dictionary with the name and uuid.
else:
self.libraries[name] = {}
uuid = os.environ[variable]
self.libraries[name]["uuid"] = uuid
def initialize(self):
# Initialize the Seafile client.
logger.info("Initializing `seaf-cli`.")
if not self.ini.exists():
logger.info("Seafile .ini file not found, running `seaf-cli init`")
#self.ini.parent.parent.mkdir(parents=True, exist_ok=True)
subprocess.run(self.binary + ["init", "-d", str(self.seafile)])
while not self.ini.exists():
logging.debug("Waiting for the .ini file to be created...")
time.sleep(1)
# Start the Seafile client.
logger.info("Starting `seaf-cli`.")
subprocess.run(self.binary + ["start"])
while not self.socket.exists():
logger.debug("Waiting for the Seafile client socket to be created.")
time.sleep(1)
self.rpc = seafile.RpcClient(str(self.socket))
def configure(self):
command = self.binary + ["config"]
if self.skip_ssl_cert:
subprocess.run(command +["-k", "disable_verify_certificate", "-v", str(self.skip_ssl_cert)])
if self.download_limit:
subprocess.run(command +["-k", "download_limit", "-v", self.download_limit])
if self.upload_limit:
subprocess.run(command +["-k", "upload_limit", "-v", self.upload_limit])
def synchronize(self):
core = self.binary + ["sync", "-u", self.username, "-p", self.password, "-s", self.url]
for name, configuration in self.libraries.items():
uuid = configuration["uuid"]
# Check if repository is already synced.
repository = self.rpc.get_repo(uuid)
if repository is not None:
logger.info(f"Library {name} is already synced.")
continue
command = core + ["-l", uuid]
if "password" in configuration:
password = configuration["password"]
command += ["-e", password]
target = self.target if name == "_" else self.target.joinpath(name)
target.mkdir(parents=True, exist_ok=True)
command += ["-d", str(target)]
if self.mfa_secret:
totp = subprocess.run(
f"oathtool --base32 --totp {self.mfa_secret}",
text=True,
capture_stdout=True).stdout
command += ["-a", totp]
logging.debug(f"Running {' '.join(command)}")
subprocess.run(command)
def follow(self):
logging.debug(f"Running `tail -v -f {self.log}`")
subprocess.run(["tail", "-v", "-f", self.log])
def healthcheck(self):
tasks = self.rpc.get_clone_tasks()
healthy = True
for task in tasks:
name = task.repo_name
state = task.state
if task.state == 'done':
continue
elif state == "fetch":
tx_task = self.rpc.find_transfer_task(task.repo_id)
percentage = 0 if tx_task.block_done == 0 else tx_task.block_done / tx_task.block_total * 100
rate = 0 if tx_task.rate == 0 else tx_task.rate / 1024.0
print(f"{name:<50s}\t{state:<20s}\t{percentage:<.1f}%, {rate:<.1f}KB/s")
elif task.state == "error":
healthy = False
error = self.rpc.sync_error_id_to_str(task.error)
print(f"{name:<50s}\t{state:<20s}\t{error}")
else:
print(f"{name:<50s}\t{state:<20s}")
repos = self.rpc.get_repo_list(-1, -1)
for repo in repos:
name = repo.name
auto_sync_enabled = self.rpc.is_auto_sync_enabled()
if not auto_sync_enabled or not repo.auto_sync:
state = "auto sync disabled"
print(f"{name:<50s}\t{state:<20s}")
continue
task = self.rpc.get_repo_sync_task(repo.id)
if task is None:
state = "waiting for sync"
print(f"{name:<50s}\t{state:<20s}")
continue
state = task.state
if state in ['uploading', 'downloading']:
tx_task = self.rpc.find_transfer_task(repo.id)
if tx_task.rt_state == "data":
state += " files"
percentage = 0 if tx_task.block_done == 0 else tx_task.block_done / tx_task.block_total * 100
rate = 0 if tx_task.rate == 0 else tx_task.rate / 1024.0
print(f"{name:<50s}\t{state:<20s}\t{percentage:<.1f}%, {rate:<.1f}KB/s")
elif tx_task.rt_state == "fs":
state += " files list"
percentage = 0 if tx_task.fs_objects_done == 0 else tx_task.fs_objects_done / tx_task.fs_objects_total * 100
print(f"{name:<50s}\t{state:<20s}\t{percentage:<.1f}%")
elif state == 'error':
healthy = False
error = self.rpc.sync_error_id_to_str(task.error)
print(f"{name:<50s}\t{state:<20s}\t{error}")
else:
print(f"{name:<50s}\t{state:<20s}")
def entrypoint():
try:
logging.debug("Instanciating the client")
client = Client()
except BadConfiguration as e:
logger.error(f"Bad configuration: {e}")
sys.exit(1)
logging.debug("Initializing the client")
client.initialize()
logging.debug("Configuring the client")
client.configure()
logging.debug("Synchronizing the client")
client.synchronize()
logging.debug("Following the client")
client.follow()
debug = get_configuration("DEBUG", False)
level = logging.INFO
format = "%(asctime)s - %(levelname)s - %(message)s"
if debug:
level = logging.DEBUG
format = "%(asctime)s - %(filename)s:%(lineno)d - %(levelname)s - %(message)s"
logging.basicConfig(format=format, level=level)
logger = logging.getLogger()
if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog="",
description="",
epilog=""
)
parser.add_argument("--healthcheck", action="store_true")
args = parser.parse_args()
healthcheck = args.healthcheck
if healthcheck:
logger.disabled = True
try:
logging.debug("Instanciating the client")
client = Client()
except BadConfiguration as e:
logger.error(f"Bad configuration: {e}")
sys.exit(1)
if healthcheck:
logging.debug("Running healthchecks")
sys.exit(client.healthcheck())
logging.debug("Initializing the client")
client.initialize()
logging.debug("Configuring the client")
client.configure()
logging.debug("Synchronizing the client")
client.synchronize()
logging.debug("Following the client")
client.follow()

4
seafile-client/issue Normal file
View File

@@ -0,0 +1,4 @@
┌───────────────────────┐
│ Seafile Docker client │
└───────────────────────┘
Run `./entrypoint.sh bash` to login as the seafile user.

6
tests/image/Dockerfile Normal file
View File

@@ -0,0 +1,6 @@
ARG TARGET=unstable
FROM seafile-client:${TARGET}-flrnnc
COPY --chmod=755 test_binaries.sh /test.sh
CMD ["/test.sh"]

View File

@@ -1,7 +1,7 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
# Copyright (C) 2019-2024, florian.anceau@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,12 +16,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
not_imported=true
while $not_imported; do
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8756C4F765C9AC3CB6B85D62379CE192D401AB61
if [ $? -eq 0 ]; then
not_imported=false
else
sleep 5
fi
done
failures=()
binaries=(seaf-cli oathtool grep)
for binary in "${binaries[@]}"; do
if ! [ -x "$(command -v $binary)" ]; then
echo "$binary was not found"
failures+=($binary)
else
echo "$binary was found"
fi
done
if [ ${#failures[@]} -ne 0 ]; then
exit 1
fi

56
tests/mock/compose.yaml Normal file
View File

@@ -0,0 +1,56 @@
name: mock-docker-seafile-client
services:
mariadb:
image: mariadb:10.11
environment:
- MYSQL_ROOT_PASSWORD=password # Requested, set the root's password of MySQL service.
- MYSQL_LOG_CONSOLE=true
- MARIADB_AUTO_UPGRADE=1
volumes:
- database:/var/lib/mysql # Requested, specifies the path to MySQL data persistent store.
memcached:
image: memcached:1.6.18
container_name: seafile-memcached
entrypoint: memcached -m 256
seafile:
image: seafileltd/seafile-mc:latest
ports:
- "80:80"
volumes:
- seafile:/shared # Requested, specifies the path to Seafile data persistent store.
environment:
- DB_HOST=mariadb
- DB_ROOT_PASSWD=password # Requested, the value should be root's password of MySQL service.
- TIME_ZONE=Etc/UTC # Optional, default is UTC. Should be uncomment and set to your local time zone.
- SEAFILE_ADMIN_EMAIL=seafile@localhost # Specifies Seafile admin user, default is 'me@example.com'.
- SEAFILE_ADMIN_PASSWORD=password # Specifies Seafile admin password, default is 'asecret'.
- SEAFILE_SERVER_LETSENCRYPT=false # Whether to use https or not.
depends_on:
- mariadb
- memcached
client:
image: seafile-client:${TARGET}-flowgunso
volumes:
#- library:/library
- data:/seafile
# user: "1000:1000"
environment:
SEAF_SERVER_URL: "http://seafile"
SEAF_USERNAME: "seafile@localhost"
SEAF_PASSWORD: "password"
SEAF_LIBRARY: "1b7d4e92-6753-4c4a-85b0-42566eab42c8"
DEBUG: 1
UID: 1000
GID: 100
depends_on:
- seafile
volumes:
database:
seafile:
library:
data:

View File

@@ -1,34 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Restrict to pipeline triggered by pushes.
if [ $CI_PIPELINE_SOURCE != "push" ]; then
echo "This must be only ran from pushes."
exit 1
fi
# Login with Docker Registry.
echo $CI_REGISTRY_BOT_PASSWORD | docker login -u $CI_REGISTRY_BOT_USERNAME docker.io --password-stdin
# Build and push as staging.
docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord -f assets/supervisord/Dockerfile .
docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-cron -f assets/cron/Dockerfile .
docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-bash -f assets/bash/Dockerfile .
docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord
docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-cron
docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-bash

View File

@@ -1,70 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Restrict production build to tag matching MAJOR.MINOR.REVISION.
if ! [[ "$CI_COMMIT_TAG" =~ ^[0-9]+[.][0-9]+[.][0-9]+$ ]]; then
echo "Version number must match major.minor.revision!"
exit 1
fi
# When this stage is ran from 'push', the build target is BUILD_LATEST.
# When this stage is ran from 'trigger', the build target must be provided.
# Otherwise, stop the stage.
if [ $CI_PIPELINE_SOURCE == "push" ]; then
BUILD_LATEST=true
elif [ $CI_PIPELINE_SOURCE == "trigger" ]; then
if [ -z $BUILD_LATEST ] && \
[ -z $BUILD_MAJOR ] && \
[ -z $BUILD_MINOR ] && \
[ -z $BUILD_REVISION ]; then
echo "You must provide build targets to this stage when ran from Pipeline Triggers."
exit 1
fi
else
echo "This stage is restricted to 'push' or 'trigger' Pipeline sources."
exit 1
fi
# Cascade the builds by inheritance.
if [ $BUILD_LATEST ]; then BUILD_MAJOR=true; BUILD_MINOR=true; BUILD_REVISION=true; fi
if [ $BUILD_MAJOR ]; then BUILD_MINOR=true; BUILD_REVISION=true; fi
if [ $BUILD_MINOR ]; then BUILD_REVISION=true; fi
# Define MAJOR, MINOR and REVISION version numbers.
MAJOR_NUMBER=$(echo "$CI_COMMIT_TAG" | awk -F \. {'print $1'})
MINOR_NUMBER=$(echo "$CI_COMMIT_TAG" | awk -F \. {'print $2'})
REVISION_NUMBER=$(echo "$CI_COMMIT_TAG" | awk -F \. {'print $3'})
MAJOR=$MAJOR_NUMBER
MINOR=$MAJOR.$MINOR_NUMBER
REVISION=$MINOR.$REVISION_NUMBER
# Always build with all tags, there's a single build anyway.
docker build \
-t index.docker.io/$CI_REGISTRY_IMAGE:latest \
-t index.docker.io/$CI_REGISTRY_IMAGE:$MAJOR \
-t index.docker.io/$CI_REGISTRY_IMAGE:$MINOR \
-t index.docker.io/$CI_REGISTRY_IMAGE:$REVISION .
# Login with Docker Registry.
echo $CI_REGISTRY_BOT_PASSWORD | docker login -u $CI_REGISTRY_BOT_USERNAME docker.io --password-stdin
# Only push requested builds.
if [ $BUILD_LATEST ]; then docker push index.docker.io/$CI_REGISTRY_IMAGE:latest; fi
if [ $BUILD_MAJOR ]; then docker push index.docker.io/$CI_REGISTRY_IMAGE:$MAJOR; fi
if [ $BUILD_MINOR ]; then docker push index.docker.io/$CI_REGISTRY_IMAGE:$MINOR; fi
if [ $BUILD_REVISION ]; then docker push index.docker.io/$CI_REGISTRY_IMAGE:$REVISION; fi

View File

@@ -1,30 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Restrict to pipeline triggered by pushes.
if [ $CI_PIPELINE_SOURCE != "push" ]; then
echo "This must be only ran from pushes."
exit 1
fi
# Login with Docker Registry.
echo $CI_REGISTRY_BOT_PASSWORD | docker login -u $CI_REGISTRY_BOT_USERNAME docker.io --password-stdin
# Build and push as staging.
docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging .
docker push index.docker.io/$CI_REGISTRY_IMAGE:staging

View File

@@ -1,46 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Based upon https://gist.github.com/jlhawn/8f218e7c0b14c941c41f
# and https://github.com/moikot/golang-dep/blob/master/.travis/push.sh
# This action can only be done with the actual owner of the repository,
# unless you can extend the collaborator's permissions but as far as I know, you can't.
# Install required system packages.
apk add curl jq
# Get a token from hub.docker.com with the owner credentials.
token=$(curl -s \
-X POST \
-H "Content-Type: application/json" \
-d '{"username": "'"$CI_REGISTRY_OWNER_USERNAME"'", "password": "'"$CI_REGISTRY_OWNER_PASSWORD"'"}' \
https://hub.docker.com/v2/users/login/ | jq -r .token)
# Generate a JSON with the README.md as the full_description.
json=$(jq -n \
--arg readme "$(<README.md)" \
'{"full_description": $readme}')
# Update the Docker Hub repository's full_description.
curl -s -L \
-X PATCH \
-d "$json" \
-H "Content-Type: application/json" \
-H "Authorization: JWT $token" \
https://cloud.docker.com/v2/repositories/$CI_REGISTRY_IMAGE/