Skip to content
Snippets Groups Projects
Commit 4abf0258 authored by Simen Vevik's avatar Simen Vevik
Browse files

merge fix part2

parent a53d79b8
No related branches found
No related tags found
No related merge requests found
# NTNU Beta - Web Page # NTNU Beta - Web Page
This is a web application created to present NTNU Betas projects/services. Users associated with NTNU can access This is a web application created to present NTNU Betas projects/services. Users associated with NTNU can access
the application through feide. the application by logging in with FEIDE.
A secondary registration option is implemented to allow external users to access this site. It requires an administrator A secondary registration option is implemented to allow external users to access this site. It requires an administrator
to approve the request. to approve the request.
As an administrator one can also create, edit and delete projects/services, as well as manage tickers. As an administrator one can also create, edit and delete projects/services, as well as manage tickers.
Everyone with access to the page can share concerns and issues they may have with features in the projects. Everyone with access to the page can share concerns and issues they may have with features in the projects.
These tickers are available to all users, but can only be resolved by administrators. These tickers are available to all users, but can only be resolved by administrators.
## Getting Started ## Getting Started
This application runs entirely on Docker. All the application processes are running in cleanly separated docker containers.
### Prerequisites ### Prerequisites
The only prerequisite for running this is a working docker installation. Both docker and docker-compose are required. Follow the instructions from the official documentation:
To set up the web application, you need the following 1. Docker
- [Node.js and npm](https://nodejs.org/en/)
- A MySQL database
By downloading and installing NodeJS you automatically install npm - Docker Desktop for Mac: https://docs.docker.com/docker-for-mac/install/
- Docker Desktop for Windows: https://docs.docker.com/docker-for-windows/
- Docker for Linux:
On desktop systems like Docker Desktop for Mac and Windows, Docker Compose is included as part of those desktop installs.
2. Docker Compose
### Installation https://docs.docker.com/compose/install/
1. Clone the project
git clone https://gitlab.stud.idi.ntnu.no/olahop/beta-web.git ⚠️ Warning: do not attempt to simply run apt-get install docker docker-compose on older Ubuntu platforms, such as 16.04 (Xenial), as you will get older versions of these utilities.
2. Navigate to the beta-web folder: ### Installation
cd PATH_TO_PROJECT_FOLDER/beta-web/
3. Run the following command to install frontend dependencies: 1. Clone the project
npm install ``git clone https://gitlab.stud.idi.ntnu.no/simenve/ntnu-beta-web.git``
2. Navigate to the ntnu-beta-web folder:
4. Navigate to the server folder: ``cd PATH_TO_PROJECT_FOLDER/ntnu-beta-web/``
cd server 3. Run the following command to build and start the services:
5. Then run the following command to install backend dependencies: ``docker-compose build && docker compose up``
npm install 4) Visit the application on http://localhost:3000
### Configuration ### Configuration
1. Https credentials 1. Https credentials
- Set your private key and certificate in `server.js` or preferably add the files to `server/config/` - Set your private key and certificate in `server.js` or preferably add the files to `server/config/`
2. Database configuration 2. Database configuration
If you wish to use another database than the one that ships with the application you can change the database credentials:
- Set your db credentials in `server/config/default.json` - Set your db credentials in `server/config/default.json`
3. Json Web Token secret 3. Json Web Token secret
- Set your jwt secret in `server/config/default.json` - Set your jwt secret in `server/config/default.json`
4. Third party SAML identification (Feide) 4. Third party SAML identification (Feide)
- We are using the npm package [passport-saml](https://www.npmjs.com/package/passport-saml) to handle XML requests and responses - We are using the npm package [passport-saml](https://www.npmjs.com/package/passport-saml) to handle XML requests and responses
- Set the metadata for your identity provider in `server/config/default.json` - Set the metadata for your identity provider in `server/config/default.json`
- Provide your metadata (entityID, SSO and SLO) to your SAML IDP - Provide your metadata (entityID, SSO and SLO) to your SAML IDP
- Update `SSO_redirect` and `SLO_redirect` in `server/config/default.json` to `https://<DOMAIN>/` and `https://<DOMAIN>:3000/login` - Update `SSO_redirect` and `SLO_redirect` in `server/config/default.json` to `https://<DOMAIN>/` and `https://<DOMAIN>:3000/login`
5. Update routes to the backend API calls 5. Update routes to the backend API calls
- We've used a proxy during development that routes every call from frontend to backend to `localhost:5000/...` - We've used a proxy during development that routes every call from frontend to backend to `localhost:5000/...`
- These backend API calls from the frontend needs to be updated manually before production - These backend API calls from the frontend needs to be updated manually before production
6. Create adminuser 6. Create adminuser
- The first adminuser has to be added manually to the database - The first adminuser has to be added manually to the database
### Run development servers ### Run development servers
1. Run the backend 1. Run the backend
- `npm run server` from beta-web/server - `npm run server` from beta-web/server
2. Run the frontend 2. Run the frontend
- `npm start` from beta-web/
- `npm start` from beta-web/
### Roadmap ### Roadmap
### Stage 1: Build ###
# Use a lighter version of Node as a parent image # Use a lighter version of Node as a parent image
# FROM mhart/alpine-node:8.11.4 # FROM mhart/alpine-node:8.11.4
FROM node:10 FROM node:10 as build
RUN mkdir /usr/src/app
# Set the working directory to /client # Set the working directory to /client
WORKDIR /client WORKDIR /usr/src/app
# copy package.json into the container at /client # copy package.json into the container at /client
COPY package*.json /client/ COPY package*.json /usr/src/app/
# install dependencies # install dependencies
RUN npm install RUN npm install
# Copy the current directory contents into the container at /client # Copy the current directory contents into the container at /client
COPY . /client/ COPY . /usr/src/app/
# Make port 3000 available to the world outside this container
EXPOSE 3000
# Run the app when the container launches # Run the app when the container launches
CMD ["npm", "start"] RUN npm run-script build
\ No newline at end of file
### Stage 2: Production env ###
FROM httpd:2.4
COPY --from=build /usr/src/app/build /usr/local/apache2/htdocs/
EXPOSE 80
CMD apachectl -D FOREGROUND
\ No newline at end of file
{ {
"homepage": "http://beta.it.ntnu.no/",
"name": "beta-web", "name": "beta-web",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
......
version: "2" version: "3"
services: services:
## Added mysql database and mounted to volume in data folder and gave it a silly name ##
db-mysql:
container_name: data-tzar-andreas
image: mysql:8.0
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: test_db
MYSQL_USER: devuser
MYSQL_PASSWORD: devpass
restart: always
volumes:
- ./data/mysql:/var/lib/mysql
networks:
- webappnetwork
ports:
- "3306:3306"
#Opens a port on the container for external database software (not recommended, tho)
expose:
- "3306"
## Adminer for database ui access ##
adminer:
container_name: beta-web-mysqladmin
image: adminer
restart: always
ports:
- "8080:8080"
networks:
- webappnetwork
links:
- db-mysql
client: client:
container_name: beta-web-client
image: webapp-client image: webapp-client
build: ./client build: ./client
restart: always restart: always
...@@ -11,8 +46,12 @@ services: ...@@ -11,8 +46,12 @@ services:
- /client/node_modules - /client/node_modules
links: links:
- server - server
depends_on:
- server
networks: [webappnetwork] networks: [webappnetwork]
server: server:
container_name: beta-web-server
image: webapp-server image: webapp-server
build: ./server build: ./server
restart: always restart: always
...@@ -22,6 +61,14 @@ services: ...@@ -22,6 +61,14 @@ services:
- ./server:/server - ./server:/server
- /server/node_modules - /server/node_modules
networks: [webappnetwork] networks: [webappnetwork]
depends_on:
- db-mysql
links:
- db-mysql
networks: networks:
webappnetwork: webappnetwork:
driver: bridge driver: bridge
volumes:
data:
...@@ -10,6 +10,6 @@ RUN npm install ...@@ -10,6 +10,6 @@ RUN npm install
# Copy the current directory contents into the container at /server # Copy the current directory contents into the container at /server
COPY . /server/ COPY . /server/
# Make port 80 available to the world outside this container # Make port 80 available to the world outside this container
EXPOSE 80 EXPOSE 5000
# Run the app when the container launches # Run the app when the container launches
CMD ["npm", "start"] CMD ["npm", "start"]
\ No newline at end of file
...@@ -4,12 +4,18 @@ ...@@ -4,12 +4,18 @@
"PORT": 5000, "PORT": 5000,
"session": "secret" "session": "secret"
}, },
"db": { "db-remote": {
"host": "remotemysql.com", "host": "remotemysql.com",
"user": "FVNTxSUOfg", "user": "FVNTxSUOfg",
"password": "Pizt8ntDPi", "password": "Pizt8ntDPi",
"database": "FVNTxSUOfg" "database": "FVNTxSUOfg"
}, },
"db": {
"host": "db-mysql",
"user": "devuser",
"password": "devpass",
"database": "test_db"
},
"passport": { "passport": {
"path": "/login/callback", "path": "/login/callback",
"entryPoint": "https://idp-test.feide.no/simplesaml/saml2/idp/SSOService.php", "entryPoint": "https://idp-test.feide.no/simplesaml/saml2/idp/SSOService.php",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment