From e0fa626ac6d81de2d14daed81b6e01c07c2c7642 Mon Sep 17 00:00:00 2001 From: Emile Nijssen Date: Wed, 31 Jul 2024 19:06:35 +0200 Subject: [PATCH] add dockerfile --- .gitignore | 1 + Dockerfile | 14 ++++++++++++++ bin/google-backup.mjs | 1 - docker-compose.yml | 12 ++++++++++++ package.json | 7 +++++-- 5 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index adaa929..064f597 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /node_modules/ +/.env /.envrc /backups/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7561551 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM node:lts + +RUN mkdir /app +WORKDIR /app + +COPY ./bin/ /app/bin/ +COPY ./lib/ /app/lib/ +COPY ./index.mjs /app/ +COPY ./package.json /app/ +COPY ./package-lock.json /app/ + +RUN npm ci + +CMD npm start \ No newline at end of file diff --git a/bin/google-backup.mjs b/bin/google-backup.mjs index 193b982..d3b861c 100755 --- a/bin/google-backup.mjs +++ b/bin/google-backup.mjs @@ -1,7 +1,6 @@ #!/usr/bin/env node import fs from 'fs'; -import path from 'path'; import { program } from 'commander'; import GoogleBackup from '../lib/GoogleBackup.mjs'; diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2b477ae --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +services: + google-backup: + image: google-backup + build: + context: . + dockerfile: Dockerfile + environment: + - GOOGLE_BACKUP_USERNAME + - GOOGLE_BACKUP_PASSWORD + - GOOGLE_BACKUP_FILEPATH=/backups/ + volumes: + - ./backups:/backups \ No newline at end of file diff --git a/package.json b/package.json index f30a7dd..a84aa7e 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,10 @@ "version": "1.0.1", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node ./bin/google-backup.mjs", + "build:docker": "docker build -t google-backup .", + "start:docker": "docker compose up" }, "bin": { "google-backup": "./bin/google-backup.mjs" @@ -20,4 +23,4 @@ "tsdav": "^2.1.0", "vcard-parser": "^1.0.0" } -} +} \ No newline at end of file