Skip to content

Commit

Permalink
refactored project files
Browse files Browse the repository at this point in the history
  • Loading branch information
savageautomate committed Mar 5, 2022
1 parent 13e454f commit 62ebd74
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
backup
Dockerfile
.gitignore
.git
.git
node_modules
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ LABEL org.label-schema.docker.cmd="docker run -it --rm --name portainer-backup -

# INSTALL ADDITIONAL IMAGE DEPENDENCIES AND COPY APPLICATION TO IMAGE
RUN apk update && apk add --no-cache tzdata
RUN mkdir -p /app
COPY app/package.json /app
COPY app/*.js /app
WORKDIR /app
RUN mkdir -p /portainer-backup/src
COPY package.json /portainer-backup
COPY src/*.js /portainer-backup/src
WORKDIR /portainer-backup
VOLUME "/backup"
RUN npm install --silent

Expand All @@ -66,7 +66,7 @@ ENV PORTAINER_BACKUP_DRYRUN=false
ENV PORTAINER_BACKUP_STACKS=false

# NODEJS RUNNING THIS APPLICATION IS THE ENTRYPOINT
ENTRYPOINT [ "/usr/local/bin/node", "index.js" ]
ENTRYPOINT [ "/usr/local/bin/node", "/portainer-backup/src/index.js" ]

# DEFAULT COMMAND (if none provided)
CMD ["schedule"]
File renamed without changes
2 changes: 1 addition & 1 deletion build-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# *********************************************************************

# GET VERSION FROM PACKAGE.JSON
VERSION=$(node -p -e "require('./app/package.json').version")
VERSION=$(node -p -e "require('./package.json').version")

# ------------------------------------------------
# BUILD DOCKER CONTAINER
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# *********************************************************************

# GET VERSION FROM PACKAGE.JSON
VERSION=$(node -p -e "require('./app/package.json').version")
VERSION=$(node -p -e "require('./package.json').version")

# use buildx to create a new builder instance; if needed
docker buildx create --driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=10485760 \
Expand Down
3 changes: 1 addition & 2 deletions app/package-lock.json → package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions app/package.json → package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "portainer-backup",
"version": "0.0.4",
"description": "Utility for scripting or scheduling scheduled backups for Portainer",
"readme": "../README.md",
"readme": "README.md",
"keywords": [
"portainer",
"backup",
Expand All @@ -24,16 +24,17 @@
"main": "index.js",
"type": "module",
"bin": {
"portainer-backup": "index.js"
"portainer-backup": "src/index.js"
},
"scripts": {
"start": "node src/index.js",
"build": "npm install",
"help": "node index.js help",
"schedule": "node index.js schedule",
"backup": "node index.js backup",
"stacks": "node index.js stacks",
"info": "node index.js info",
"restore": "node index.js restore"
"help": "node src/index.js help",
"schedule": "node src/index.js schedule",
"backup": "node src/index.js backup",
"stacks": "node src/index.js stacks",
"info": "node src/index.js info",
"restore": "node src/index.js restore"
},
"dependencies": {
"axios": "^0.26.0",
Expand All @@ -46,7 +47,6 @@
"gradient-string": "^2.0.0",
"log-symbols": "^5.1.0",
"luxon": "^2.3.1",
"moment": "^2.29.1",
"node-cron": "^3.0.0",
"pretty-bytes": "^6.0.0",
"sanitize-filename": "^1.6.3",
Expand Down
38 changes: 38 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh -e
# *********************************************************************
# ___ ___ ___ ___ ___
# / __| /_\ \ / /_\ / __| __|
# \__ \/ _ \ V / _ \ (_ | _|
# |___/_/_\_\_/_/_\_\___|___| ___ ___ ___
# / __|/ _ \| __|_ _\ \ / /_\ | _ \ __|
# \__ \ (_) | _| | | \ \/\/ / _ \| / _|
# |___/\___/|_| |_| \_/\_/_/ \_\_|_\___|
#
# -------------------------------------------------------------------
# PORTAINER-BACKUP
# https://github.com/SavageSoftware/portainer-backup
# -------------------------------------------------------------------
#
# This script compiles and builds the current project sources into
# a Docker container image for ARM64 and x86_64 platforms. Next,
# the script publishes the Docker images, publishes the project
# to the NPM registry.
#
# *********************************************************************
# COPYRIGHT SAVAGESOFTWARE,LLC, @ 2022, ALL RIGHTS RESERVED
# *********************************************************************

# BUMP VERSION IN PACKAGE.JSON
npm version patch

# BUILD AND PUSH DOCKER IMAGES TO: DockerHub
# https://hub.docker.com/repository/docker/savagesoftware/portainer-backup
./build.sh --push

# PUSH README.MD TO: DockerHub
# https://hub.docker.com/repository/docker/savagesoftware/portainer-backup
docker pushrm savagesoftware/portainer-backup

# PUBLISH TO: NPM REGISTRY
# https://www.npmjs.com/package/portainer-backup
npm publish
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

A utility for scripting or scheduling Portainer backups. This utility can backup the entire Portainer database, optionally protect the archive file with a password and can additionally backup the `docker-compose` files for stacks created in the Portainer web interface.

![SCREENSHOT](./app/screenshot.jpg)
![SCREENSHOT](https://github.com/SavageSoftware/portainer-backup/raw/master/assets/screenshot.jpg)

[![NPM](https://nodei.co/npm/portainer-backup.png?downloads=true&downloadRank=false&stars=false)](https://www.npmjs.com/package/portainer-backup)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion app/index.js → src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { createRequire } from 'module';

// use the require approach to obtain package.json
const require = createRequire(import.meta.url);
const pkg = require('./package.json');
const pkg = require('../package.json');

// create deafult context
let context = {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 62ebd74

Please sign in to comment.