adding devops

used gemini to create the k8s/dockerfiles faster
This commit is contained in:
Smigz 2025-05-02 16:47:07 +00:00
parent 5c09c5a22f
commit 6c14a968c3
74 changed files with 2061 additions and 16 deletions

62
auth-expressjs/README.md Normal file
View file

@ -0,0 +1,62 @@
# Auth-ExpressJS Project
## Description
This project is a web application built with Express.js and Node.js, serving as an authentication server. It allows users to sign up and log in, managing user sessions and providing basic user authentication functionality.
## Prerequisites
- Node.js (v14 or later recommended)
- npm (usually comes with Node.js)
- PostgreSQL
## Installation
1. **Clone the repository:**
```
bash
git clone <repository-url>
cd auth-expressjs
```
2. **Install dependencies:**
```
bash
npm install
```
3. **Create database:**
Create a database in postgres
4. **Set up the database**
```
bash
psql -d <database-name> -f migrations/init.sql
```
## Running the Project
1. **Start the application:**
```
bash
npm start
```
This command starts the server, and you can access the application in your browser at `http://localhost:3000`.
- Make sure you change the db password and username in the app.js file
## Project Structure
- `src/`: Contains the main application code.
- `app.js`: The main application file where the Express.js server is set up.
- `views/`: Contains the EJS templates for the views.
- `migrations/`: Contains the sql file used to setup the database
- `package.json`: Lists the project dependencies and scripts.
- `package-lock.json`: Ensures consistent dependency versions across installations.
- `migrations`: database configuration files
## Usage
- **Sign Up:** Navigate to `http://localhost:3000/sign-up` to create a new account.
- **Log In:** Navigate to `http://localhost:3000/log-in` to log in with your credentials.
- **Home:** Navigate to `http://localhost:3000` to access the home page.

View file

@ -0,0 +1,20 @@
# Use an official Node.js runtime as the base image
FROM node:18-alpine
# Set the working directory in the container
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
# Install production dependencies
RUN npm install --omit=dev
# Copy the rest of the application code to the working directory
COPY . .
# Expose the port the app runs on
EXPOSE 3000
# Define the command to run the application
CMD [ "npm", "start" ]

View file

@ -0,0 +1,41 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: auth-expressjs-deployment
spec:
replicas: 3
selector:
matchLabels:
app: auth-expressjs
template:
metadata:
labels:
app: auth-expressjs
spec:
containers:
- name: auth-expressjs
image: auth-expressjs:latest # Replace with your image name and tag
ports:
- containerPort: 3000
env:
- name: NODE_ENV
value: production
volumeMounts:
- mountPath: /app/src/data
name: data
volumes:
- name: data
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: auth-expressjs-service
spec:
selector:
app: auth-expressjs
type: LoadBalancer
ports:
- protocol: TCP
port: 80
targetPort: 3000