Merge branch 'ep/Nov5/PostgresAndGardenMigration' into 'master'
Prepared for Garden See merge request Dunemask/nubian!2
This commit is contained in:
commit
23b1033085
12 changed files with 28 additions and 63 deletions
|
@ -1 +1,2 @@
|
|||
src/uploads/
|
||||
uploads/
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -9,3 +9,5 @@ src/uploads/
|
|||
.env
|
||||
.env.dev
|
||||
.env.prod
|
||||
newsrc/
|
||||
uploads/
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
FROM node:latest
|
||||
RUN apt-get update && apt-get upgrade -y
|
||||
WORKDIR /dunestorm/nubian
|
||||
FROM node:16
|
||||
WORKDIR /dunemask/net/nubian
|
||||
COPY package.json .
|
||||
RUN npm i --only=prod
|
||||
RUN npm i
|
||||
COPY src src
|
||||
CMD ["npm","start"]
|
||||
EXPOSE 52001
|
||||
|
|
14
dist/predeploy-vanilla.sh
vendored
14
dist/predeploy-vanilla.sh
vendored
|
@ -1,14 +0,0 @@
|
|||
#!/bin/bash
|
||||
echo "Creating vanilla predeploy!"
|
||||
# Set path correclty
|
||||
if [[ $PWD == *"dist" ]];
|
||||
then cd ..
|
||||
fi
|
||||
# If .env exists, ignore it
|
||||
if [[ ! -f ".env" ]];then
|
||||
echo "Building vanilla env file!"
|
||||
echo "KHUFU_UPLOAD_PATH=/srv/uploads">> .env
|
||||
fi
|
||||
# Install node dependencies
|
||||
echo "Installing node depencencies!"
|
||||
npm i
|
|
@ -1,18 +0,0 @@
|
|||
version: "3"
|
||||
services:
|
||||
nubian.dunestorm.net:
|
||||
image: nubian.dunestorm.net
|
||||
build: .
|
||||
ports:
|
||||
- "52001:52001"
|
||||
environment:
|
||||
- ALEXANDRIA_INTERNAL_URL=${ALEXANDRIA_INTERNAL_URL}
|
||||
- ALEXANDRIA_DATABASE_PASSWORD=${ALEXANDRIA_DATABASE_PASSWORD}
|
||||
- CAIRO_PUBLIC_URL=${CAIRO_PUBLIC_URL}
|
||||
env_file:
|
||||
- .env
|
||||
networks:
|
||||
- dunestorm_dev
|
||||
networks:
|
||||
dunestorm_dev:
|
||||
external: true
|
26
package.json
26
package.json
|
@ -5,9 +5,7 @@
|
|||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"start": "node src/index.js --no-warnings",
|
||||
"start:dev": "nodemon src/index.js",
|
||||
"build": "npm run build:all",
|
||||
"build:all": "docker-compose build"
|
||||
"start:dev": "nodemon src/index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -22,26 +20,20 @@
|
|||
"dependencies": {
|
||||
"axios": "^0.21.1",
|
||||
"body-parser": "^1.19.0",
|
||||
"chalk": "^4.1.2",
|
||||
"express": "^4.17.1",
|
||||
"express-bearer-token": "^2.4.0",
|
||||
"figlet": "^1.5.2",
|
||||
"moment": "^2.29.1",
|
||||
"mongoose": "^5.13.3",
|
||||
"multer": "^1.4.2",
|
||||
"multer-gridfs-storage": "^5.0.2",
|
||||
"path": "^0.12.7",
|
||||
"pg-promise": "^10.11.1",
|
||||
"postgres-migrations": "^5.3.0",
|
||||
"rimraf": "^3.0.2"
|
||||
},
|
||||
"nodemonConfig": {
|
||||
"restartable": "rs",
|
||||
"ignore": [
|
||||
".git",
|
||||
"./src/uploads/",
|
||||
"./src/zips/"
|
||||
],
|
||||
"verbose": true,
|
||||
"ext": "js,json",
|
||||
"signal": "SIGINT",
|
||||
"env": {
|
||||
"CAIRO_URL": "http://localhost:52000",
|
||||
"KHUFU_UPLOAD_PATH": "uploads/"
|
||||
}
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.14"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,12 +9,12 @@ const {
|
|||
const config = require("../config.json");
|
||||
const mongoose = require("mongoose");
|
||||
mongoose.connect(
|
||||
`mongodb://${process.env.ALEXANDRIA_INTERNAL_URL}/nubian?authSource=admin`,
|
||||
`mongodb://${process.env.NUBIAN_MONGO_HOST}/nubian?authSource=admin`,
|
||||
{
|
||||
useUnifiedTopology: true,
|
||||
useNewUrlParser: true,
|
||||
user: "admin",
|
||||
pass: process.env.ALEXANDRIA_DATABASE_PASSWORD,
|
||||
user: process.env.NUBIAN_MONGO_USERNAME,
|
||||
pass: process.env.NUBIAN_MONGO_PASSWORD,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -25,9 +25,8 @@ const userUpload = multer({
|
|||
|
||||
//Helper Methods
|
||||
function userUploadDestination(user_id) {
|
||||
if (!fs.existsSync(resolvePath(process.env.KHUFU_UPLOAD_PATH)))
|
||||
fs.mkdirSync(resolvePath(process.env.KHUFU_UPLOAD_PATH));
|
||||
const destination = resolvePath(process.env.KHUFU_UPLOAD_PATH, `${user_id}`);
|
||||
if (!fs.existsSync("uploads")) fs.mkdirSync("uploads");
|
||||
const destination = resolvePath(`uploads/${user_id}`);
|
||||
if (!fs.existsSync(destination)) fs.mkdirSync(destination);
|
||||
return destination;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,8 @@ const timeout = 10 * 60 * 1000; // 10 minutes
|
|||
app.use(bearerToken());
|
||||
app.use(bodyParser.json({ limit: Server.BodyLimit }));
|
||||
app.use(bodyParser.urlencoded({ limit: Server.BodyLimit, extended: false }));
|
||||
app.use(["/nubian/api/stash", "/api/stash", "/stash"], stashRouter);
|
||||
app.use(require("./routes/vitals-router"));
|
||||
app.use("/api/stash", stashRouter);
|
||||
const startServer = () => {
|
||||
var server = app.listen(port, () => {
|
||||
console.log("Node version:" + process.versions.node);
|
||||
|
|
|
@ -13,7 +13,7 @@ const cairoMiddleware = (req, res, next) => {
|
|||
if (req.token == null) return next();
|
||||
else
|
||||
axios
|
||||
.get(`${process.env.CAIRO_PUBLIC_URL}/user/data`, {
|
||||
.get(`${process.env.CAIRO_URL}/api/user/info`, {
|
||||
headers: { authorization: `Bearer ${req.token}` },
|
||||
})
|
||||
.then((authRes) => {
|
||||
|
|
4
src/routes/vitals-router.js
Normal file
4
src/routes/vitals-router.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
const router = require("express").Router();
|
||||
router.get("/healthcheck", (req, res) => res.sendStatus(200));
|
||||
router.get("/alive", (req, res) => res.sendStatus(200));
|
||||
module.exports = router;
|
|
@ -8,7 +8,7 @@ const file = new Schema(
|
|||
type: String,
|
||||
required: true,
|
||||
},
|
||||
owner: { type: ObjId, ref: "user" },
|
||||
owner: { type: String},
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
|
|
Reference in a new issue