FEAT: Docker for backend is working, just need to use docker compose to create a working application.

This commit is contained in:
Hayden Hargreaves 2025-03-05 18:19:08 -07:00
parent 4cbc846990
commit da2aea70ac
2 changed files with 35 additions and 5 deletions

31
backend/Dockerfile Normal file
View File

@ -0,0 +1,31 @@
# Use a Node.js base image
FROM node:18-alpine
# Set the working directory in the container
WORKDIR /app
# Copy package.json and package-lock.json (or yarn.lock)
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the backend code
COPY . .
# Expose the port your Express app runs on (internally only)
EXPOSE 5000
# Build the application
RUN npm run build
# Start the application
CMD ["npm", "run", "start"]
# BUILD COMMAND, from the ./backend directory
# docker build -t azpect3120/file.gophernest.backend:latest .
# RUN COMMAND, from the ./backend directory
# The directory only matters because of the .env file
# docker run -p 5000:5000 --env-file .env -v /home/azpect:/home/azpect azpect3120/file.gophernest.backend:latest

View File

@ -8,9 +8,8 @@ import cors from "cors";
import archiver from "archiver"; import archiver from "archiver";
import {appendDirectoryToArchive, appendFileToArchive} from "./download"; import {appendDirectoryToArchive, appendFileToArchive} from "./download";
import path from "node:path"; import path from "node:path";
import jwt from "jsonwebtoken";
import {config} from "dotenv";
import {verifyToken} from "./authenicate"; import {verifyToken} from "./authenicate";
import jwt from "jsonwebtoken";
/** /**
* App details * App details
@ -23,10 +22,10 @@ const ROOT: string = "/home/azpect";
* Configure the .env file, this is for testing only * Configure the .env file, this is for testing only
* TODO: Remove this * TODO: Remove this
*/ */
config({path: ".env"}); // config({path: ".env"});
/** /**
* Invalid file extentions for the file editor. * Invalid file extensions for the file editor.
*/ */
const INVALID_EXTS: string[] = ["exe", "dll", "obj", "lib", "bin", "dat", "pdf", "jpg", "jpeg", "png", "gif", "webm", "webp", "bmp", "mp3", "wav", "mp4", "avi", "zip", "rar", "7z", "iso", "dmg", "class", "pyc", "o", "a", "woff", "woff2", "ttf", "otf", "db", "sqlite", "mdb", "accdb", "psd", "ai", "indd", "blend", "fbx", "unitypackage", "pak", "sav", "msi", ".doc", ".docx", ".dot", ".dotx", ".docm", ".dotm", ".rtf", ".txt", ".xls", ".xlsx", ".xlsm", ".xltx", ".xltm", ".csv", ".ppt", ".pptx", ".pptm", ".potx", ".potm", ".ppsx", ".ppsm", ".mdb", ".accdb", ".accde", ".accdt", ".pst", ".ost", ".msg", ".one", ".onetoc2", ".pub", ".vsd", ".vsdx", ".vssx", ".vstx", ".odc", ".oft", ".pki"]; const INVALID_EXTS: string[] = ["exe", "dll", "obj", "lib", "bin", "dat", "pdf", "jpg", "jpeg", "png", "gif", "webm", "webp", "bmp", "mp3", "wav", "mp4", "avi", "zip", "rar", "7z", "iso", "dmg", "class", "pyc", "o", "a", "woff", "woff2", "ttf", "otf", "db", "sqlite", "mdb", "accdb", "psd", "ai", "indd", "blend", "fbx", "unitypackage", "pak", "sav", "msi", ".doc", ".docx", ".dot", ".dotx", ".docm", ".dotm", ".rtf", ".txt", ".xls", ".xlsx", ".xlsm", ".xltx", ".xltm", ".csv", ".ppt", ".pptx", ".pptm", ".potx", ".potm", ".ppsx", ".ppsm", ".mdb", ".accdb", ".accde", ".accdt", ".pst", ".ost", ".msg", ".one", ".onetoc2", ".pub", ".vsd", ".vsdx", ".vssx", ".vstx", ".odc", ".oft", ".pki"];
@ -36,7 +35,7 @@ const INVALID_EXTS: string[] = ["exe", "dll", "obj", "lib", "bin", "dat", "pdf",
*/ */
const corsOptions: cors.CorsOptions = { const corsOptions: cors.CorsOptions = {
origin: ["http://localhost:3100"], origin: ["http://localhost:3100"],
methods: ["GET"] methods: ["GET", "POST"]
}; };
APP.use(cors(corsOptions)); APP.use(cors(corsOptions));