Skip to content

Commit f7c6385

Browse files
committed
dockerized
closes #4
1 parent 33b2b69 commit f7c6385

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# User lightwight base image
2+
FROM node:20.9.0-alpine
3+
4+
# Install Git
5+
RUN apk add --no-cache git
6+
7+
# Define work directory
8+
WORKDIR /usr/src/app
9+
10+
# Copy package definition
11+
COPY package*.json ./
12+
13+
# Install dependencies
14+
RUN npm install
15+
16+
# Copy source files
17+
COPY . .
18+
19+
# Start backup script
20+
CMD ["node", "index.js"]

Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
.PHONY: backup
1+
.PHONY: backup docker_cleanup
22

3-
backup: install
4-
node index.js
3+
backup: docker_run
54

6-
install:
7-
npm install
5+
docker_run: docker_build
6+
docker run --rm --name github-backup github-backup
87

8+
docker_build: docker_cleanup
9+
docker build -t github-backup .
10+
11+
docker_cleanup:
12+
docker stop github-backup || true
13+
docker rm github-backup || true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Local backup of your GitHub data.
1515

1616
## Usage
1717

18-
Requirements: Node.js
18+
Requirements: Docker
1919

2020
1. Clone this repository
2121
2. Update and save `credentials.template.js` as `credentials.js`

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import fetch from 'node-fetch'
55
import { extension } from 'mime-types'
66
import credentials from './credentials.js'
77

8+
shell.config.fatal = true
9+
810
const perPage = 100
911
const retryCount = 10
1012
const retryDelayRateLimit = 6 * 60
@@ -152,8 +154,7 @@ async function backup() {
152154
try {
153155

154156
// Reset the backup folder
155-
shell.exec(`rm -r ${folder}`)
156-
fs.ensureDirSync(folder)
157+
fs.emptyDirSync(folder)
157158

158159
// Get repositories
159160
const repositories = await requestAllWithRetry('/user/repos')

0 commit comments

Comments
 (0)