diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..1bcf75a3f65b57725abe3ff844a2c3869cab61f5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +docker-compose.yml +Dockerfile +.gitignore +README.md +.drone.yml \ No newline at end of file diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000000000000000000000000000000000000..2382b0ce0679c5c376429abf157e5acb2ca33c27 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,119 @@ +kind: pipeline +type: docker +name: deploy + +clone: + disable: true + +steps: +- name: notif build start + image: appleboy/drone-discord + settings: + webhook_id: + from_secret: discord_webhook_id + webhook_token: + from_secret: discord_webhook_token + username: "Drone Princelle (ERP: student)" + avatar_url: https://s3.princelle.org/share/drone-ci.png + message: > + 🚀 Starting deployment of **{{ repo.name }}** repo (*ERP*)... + + + **Commit from {{commit.author}} on {{commit.branch}}:** + + {{commit.message}} + + {{ build.link }} + + +- name: pull + image: appleboy/drone-ssh + settings: + host: flash.princelle.org + username: mprincelle + port: 22 + key: + from_secret: ci_key + script: + - cd /app/uni/erp/student + - git fetch --all + - git reset --hard origin/main + - git checkout {{commit.branch}} + - git pull + +- name: configure + image: appleboy/drone-ssh + settings: + host: flash.princelle.org + username: mprincelle + port: 22 + key: + from_secret: ci_key + script: + - cd /app/uni/erp/student + - echo -e "DB_PORT=2005" > .env + - echo -e "SERVER_PORT=2003" >> .env + +- name: build + image: appleboy/drone-ssh + settings: + host: flash.princelle.org + username: mprincelle + port: 22 + key: + from_secret: ci_key + script: + - cd /app/uni/erp/student + - docker-compose up -d --build + + +- name: notif deploy done + image: appleboy/drone-discord + settings: + webhook_id: + from_secret: discord_webhook_id + webhook_token: + from_secret: discord_webhook_token + username: "Drone Princelle (ERP: student)" + avatar_url: https://s3.princelle.org/share/drone-ci.png + message: > + ✅ Successfully deployed **{{ repo.name }}** repo (*ERP*) on Princelle Cloud! + + + **Commit from {{commit.author}} on {{commit.branch}}:** + + {{commit.message}} + + **APP URL:** https://student.erp.uni.princelle.org/ + + {{ build.link }} + when: + status: + - success + +- name: notif deploy failure + image: appleboy/drone-discord + settings: + webhook_id: + from_secret: discord_webhook_id + webhook_token: + from_secret: discord_webhook_token + username: "Drone Princelle (ERP: student)" + avatar_url: https://s3.princelle.org/share/drone-ci.png + message: > + âš ï¸ Error on deploying **{{ repo.name }}** repo (*ERP*) on Princelle Cloud... + + + **Commit from {{commit.author}} on {{commit.branch}}:** + + {{commit.message}} + + {{ build.link }} + when: + status: + - failure + + +trigger: + branch: + - main diff --git a/.env.model b/.env.model new file mode 100644 index 0000000000000000000000000000000000000000..a8472f79e22024ca4d64f04087b14b1962a6f8cd --- /dev/null +++ b/.env.model @@ -0,0 +1,2 @@ +SERVER_PORT=27017 +APP_PORT=8005 \ No newline at end of file diff --git a/.gitignore b/.gitignore index aba02a1184a2ab6ad2eeb5643516ef6a7351b0d0..8ea5b1e335694ebd1ab4f3ec896a08598b9bcc2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .idea/ +.env \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 4b9aa12c411aa9c4dd41212efa0fcee488703a18..c234c8cd2d882bdd7d43d74f7fcc4af16d5f2fe8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,19 +2,26 @@ version: '3' services: mongodb: image: mongo + container_name: "student_db" + volumes: + - student_db_data:/data/db ports: - - "27017:27017" + - "${DB_PORT:-27017}:27017" server: build: . depends_on: - "mongodb" command: "npm run start:prod" + container_name: "student_app" ports: - - "8005:8005" + - "${SERVER_PORT:-8005}:8005" environment: - CHOKIDAR_USEPOLLING=true - CI=true - NODE_ENV=production - PORT=8005 - MONGO_NAME=mongodb + +volumes: + student_db_data: \ No newline at end of file diff --git a/frontend/public/.htaccess b/frontend/public/.htaccess new file mode 100644 index 0000000000000000000000000000000000000000..22480dad4299b3f33a84cf1e75ed6972bf078a77 --- /dev/null +++ b/frontend/public/.htaccess @@ -0,0 +1,9 @@ +<IfModule mod_rewrite.c> + RewriteEngine On + RewriteBase / + RewriteRule ^index\.html$ - [L] + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-l + RewriteRule . /index.html [L] +</IfModule> diff --git a/frontend/src/App.js b/frontend/src/App.js index 3c8cc126148fe47f08be28ded8acba7f33c42209..af5053d7fbaac53a3fe29d6aea34448c35a26c8c 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import './App.css'; import {connect} from 'react-redux'; -import {BrowserRouter as Router, Route, Link, Redirect} from "react-router-dom"; +import {BrowserRouter, Route, Switch , Link, Redirect} from "react-router-dom"; import SignUp from './containers/SignUp.container'; import Login from './containers/Login.container'; import Privacy from './containers/Privacy.container' @@ -20,6 +20,7 @@ const PrivateRoute = ({ component: Component, ...rest }) => ( )} /> ) + class App extends Component { // constructor(props) { // super(props); @@ -32,7 +33,8 @@ class App extends Component { render() { return ( - <Router> + <> + <BrowserRouter> <div> <Navbar bg="dark" expand="lg" variant="dark"> <Navbar.Brand>STUDENT</Navbar.Brand> @@ -96,14 +98,16 @@ class App extends Component { </Modal.Footer> </Modal> } - + </div> + <Switch> <PrivateRoute path="/" exact component={Profile} /> <Route path="/login" exact component={Login} /> <Route path="/signup/" component={SignUp} /> <Route path="/privacy/" component={Privacy} /> <PrivateRoute path="/bank/" component={Bank} /> - </div> - </Router> + </Switch> + </BrowserRouter> + </> ); } }