housekeeping
1
.github/workflows/docker-publish.yml
vendored
|
@ -91,3 +91,4 @@ jobs:
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
file: {context}/docker/Dockerfile
|
||||||
|
|
2
.github/workflows/main.yml
vendored
|
@ -11,5 +11,5 @@ jobs:
|
||||||
- name: Cypress run
|
- name: Cypress run
|
||||||
uses: cypress-io/github-action@v4
|
uses: cypress-io/github-action@v4
|
||||||
with:
|
with:
|
||||||
build: node db.js
|
build: node app/db.js
|
||||||
start: npm start
|
start: npm start
|
||||||
|
|
|
@ -13,11 +13,11 @@ Upcoming Features:
|
||||||
Source:
|
Source:
|
||||||
```Bash
|
```Bash
|
||||||
EBPASS=changeme
|
EBPASS=changeme
|
||||||
EBPORT=4000
|
EBPORT=3000
|
||||||
EBAPI_KEY=changeme #ShareX support
|
EBAPI_KEY=changeme #ShareX support
|
||||||
|
|
||||||
$ npm install
|
$ npm install
|
||||||
$ node db.js
|
$ node app/db.js
|
||||||
$ npm start
|
$ npm start
|
||||||
```
|
```
|
||||||
Default username is admin with the password being whatever EBPASS is
|
Default username is admin with the password being whatever EBPASS is
|
||||||
|
@ -49,7 +49,7 @@ JSON
|
||||||
|
|
||||||
Docker config
|
Docker config
|
||||||
```
|
```
|
||||||
docker run -d -p "4000:4000" -e EBPORT=4000 -e EBPASS=changeme -e EBAPI_KEY=changeme ghcr.io/waveringana/embedder:1.7.1
|
docker run -d -p "3000:3000" -e EBPORT=3000 -e EBPASS=changeme -e EBAPI_KEY=changeme ghcr.io/waveringana/embedder:1.7.1
|
||||||
```
|
```
|
||||||
|
|
||||||
Docker Compose
|
Docker Compose
|
||||||
|
|
|
@ -13,7 +13,7 @@ const path = require("path");
|
||||||
const authRouter = require("./routes/auth");
|
const authRouter = require("./routes/auth");
|
||||||
const indexRouter = require("./routes/index");
|
const indexRouter = require("./routes/index");
|
||||||
|
|
||||||
const db = require("./db");
|
const db = require("./db").db;
|
||||||
|
|
||||||
let app = express();
|
let app = express();
|
||||||
let server = http.createServer(app);
|
let server = http.createServer(app);
|
|
@ -10,25 +10,28 @@ let db = new sqlite3.Database("./var/db/media.db");
|
||||||
db.serialize(function() {
|
db.serialize(function() {
|
||||||
// create the database schema for the todos app
|
// create the database schema for the todos app
|
||||||
db.run("CREATE TABLE IF NOT EXISTS users ( \
|
db.run("CREATE TABLE IF NOT EXISTS users ( \
|
||||||
id INTEGER PRIMARY KEY, \
|
id INTEGER PRIMARY KEY, \
|
||||||
username TEXT UNIQUE, \
|
username TEXT UNIQUE, \
|
||||||
hashed_password BLOB, \
|
hashed_password BLOB, \
|
||||||
salt BLOB \
|
salt BLOB \
|
||||||
)");
|
)");
|
||||||
|
|
||||||
db.run("CREATE TABLE IF NOT EXISTS media ( \
|
db.run("CREATE TABLE IF NOT EXISTS media ( \
|
||||||
id INTEGER PRIMARY KEY, \
|
id INTEGER PRIMARY KEY, \
|
||||||
path TEXT NOT NULL, \
|
path TEXT NOT NULL, \
|
||||||
expire INTEGER \
|
expire INTEGER \
|
||||||
)");
|
)");
|
||||||
|
|
||||||
// create an initial user (username: alice, password: letmein)
|
createUser("admin", process.env.EBPASS || "changeme");
|
||||||
var salt = crypto.randomBytes(16);
|
|
||||||
db.run("INSERT OR IGNORE INTO users (username, hashed_password, salt) VALUES (?, ?, ?)", [
|
|
||||||
"admin",
|
|
||||||
crypto.pbkdf2Sync(process.env.EBPASS || "changeme", salt, 310000, 32, "sha256"),
|
|
||||||
salt
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = db;
|
function createUser(username, password) {
|
||||||
|
var salt = crypto.randomBytes(16);
|
||||||
|
db.run("INSERT OR IGNORE INTO users (username, hashed_password, salt) VALUES (?, ?, ?)", [
|
||||||
|
username,
|
||||||
|
crypto.pbkdf2Sync(password, salt, 310000, 32, "sha256"),
|
||||||
|
salt
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {db: db, createUser: createUser};
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 400 KiB After Width: | Height: | Size: 400 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 954 B After Width: | Height: | Size: 954 B |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
@ -3,7 +3,7 @@ const express = require("express");
|
||||||
const passport = require("passport");
|
const passport = require("passport");
|
||||||
const LocalStrategy = require("passport-local");
|
const LocalStrategy = require("passport-local");
|
||||||
|
|
||||||
let db = require("../db");
|
let db = require("../db").db;
|
||||||
|
|
||||||
let router = express.Router();
|
let router = express.Router();
|
||||||
|
|
|
@ -10,7 +10,7 @@ ffmpeg.setFfprobePath(ffprobepath);
|
||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
||||||
let db = require("../db");
|
let db = require("../db").db;
|
||||||
let {checkAuth, convert, handleUpload} = require("./middleware");
|
let {checkAuth, convert, handleUpload} = require("./middleware");
|
||||||
|
|
||||||
function extension(str){
|
function extension(str){
|
|
@ -7,7 +7,7 @@ ffmpeg.setFfprobePath(ffprobepath);
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const process = require("process");
|
const process = require("process");
|
||||||
|
|
||||||
let db = require("../db.js");
|
let db = require("../db.js").db;
|
||||||
|
|
||||||
function extension(str){
|
function extension(str){
|
||||||
let file = str.split("/").pop();
|
let file = str.split("/").pop();
|
|
@ -33,17 +33,17 @@ function extension(str){
|
||||||
<meta property="og:video:type" content="video/mp4"></meta>
|
<meta property="og:video:type" content="video/mp4"></meta>
|
||||||
<meta property="og:url" content="<%= host %>/uploads/<%= extension(url)[0] %>.mp4"></meta>
|
<meta property="og:url" content="<%= host %>/uploads/<%= extension(url)[0] %>.mp4"></meta>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
<link rel="alternate" type="application/json+oembed" href="<%= host %>/uploads/oembed-<%= extension(url)[0]+extension(url)[1] %>.json"></link>
|
<link rel="alternate" type="application/json+oembed" href="<%= host %>/uploads/oembed-<%= extension(url)[0]+extension(url)[1] %>.json"></link>
|
||||||
<meta property="og:title" content="<%= extension(url)[0] + extension(url)[1] %>"></meta>
|
<meta property="og:title" content="<%= extension(url)[0] + extension(url)[1] %>"></meta>
|
||||||
<meta property="og:description" content="Click to view the image"></meta>
|
<meta property="og:description" content="Click to view the image"></meta>
|
||||||
<meta property="og:site_name" content="embedder"></meta>
|
<meta property="og:site_name" content="embedder"></meta>
|
||||||
<meta property="og:type" content="article"></meta>
|
<meta property="og:type" content="article"></meta>
|
||||||
<meta property="og:image" content="<%= host %>/uploads/<%= extension(url)[0] + extension(url)[1] %>"></meta>
|
<meta property="og:image" content="<%= host %>/uploads/<%= extension(url)[0] + extension(url)[1] %>"></meta>
|
||||||
<meta property="og:image:width" content="<%= width %>"></meta>
|
<meta property="og:image:width" content="<%= width %>"></meta>
|
||||||
<meta property="og:image:height" content="<%= height %>"></meta>
|
<meta property="og:image:height" content="<%= height %>"></meta>
|
||||||
<meta property="og:image:type" content="image/<%= extension(url)[1].split('.').join("") %>"></meta>
|
<meta property="og:image:type" content="image/<%= extension(url)[1].split('.').join("") %>"></meta>
|
||||||
<meta property="og:url" content="<%= host %>/uploads/<%= extension(url)[0] + extension(url)[1] %>"></meta>
|
<meta property="og:url" content="<%= host %>/uploads/<%= extension(url)[0] + extension(url)[1] %>"></meta>
|
||||||
<% } %>
|
<% } %>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
|
@ -79,7 +79,7 @@ return string.slice((string.lastIndexOf(".") - 2 >>> 0) + 2);
|
||||||
<% } else if (extension(file.path) == ".jpg" || extension(file.path) == ".jpeg" || extension(file.path) == ".png" || extension(file.path) == ".gif" || extension(file.path) == ".webp" ) { %>
|
<% } else if (extension(file.path) == ".jpg" || extension(file.path) == ".jpeg" || extension(file.path) == ".png" || extension(file.path) == ".gif" || extension(file.path) == ".webp" ) { %>
|
||||||
<img class="image" src="/uploads/<%=file.path %>" width="100%" onclick="copyURI(event)" loading="lazy">
|
<img class="image" src="/uploads/<%=file.path %>" width="100%" onclick="copyURI(event)" loading="lazy">
|
||||||
<% } else {%> <!-- non-media file -->
|
<% } else {%> <!-- non-media file -->
|
||||||
<div class="nonmedia" onclick="copyPath('<%=file.path%>')">
|
<div class="nonmedia" onclick="copyPath('/uploads/<%=file.path%>')">
|
||||||
<p><%=extension(file.path)%> file</p>
|
<p><%=extension(file.path)%> file</p>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
|
@ -1,4 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
node db.js
|
|
||||||
npm start
|
|
|
@ -1,22 +1,22 @@
|
||||||
FROM node:16-alpine AS BUILD_IMAGE
|
FROM node:16-alpine AS BUILD_IMAGE
|
||||||
|
|
||||||
RUN apk add curl bash
|
RUN apk add curl
|
||||||
|
RUN curl -sf https://gobinaries.com/tj/node-prune | sh
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
RUN npm prune --production
|
RUN npm prune --production
|
||||||
|
RUN /usr/local/bin/node-prune
|
||||||
RUN curl -sf https://gobinaries.com/tj/node-prune | sh
|
|
||||||
|
|
||||||
FROM node:16-alpine
|
FROM node:16-alpine
|
||||||
|
|
||||||
COPY --from=BUILD_IMAGE /node_modules ./node_modules
|
COPY --from=BUILD_IMAGE /node_modules ./node_modules
|
||||||
COPY . .
|
COPY /app ./app
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
RUN node db.js
|
RUN node /app/db.js
|
||||||
|
|
||||||
CMD ["npm", "start"]
|
CMD ["npm", "start"]
|
|
@ -21,14 +21,13 @@
|
||||||
},
|
},
|
||||||
"license": "Unlicense",
|
"license": "Unlicense",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./app.js"
|
"start": "node ./app/app.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
||||||
"@ffprobe-installer/ffprobe": "^1.4.1",
|
"@ffprobe-installer/ffprobe": "^1.4.1",
|
||||||
"connect-sqlite3": "^0.9.13",
|
"connect-sqlite3": "^0.9.13",
|
||||||
"cookie-parser": "~1.4.4",
|
"cookie-parser": "~1.4.4",
|
||||||
"cypress-real-events": "^1.7.4",
|
|
||||||
"dotenv": "^8.6.0",
|
"dotenv": "^8.6.0",
|
||||||
"ejs": "^3.1.8",
|
"ejs": "^3.1.8",
|
||||||
"express": "~4.16.1",
|
"express": "~4.16.1",
|
||||||
|
@ -45,6 +44,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cypress": "^11.1.0",
|
"cypress": "^11.1.0",
|
||||||
"cypress-file-upload": "^5.0.8",
|
"cypress-file-upload": "^5.0.8",
|
||||||
|
"cypress-real-events": "^1.7.4",
|
||||||
"eslint": "^8.28.0"
|
"eslint": "^8.28.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|