MStadlmeier / drivesync

Google Drive synchronization for Linux
MIT License
197 stars 26 forks source link

Added Dockerfile, added build and run instructions. #39

Closed tedsluis closed 4 years ago

tedsluis commented 4 years ago

This pull request adds the instructions and Dockerfile to run drivesync in a container using Docker or Podman.

The Dockerfile is meant to build an image based on the official ruby:2.6.6 image with the drivesync source code.

I added a short instruction to the README.md that describes building and starting drive sync.

Below the output of the drivesync image build:

$ docker build -t drivesync .                                                                                                                                                             
STEP 1: FROM ruby:2.6.6                                                                                                                                                                                                                       
Getting image source signatures                                                                                                                                                                                                               
Copying blob 8d134d749716 done                                                                                                                                                                                                                
Copying blob 5a63a0a859d8 done                                                                                                                                                                                                                
Copying blob 0ed5a9824906 done                                                                                                                                                                                                                
Copying blob 496548a8c952 done                                                                                                                                                                                                                
Copying blob 376057ac6fa1 done                                                                                                                                                                                                                
Copying blob 2adae3950d4d done                                                                                                                                                                                                                
Copying blob 174d855079b8 done                                                                                                                                                                                                                
Copying blob a749489e9ce3 done                                                                                                                                                                                                                
Copying config 107c48f680 done                                                                                                                                                                                                                
Writing manifest to image destination                                                                                                                                                                                                         
Storing signatures                                                                                                                                                                                                                            
STEP 2: RUN git clone https://github.com/MStadlmeier/drivesync.git /drivesync                                                                                                                                                                 
Cloning into '/drivesync'...                                                                                                                                                                                                                  
remote: Enumerating objects: 3, done.                                                                                                                                                                                                         
remote: Counting objects: 100% (3/3), done.                                                                                                                                                                                                   
remote: Compressing objects: 100% (3/3), done.                                                                                                                                                                                                
remote: Total 245 (delta 0), reused 2 (delta 0), pack-reused 242                                                                                                                                                                              
Receiving objects: 100% (245/245), 53.05 KiB | 448.00 KiB/s, done.                                                                                                                                                                            
Resolving deltas: 100% (153/153), done.                                                                                                                                                                                                       
--> febb80e1ba4                                                                                                                                                                                                                               
STEP 3: RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales                                                                                                                                                       
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]                                                                                                                                                           
Get:2 http://deb.debian.org/debian buster InRelease [121 kB]                                                                                                                                                                                  
Get:3 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]                                                                                                                                                                         
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [201 kB]                                                                                                                                                  
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7905 kB]                                                                                                                                                                       
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [7380 B]                                                                                                                                                                
Fetched 8350 kB in 1s (5703 kB/s)                                                                                                                                                                                                             
Reading package lists... Done                                                                                                                                                                                                                 
Reading package lists... Done                                                                                                                                                                                                                 
Building dependency tree                                                                                                                                                                                                                      
Reading state information... Done                                                                                                                                                                                                             
The following additional packages will be installed:                                                                                                                                                                                          
  libc-l10n                                                                                                                                                                                                                                   
The following NEW packages will be installed:                                                                                                                                                                                                 
  libc-l10n locales
0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
Need to get 4907 kB of archives.
After this operation, 20.8 MB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 libc-l10n all 2.28-10 [847 kB]
Get:2 http://deb.debian.org/debian buster/main amd64 locales all 2.28-10 [4060 kB]
Fetched 4907 kB in 0s (21.7 MB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libc-l10n.
(Reading database ... 23979 files and directories currently installed.)
Preparing to unpack .../libc-l10n_2.28-10_all.deb ...
Unpacking libc-l10n (2.28-10) ...
Selecting previously unselected package locales.
Preparing to unpack .../locales_2.28-10_all.deb ...
Preparing to unpack .../locales_2.28-10_all.deb ...                                                                                                                                                                                           
Unpacking locales (2.28-10) ...                                                                                                                                                                                                               
Setting up libc-l10n (2.28-10) ...                                                                                                                                                                                                            
Setting up locales (2.28-10) ...                                                                                                                                                                                                              
Generating locales (this might take a while)...                                                                                                                                                                                               
Generation complete.                                                                                                                                                                                                                          
--> 893d3e8b1c5                                                                                                                                                                                                                               
STEP 4: RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen &&     dpkg-reconfigure --frontend=noninteractive locales &&     update-locale LANG=en_US.UTF-8                                                              
Generating locales (this might take a while)...                                                                                                                                                                                               
  en_US.UTF-8... done                                                                                                                                                                                                                         
Generation complete.                                                                                                                                                                                                                          
--> 10ce88f4cd8                                                                                                                                                                                                                               
STEP 5: ENV LANG en_US.UTF-8                                                                                                                                                                                                                  
--> 9cddf37aebe
STEP 6: ENV LC_ALL en_US.UTF-8
--> 54de2287c04
STEP 7: WORKDIR /drivesync
--> 5df7c1c7d20
STEP 8: RUN bundle update --bundler     && bundle install
Fetching gem metadata from https://rubygems.org/........
Fetching public_suffix 3.0.2
Installing public_suffix 3.0.2
Fetching addressable 2.5.2
Installing addressable 2.5.2
Using bundler 1.17.2
Fetching declarative 0.0.10
Installing declarative 0.0.10
Fetching declarative-option 0.1.0
Installing declarative-option 0.1.0
Fetching multipart-post 2.0.0
Installing multipart-post 2.0.0
Fetching faraday 0.15.2
Installing faraday 0.15.2
Fetching jwt 2.1.0
Installing jwt 2.1.0
Fetching little-plugger 1.1.4
Installing little-plugger 1.1.4
Fetching multi_json 1.13.1
Installing multi_json 1.13.1
Fetching logging 2.2.2
Installing logging 2.2.2
Fetching memoist 0.16.0
Installing memoist 0.16.0
Fetching os 0.9.6
Installing os 0.9.6
Fetching signet 0.8.1
Installing signet 0.8.1
Fetching googleauth 0.6.2
Installing googleauth 0.6.2
Fetching httpclient 2.8.3
Installing httpclient 2.8.3
Fetching mime-types-data 3.2016.0521
Installing mime-types-data 3.2016.0521
Fetching mime-types 3.1
Installing mime-types 3.1
Fetching uber 0.1.0
Installing uber 0.1.0
Fetching representable 3.0.4
Installing representable 3.0.4
Fetching retriable 3.1.2
Installing retriable 3.1.2
Fetching google-api-client 0.23.4
Installing google-api-client 0.23.4
Bundle updated!
Using public_suffix 3.0.2
Using addressable 2.5.2
Using bundler 1.17.2
Using declarative 0.0.10
Using declarative-option 0.1.0
Using multipart-post 2.0.0
Using faraday 0.15.2
Using jwt 2.1.0
Using little-plugger 1.1.4
Using multi_json 1.13.1
Using logging 2.2.2
Using memoist 0.16.0
Using os 0.9.6
Using signet 0.8.1
Using googleauth 0.6.2
Using httpclient 2.8.3
Using mime-types-data 3.2016.0521
Using mime-types 3.1
Using uber 0.1.0
Using representable 3.0.4
Using retriable 3.1.2
Using google-api-client 0.23.4
Bundle complete! 1 Gemfile dependency, 22 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
STEP 9: COMMIT drivesync
--> a924a460204
a924a460204b398faefd3ad7457eb05a1e1bed689d37271103a21e2f6807f0ed

The ruby:2.6.6 base image and the drivesync image:

$ docker images
REPOSITORY                   TAG      IMAGE ID       CREATED          SIZE
localhost/drivesync          latest   a924a460204b   19 minutes ago   994 MB
docker.io/library/ruby       2.6.6    107c48f680c0   12 days ago      862 MB

The run:

$ docker run -it -v /etc/localtime:/etc/localtime:ro \
                 -v /root/Documents/drive:/root/Documents/drive:z \
                 -v /root/.credentials:/root/.credentials:z \
                 -v /root/.drivesync:/root/.drivesync:z \
                 drivesync \
                 ruby drivesync.rb
Local folder is 3 files behind and 0 files ahead of remote
Starting sync at 2020-05-28 23:02:54 +0200
Downloading file files/spot02.mp3 ...                                                                               
Downloading file files/photo3736453.jpeg ...                                                                          
Downloading file files/list.xml ...       
Sync complete.
MStadlmeier commented 4 years ago

@tedsluis Thanks for the contribution! I will cherry-pick this into the development branch and include it in the next release.

MStadlmeier commented 4 years ago

Merged into develop