From 47487beeba8537ad3fe752b0b7a4d9a45ca4b5db Mon Sep 17 00:00:00 2001 From: sijmenhuizenga Date: Sat, 12 Sep 2020 00:11:07 +0200 Subject: [PATCH] Docker support --- Dockerfile | 22 ++++++++++++++++++++++ README.md | 24 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fe6a447 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM golang:1.12 as builder + +WORKDIR /project +COPY main.go go.mod go.sum ./ +COPY downloader ./downloader +ADD vendor ./vendor +ADD version ./version + +# Production-ready build, without debug information specifically for linux +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o=gitmoo-goog -mod=vendor . + + +FROM alpine:3.12 + +# Add CA certificates required for SSL connections +RUN apk add --update --no-cache ca-certificates + +COPY --from=builder /project/gitmoo-goog /usr/local/bin/gitmoo-goog + +RUN mkdir /app +WORKDIR /app +ENTRYPOINT ["/usr/local/bin/gitmoo-goog"] \ No newline at end of file diff --git a/README.md b/README.md index 138da1b..40f6618 100644 --- a/README.md +++ b/README.md @@ -95,3 +95,27 @@ Logfile will be saved as `gitmoo.log`. Files are created as follows: `[folder][year][month][day]_[hash].json` and `.jpg`. The `json` file holds the metadata from `google-photos`. + +## Docker (Linux only) + +You can run gitmoo-goog in Docker. At the moment you have to build the image yourself. After cloning the repo run: + +``` +$ docker build -t dtylman/gitmoo-goog:latest . +``` + +Now run gitmoo-goo in Docker: + +``` +$ docker run -v $(pwd):/app --user=$(id -u):$(id -g) dtylman/gitmoo-goog:latest +``` + +Replace `$(pwd)` with the location of your storage directory on your computer. +Within the storage directory gitmoo-goog expects the `credentials.json` and will place all the downloaded files. + +The part `--user=$(id -u):$(id -g)` ensures that the downloaded files are owned by the user launching the container. + +Configuring additional settings is possible by adding command arguments like so: +``` +$ docker run -v $(pwd):/app --user=$(id -u):$(id -g) dtylman/gitmoo-goog:latest -loop -throttle 45 +```