From abad4ead8f2bc42bcc75da03932a9b42a3a0f0bf Mon Sep 17 00:00:00 2001 From: karastoyanov on vivobook Date: Sun, 29 Sep 2024 13:04:47 +0300 Subject: [PATCH] old dev build reworked --- .env_variables | 69 ------------------------------ .gitignore | 1 + Dockerfile.postgres | 5 --- Dockerfile.skill_forge | 36 ---------------- achievements.sql | 42 ------------------- docker-compose.yaml | 95 ------------------------------------------ init.sql | 10 ----- mongo-init.js | 12 ------ setup-postgres.sh | 17 -------- 9 files changed, 1 insertion(+), 286 deletions(-) delete mode 100644 .env_variables delete mode 100644 Dockerfile.postgres delete mode 100644 Dockerfile.skill_forge delete mode 100644 achievements.sql delete mode 100644 docker-compose.yaml delete mode 100644 init.sql delete mode 100644 mongo-init.js delete mode 100755 setup-postgres.sh diff --git a/.env_variables b/.env_variables deleted file mode 100644 index 0b2de7d0..00000000 --- a/.env_variables +++ /dev/null @@ -1,69 +0,0 @@ -# .env file -### README ### - -# DEVELOPER VERSION ONLY!!! - -# This file contains important static variables loaded in the application during execution. -# Do NOT modify this content unless you know what you are doing. - -# The variables are used to set up the application configurations. - -# VERSION: The version of the application -# SERVER_IP_ADDR: The IP address of the server -# DEBUG_PORT: The port number for debugging the application -# SECRET_KEY: The secret key for the application - -# Postgres Connection Dev Credentials -# DB_HOST: The host of the database -# DB_PORT: The port number of the database -# DB_NAME: The name of the database -# DB_USER: The username of the database -# DB_PASSWORD: The password of the database - - -# MongoDB Connection Credentials -# MONGO_USERNAME: The username of the MongoDB -# MONGO_PASSWORD: The password of the MongoDB -# MONGO_HOSTNAME: The hostname of the MongoDB -# MONGO_PRIMARY_PORT: The primary node port of the MongoDB -# MONGO_SECONDARY_PORT: The secondary node port of the MongoDB -# MONGO_SECONDARY_PORT_2: The secondary node port of the MongoDB -# MONGO_REPLICA_SET: The replica set of the MongoDB -# MONGO_AUTH_SOURCE: The authentication source of the MongoDB -# MONGO_DATABASE: The database of the MongoDB - -# Piston API URL - Piston API endpoint - -### EOF README ### - -# GENERAL CONFIGS -VERSION="0.0.1-dev" -SERVER_IP_ADDR=127.0.0.1 -DEBUG_PORT=5000 - -# APPLICATION SECRET KEY -SECRET_KEY = 'iG3pV7L6Xp9Qw2mZjxYdTn7GfR53t4wNpMsU8KhBcWd' - -# Postgres Connection Dev Credentials -DB_HOST=127.0.0.1 -DB_PORT=5432 -DB_NAME=skill_forge_dev -DB_USER=skill_forge -DB_PASSWORD=skill_forge -SQLALCHEMY_DATABASE_URI_DEV='postgresql://skill_forge:skill_forge@skillforge-postgres-dev:5432/skill_forge_dev' - - -# MongoDB Connection Credentials -MONGO_ADMIN_USERNAME = mongo_admin -MONGO_ADMIN_PASSWORD = mongo_admin - -MONGO_USERNAME=skill_forge -MONGO_PASSWORD=skill_forge -MONGO_HOSTNAME=mongo-dev -MONGO_PRIMARY_PORT="27017" -MONGO_AUTH_SOURCE=skill_forge_logs -MONGO_DATABASE=skill_forge_logs -MONGO_DATABASE_URI_DEV='mongodb://skill_forge:skill_forge@mongo-dev:27017/?authSource=skill_forge_logs&directConnection=true' - -# Piston API URL -PISTON_API_URL='http://piston-api:2000' diff --git a/.gitignore b/.gitignore index bebdbb61..b630b2be 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ basic_email.py # Ignore DOC.md DOC.md +/old-build/ \ No newline at end of file diff --git a/Dockerfile.postgres b/Dockerfile.postgres deleted file mode 100644 index 2f097724..00000000 --- a/Dockerfile.postgres +++ /dev/null @@ -1,5 +0,0 @@ -# Use the official Postgres 16 Alpine image as a base -FROM postgres:latest - -# Install pg_cron scheduler for Postgres -RUN apt update && apt install -y postgresql-16-cron \ No newline at end of file diff --git a/Dockerfile.skill_forge b/Dockerfile.skill_forge deleted file mode 100644 index 3a0c4004..00000000 --- a/Dockerfile.skill_forge +++ /dev/null @@ -1,36 +0,0 @@ -# Use the base image containing Python 3.8, NodeJS, npm, mono-complete compiler and java compiler -FROM python:latest - -# Image Labels. Update values for each build -LABEL Name="Skill-Forge" -LABEL Version="0.0.1" -LABEL Release="dev-stack-release" -LABEL ReleaseDate="" -LABEL Description="Skill Forge is a open-source platform for learning and practicing programming languages." -LABEL Maintainer="Aleksandar Karastoyanov " -LABEL License="GNU GPL v3.0 license" -LABEL GitHub SourceCode="https://github.com/SoftUni-Discord-Community/skill_forge" - -# Set default timezone -ENV TZ=Europe/Sofia -RUN ln -fs /usr/share/zoneinfo/$TZ /etc/localtime \ - && dpkg-reconfigure -f noninteractive tzdata - -# Set the working directory in the container -WORKDIR /app - -# Copy the current directory contents into the container at /app -COPY . /app - -# Copy the Python app requirements file into the container at /app -COPY ./requirements.txt /app/requirements.txt - -# Install the Python app requirements -RUN pip install --upgrade pip -RUN pip install -r requirements.txt --no-cache - -# Expose port 8000 -EXPOSE 8000 - -# Run the Python app -CMD ["gunicorn", "-k", "eventlet", "-w", "1", "-b", "0.0.0.0:8000", "wsgi:app"] diff --git a/achievements.sql b/achievements.sql deleted file mode 100644 index 6823eef9..00000000 --- a/achievements.sql +++ /dev/null @@ -1,42 +0,0 @@ --- achievements.sql - --- Create the achievements table -CREATE TABLE achievements ( - achievement_id VARCHAR(20) PRIMARY KEY, - achievement_name VARCHAR(50) NOT NULL, - achievement_description VARCHAR(255) NOT NULL, - achievement_picture VARCHAR(255) NOT NULL, - "language" VARCHAR(50) NOT NULL, - quests_number_required INTEGER NOT NULL -); - --- Create achivements table and insert some data -INSERT INTO achievements (achievement_id,achievement_name,achievement_description,achievement_picture,"language",quests_number_required) VALUES - ('ACH-JS-001','JavaScript Novice Mage','Solve 10 JavaScript Quests','JavaScript/javascript-1.png','JavaScript',10), - ('ACH-JS-002','JavaScript Adept Enchanter','Solve 20 JavaScript Quests','JavaScript/javascript-2.png','JavaScript',20), - ('ACH-JS-003','JavaScript Skilled Sorcerer','Solve 40 JavaScript Quests','JavaScript/javascript-3.png','JavaScript',40), - ('ACH-JS-004','JavaScript Master Wizard','Solve 60 JavaScript Quests','JavaScript/javascript-4.png','JavaScript',60), - ('ACH-JS-005','JavaScript Archmage','Solve 80 JavaScript Quests','JavaScript/javascript-5.png','JavaScript',80), - ('ACH-JS-006','JavaScript Legendary Hero','Solve 100 JavaScript Quests','JavaScript/javascript-6.png','JavaScript',100), - ('ACH-PY-001','Python Apprentice','Solve 10 Python Quests','Python/python-1.png','Python',10), - ('ACH-PY-002','Python Spellcaster','Solve 20 Python Quests','Python/python-2.png','Python',20), - ('ACH-PY-003','Python Rune Scribe','Solve 40 Python Quests','Python/python-3.png','Python',40), - ('ACH-PY-004','Python Arcane Adept','Solve 60 Python Quests','Python/python-4.png','Python',60); -INSERT INTO achievements (achievement_id,achievement_name,achievement_description,achievement_picture,"language",quests_number_required) VALUES - ('ACH-PY-005','Python Mystic Sage','Solve 80 Python Quests','Python/python-5.png','Python',80), - ('ACH-PY-006','Python High Sorcerer','Solve 100 Python Quests','Python/python-6.png','Python',100), - ('ACH-JV-001','Java Novice','Solve 10 Java Quests','Java/java-1.png','Java',10), - ('ACH-JV-002','Java Initiate','Solve 20 Java Quests','Java/java-2.png','Java',20), - ('ACH-JV-003','Java Enchanter','Solve 40 Java Quests','Java/java-3.png','Java',40), - ('ACH-JV-004','Java Conjurer','Solve 60 Java Quests','Java/java-4.png','Java',60), - ('ACH-JV-005','Java Sorcerer','Solve 80 Java Quests','Java/java-5.png','Java',80), - ('ACH-JV-006','Java Archmage','Solve 100 Java Quests','Java/java-6.png','Java',100), - ('ACH-CS-001','C# Apprentice','Solve 10 C# Quests','CS/cs-1.png','C#',10), - ('ACH-CS-002','C# Adept','Solve 20 C# Quests','CS/cs-1.png','C#',20); -INSERT INTO achievements (achievement_id,achievement_name,achievement_description,achievement_picture,"language",quests_number_required) VALUES - ('ACH-CS-003','C# Spellcaster','Solve 40 C# Quests','CS/cs-1.png','C#',40), - ('ACH-CS-004','C# Mystic','Solve 60 C# Quests','CS/cs-1.png','C#',60), - ('ACH-CS-005','C# Sorcerer','Solve 80 C# Quests','CS/cs-1.png','C#',80), - ('ACH-CS-006','C# Grand Enchanter','Solve 100 C# Quests','CS/cs-1.png','C#',100), - ('ACH-GEN-001','Skill Forge Contributor','Successfully Submited a Quest','General/quest_approved.png','General',1), - ('ACH-GEN-002','Early Bird','Thanks for joining us early!','General/early_bird.png','General',1); diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 8d61f2ee..00000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,95 +0,0 @@ -services: - - # Development PostgreSQL database instance - postgres-dev: - build: - context: . - dockerfile: ./Dockerfile.postgres - container_name: skillforge-postgres-dev - restart: always - environment: - - POSTGRES_USER=${DB_USER} - - POSTGRES_PASSWORD=${DB_PASSWORD} - - POSTGRES_DB=${DB_NAME} - - PGDATA=/var/lib/postgresql/data/pgdata - ports: - - '5432:5432' - volumes: - - postgres-dev:/var/lib/postgresql/data/pgdata - - ./achievements.sql:/docker-entrypoint-initdb.d/achievements.sql - - ./init.sql:/docker-entrypoint-initdb.d/init.sql - command: - - "postgres" - - "-c" - - "shared_preload_libraries=pg_cron" - - "-c" - - "cron.database_name=${DB_NAME}" - healthcheck: - test: ["CMD", "pg_isready", "-h", "localhost", "-p", "5432"] - interval: 10s - timeout: 5s - retries: 5 - networks: - - skillforge-net - - # MongoDB database replica cluster - mongo-dev: - image: mongo:4.4.18 - container_name: mongo-dev - ports: - - "27017:27017" - environment: - MONGO_INITDB_ROOT_USERNAME: ${MONGO_ADMIN_USERNAME} - MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ADMIN_PASSWORD} - volumes: - - mongo-dev:/data/db - - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js - networks: - - skillforge-net - - # Piston API instance - piston-api: - image: ghcr.io/engineer-man/piston@sha256:6500f2af69ce18fe16ca9a0ba7b0ea895366fc0efa46860c03d1d3c8a6cd270d - container_name: piston-api - ports: - - "2000:2000" - privileged: true - volumes: - - ../data/piston/packages:/piston/packages - tmpfs: - - /tmp:exec - networks: - - skillforge-net - - # Skill Forge application dev instance - skill-forge-dev: - build: - context: . - dockerfile: ./Dockerfile.skill_forge - container_name: skillforge-dev - restart: always - ports: - - '8000:8000' - volumes: - - skill-forge-dev:/app - depends_on: - - postgres-dev - - mongo-dev - - piston-api - networks: - - skillforge-net - - - -volumes: - postgres-dev: - driver: local - mongo-dev: - driver: local - skill-forge-dev: - driver: local - -networks: - skillforge-net: - driver: bridge - \ No newline at end of file diff --git a/init.sql b/init.sql deleted file mode 100644 index fead5cc1..00000000 --- a/init.sql +++ /dev/null @@ -1,10 +0,0 @@ --- init.sql - --- Run this as a superuser to create the pg_cron extension -CREATE EXTENSION IF NOT EXISTS pg_cron; - --- Optionally, grant usage to a regular user (replace 'skill_forge' with your username) -GRANT USAGE ON SCHEMA cron TO skill_forge; - --- Create a scheduled job that runs every minute and deletes old Reset Password Tokens -SELECT cron.schedule('* * * * *', $$DELETE FROM reset_tokens WHERE expiration_time < now()$$); \ No newline at end of file diff --git a/mongo-init.js b/mongo-init.js deleted file mode 100644 index a3141ccd..00000000 --- a/mongo-init.js +++ /dev/null @@ -1,12 +0,0 @@ -db = db.getSiblingDB('skill_forge_logs'); // Switch to the 'skill_forge_logs' database - -db.createUser({ - user: "skill_forge", - pwd: "skill_forge", // Password for the new user - roles: [ - { - role: "readWrite", // Assign readWrite role - db: "skill_forge_logs" // For the 'skill_forge_logs' database - } - ] -}); \ No newline at end of file diff --git a/setup-postgres.sh b/setup-postgres.sh deleted file mode 100755 index 58765300..00000000 --- a/setup-postgres.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - - -# This directory is created during the first run of PostgreSQL -if [ -f /var/lib/postgresql/data/pgdata/postgresql.conf ]; then - echo "Appending pg_cron settings to postgresql.conf" - - # Append pg_cron settings - echo "shared_preload_libraries = 'pg_cron'" >> /var/lib/postgresql/data/pgdata/postgresql.conf - echo "cron.database_name = 'skill_forge_dev'" >> /var/lib/postgresql/data/pgdata/postgresql.conf - - # Restart PostgreSQL to apply the changes - echo "Restarting PostgreSQL to apply changes..." - su - postgres -c "/usr/lib/postgresql/16/bin/pg_ctl -D /var/lib/postgresql/data/pgdata restart" -else - echo "postgresql.conf not found, skipping pg_cron configuration." -fi