Commit 47b4cb8e authored by Johan Tanderup Degn's avatar Johan Tanderup Degn
Browse files

Merge branch 'develop' into 'master'

Release of Prototype

See merge request !29
parents 29811153 4a18f3d1
Pipeline #55394 passed with stage
in 39 seconds
.DS_Store
\ No newline at end of file
.DS_Store
.vscode
\ No newline at end of file
stages:
- test
- create-vue-build
- build-docker-server-container
- build-docker-web-container
test:
stage: test
image: node
script:
- cd website/studerende-dk
- echo "Starting Linter"
- npm install
- npm run lint
- echo "Linter Done!"
create-vue-build:
only:
- develop
stage: create-vue-build
image: node
script:
- cd website/studerende-dk
- echo "Start building App"
- npm install
- npm run build
- echo "Build successfully!"
artifacts:
expire_in: 1 hour
paths:
- website/studerende-dk/dist
cache:
paths:
- website/studerende-dk/node_modules/
build-docker-server-container:
only:
- develop
stage: build-docker-server-container
image: docker:latest
services:
- name: docker:19.03.8-dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- cd backend
- echo "Starting docker build of server."
- docker build . -t "$CI_REGISTRY_IMAGE""/server"
- docker push "$CI_REGISTRY_IMAGE""/server"
- echo "Docker build of server done!"
build-docker-web-container:
only:
- develop
stage: build-docker-web-container
image: docker:latest
services:
- name: docker:19.03.8-dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- cd website/studerende-dk
- echo "Starting docker build of web."
- docker build . -t "$CI_REGISTRY_IMAGE""/web"
- docker push "$CI_REGISTRY_IMAGE""/web"
- echo "Docker build of web done!"
FROM python:3.8
COPY server/* .
ENV PYTHONUNBUFFERED=1
EXPOSE 1337
CMD ["python", "server.py"]
\ No newline at end of file
# Inspired by https://pythonbasics.org/webserver/
from http.server import BaseHTTPRequestHandler, HTTPServer
import time
hostName = '0.0.0.0'
serverPort = 1337
db = {
'katrine-marie' : '[{"height":400,"blocks":[{"type":"Calendar","width":75},{"type":"ActiveCourses","width":25}]},{"height":250,"blocks":[{"type":"Deadlines","width":100}]},{"height":300,"blocks":[{"type":"Feed","width":50},{"type":"Mail","width":25},{"type":"Mail","width":25}]}]',
'isaac' : '[{"height":400,"blocks":[{"type":"Calendar","width":75},{"type":"ActiveCourses","width":25}]},{"height":250,"blocks":[{"type":"Deadlines","width":100}]},{"height":300,"blocks":[{"type":"Feed","width":50},{"type":"Mail","width":25},{"type":"Mail","width":25}]}]'
}
class MyServer(BaseHTTPRequestHandler):
def _set_ok_headers(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
def _set_err_headers(self):
self.send_response(500)
self.send_header('Content-type', 'text/html')
self.end_headers()
def handle_load_layout(self, id):
if id in db:
self._set_ok_headers()
self.wfile.write(bytes(db[id], 'utf-8'))
else:
self._set_err_headers()
self.wfile.write(bytes('Error: Could not find id ' + str(id), 'utf-8'))
def handle_save_layout(self, id, data):
db[id] = data.replace('%22', '"')
self._set_ok_headers()
def do_GET(self):
# remove '/?' from path
query = self.path[2:]
fields = dict(f.split("=") for f in query.split("&"))
if fields['type'] == "load":
self.handle_load_layout(fields['id'])
elif fields['type'] == "save":
self.handle_save_layout(fields['id'], fields['data'])
else:
self._set_err_headers()
self.wfile.write(bytes('Request type not supported', 'utf-8'))
if __name__ == '__main__':
webServer = HTTPServer((hostName, serverPort), MyServer)
print('Server started http://%s:%s' % (hostName, serverPort))
try:
webServer.serve_forever()
except KeyboardInterrupt:
pass
webServer.server_close()
print('Server stopped.')
\ No newline at end of file
# From https://docs.docker.com/compose/
version: "3.9"
services:
web:
build: website/studerende-dk/
ports:
- "80:80"
server:
build: backend/
ports:
- "1337:1337"
\ No newline at end of file
{
"name": "hold-afstand",
"lockfileVersion": 2,
"requires": true,
"packages": {}
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Issac Euler Jensen</h1>
<div id="content">
<div id="left">
<div id="top">
<img src="Isaac.png" style="object-position: 100% 100%;"/>
<span id="quote">"I have three deadlines for next week."</span>
<p id="small-desc">Isaac Euler Jensen is a first year student at Aarhus University studying maths. He likes to keep on top of his homework, which he has a lot of. Isaac has come to Aarhus University straight from high school, and he wants to pursue a career in the academic world.</p>
</div>
<div id="bot">
<p id="big-desc">Isaac Euler Jensen's education revolves around handing in several academic papers each week. He has strict deadlines for each of his courses which results in him needing to be able to access these deadlines easily. He also has several exercise classes each week for each of his courses. For these hand-ins and exercise classes he uses a lot of different mathematical literature. He spends a lot of time with this literature both preparing for exercise classes and lectures.
For him the most important aspect of a platform for education is easy access to deadlines and course content. He does not care too much about a calendar displaying his weekly schedule for example, as it is the same every week. He does not need any collaboration tools, as he hands in individually in all courses. So if he could design the perfect platform for education, it would just be a platform with seamless access to deadlines and course content. Nothing more.</p>
</div>
</div>
<div id="right">
<strong>Goals</strong>
<ul>
<li>Have a career in the academic world,</li>
<li>Stay at the top of the class,</li>
<li>Learn and understand math at a higher level.</li>
</ul>
<strong>Tasks</strong>
<ul>
<li>Read current week's literature,</li>
<li>Prepare for upcoming exercise classes,</li>
<li>Complete and deliver many assignments per week.</li>
</ul>
<strong>Roles</strong>
<ul>
<li>Top student.</li>
</ul>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Kathrine-Marie Strange</h1>
<div id="content">
<div id="left">
<div id="top">
<img src="Kathrine-Marie.png"/>
<span id="quote">"I'm excited for my traineeship at the local medical facility next month."</span>
<p id="small-desc">Kathrine-Marie Strange is a fifth year medicine student with a high interest in her education. She tries to get as much real world experience practicing medicine to prepare her for career after the education.</p>
</div>
<div id="bot">
<p id="big-desc">Kathrine-Marie's weekdays are very busy with her difficult education, but she also wants free time for personal activities. It is therefore important to Kathrine-Marie that she can have a great overview of her weekly university schedule.
Her studies does not involve hand-ins or assignments, so she rather wants to have a feed of the most recent changes to her courses and upcoming exams. She often experiences changes in both location and times throughout the week and a quick overview would be greatly valued by Kathrine-Marie.
On the perfect platform of education for her you would be able to see the recent changes in the courses and a large schedule of the week. She needs this to coordinate her time and notice important changes. She would also appreciate not having too much information on her front-page, and letting her focus on practical learning would increase her likability of her front-page.</p>
</div>
</div>
<div id="right">
<strong>Goals</strong>
<ul>
<li>Get real world experience in a clinic to prepare for a career as general practitioner,</li>
<li>Keep a structured schedule in her everyday life to make time for activities besides her studies.</li>
</ul>
<strong>Tasks</strong>
<ul>
<li>Find and read literature for the courses,</li>
<li>Attend lectures and exercise classes when she's not at the clinic,</li>
<li>Work in the clinic utilizing her knowledge.</li>
</ul>
<strong>Roles</strong>
<ul>
<li>Student,</li>
<li>Friend,</li>
<li>Trainee.</li>
</ul>
</div>
</div>
</body>
</html>
\ No newline at end of file
html, body {
width: 100%;
height: 100%;
font-family: Arial, Helvetica, sans-serif;
}
* {
box-sizing: border-box;
}
body {
padding: 20px;
background: #ecf5f7;
}
p {
margin: 0;
padding: 0;
}
#content {
display: flex;
width: 100%;
}
#left, #right {
flex-basis: 300px;
}
#left {
flex-grow: 5;
display: flex;
flex-direction: column;
margin-right: 10px;
}
#right {
flex-grow: 2;
margin-left: 10px;
}
#top, #bot {
border: 2px solid lightgray;
background: linear-gradient(#C4DFE6, #ecf5f7);
padding: 10px;
}
#top {
margin-bottom: 20px;
}
#quote {
font-style: italic;
font-weight: 900;
display: block;
margin-bottom: 5px;
}
img {
float: left;
width: 300px;
height: 300px;
object-fit: cover;
object-position: 0 0;
margin-right: 20px;
}
\ No newline at end of file
#!/bin/bash
# this script pulls the docker images and
# deploys them respectively if they are
# newer than the ones running.
# this script can be run at any time,
# and will only change the running
# containers if newer ones are available.
function deploy {
local url=$1
local service_name=$2
local run_arguments=$3
old_digest=$(docker inspect -f '{{.RepoDigests}}' ${url}:active | grep -o 'sha256:[0-9A-Fa-f]*')
# probably no existing image
if [ $? -ne 0 ]; then
echo "No existing image! Abort."
exit 1;
fi
new_digest=$(docker pull ${url}:latest | grep Digest | sed 's/Digest: //')
# network error or authentication might go wrong
if [ $? -ne 0 ]; then
echo "Auth or network err! Abort."
exit 2;
fi
# sanity check that new digest is formatted correctly and is same length as old.
# if it aint, it could be the result of a gitlab server error or such.
local check=$(echo $new_digest | grep -o 'sha256:[0-9A-Fa-f]*')
if [ "${#check}" -eq "0" ] || [ ${#old_digest} -ne 71 ]; then
echo "Damnit, something went bad! Crash and burn.."
exit 3;
fi
echo "Old digest: $old_digest"
echo "New digest: $new_digest"
if [ "$old_digest" != "$new_digest" ]; then
echo "Deploying new docker instance: $service_name."
docker stop $service_name
docker rm $service_name
docker rmi ${url}:active
docker tag ${url}:latest ${url}:active
docker run --network persist-net $run_arguments --name $service_name -d ${url}:active
result=0
else
echo "Already up to date."
fi
# remove/untag file. silence output
docker rmi ${url}:latest >/dev/null 2>&1
}
base_url="registry.gitlab.au.dk/exsys2021/da6/hold-afstand/"
# deploy new server if available
result=1
deploy ${base_url}server "server" "--network-alias server"
server_deployed=$result
echo
# deploy new web if available
result=1
deploy ${base_url}web "web" "-p 80:80"
web_deployed=$result
# if anything has been deployed, notify the devs
if [ $server_deployed -eq 0 ] || [ $web_deployed -eq 0 ]; then
[ $server_deployed -eq 0 ] && msg="backend"
[ $web_deployed -eq 0 ] && [ $server_deployed -eq 0 ] && msg=${msg}" and "
[ $web_deployed -eq 0 ] && msg=${msg}"frontend"
slack_msg="A new version of the ${msg} has been deployed! Check it out: https://vm34.exsys2021.cs.au.dk/"
echo $slack_msg
# notify slack channel
/home/auuser/slack-notifier.sh $slack_msg
fi
echo "Done."
#!/bin/bash
# ----- CAUTION!!! -----
# This script stops and removes the running web and server
# containers, removes their images and the persist-net
# docker network.
#
# It then reconfigures the network, download
# the images and redeploys them again.
base_url="registry.gitlab.au.dk/exsys2021/da6/hold-afstand/"
# stops docker containers
echo -n "Stopping containers..."
docker stop server >/dev/null 2>&1
docker stop web >/dev/null 2>&1
echo " Done."
# removes docker containers
echo -n "Removing containers..."
docker rm server >/dev/null 2>&1
docker rm web >/dev/null 2>&1
echo " Done."
# removes docker images
echo -n "Removing images..."
docker rmi ${base_url}server:active >/dev/null 2>&1
docker rmi ${base_url}web:active >/dev/null 2>&1
echo " Done."
# removes unused docker networks
echo -n "Removing docker network..."
docker network rm persist-net >/dev/null 2>&1
echo " Done."
# pulling the images
echo -n "Pulling latest sever image..."
docker pull ${base_url}server:latest >/dev/null 2>&1
echo " Done."
echo -n "Pulling latest web image..."
docker pull ${base_url}web:latest >/dev/null 2>&1
echo " Done."
# changes tags from latest to active
echo -n "Tagging..."
docker tag ${base_url}server:latest ${base_url}server:active >/dev/null 2>&1
docker tag ${base_url}web:latest ${base_url}web:active >/dev/null 2>&1
docker rmi ${base_url}server:latest >/dev/null 2>&1
docker rmi ${base_url}web:latest >/dev/null 2>&1
echo " Done."
# crates network
echo -n "Creates docker network..."
docker network create -d bridge persist-net --attachable >/dev/null 2>&1
echo " Done."
# spins up containers
echo -n "Spinning up containers..."
docker run --network persist-net --network-alias server --name server -d ${base_url}server:active >/dev/null 2>&1
docker run --network persist-net -p 80:80 --name web -d ${base_url}web:active >/dev/null 2>&1
echo " Done."
echo "All done!"
#!/bin/bash
# INFO: This script should be placed in auuser 's homefolder!
# sanity check
if [ "$#" == "0" ]; then
echo "The message should be passed as an argument!"
exit 1
fi
data='{"text":"'"$@"'"}'
url=$(head -n 1 slack-url)
curl -X POST -H 'Content-type: application/json' --data "$data" $url
> 1%
last 2 versions
not dead
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended'
],
parserOptions: {
parser: 'babel-eslint'
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
}
}
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
FROM nginx:latest
COPY ./dist /usr/share/nginx/html
COPY nginx-conf/ /etc/nginx/conf.d/
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment