Skip to content

Commit

Permalink
Merge pull request #21 from adamzv/hotfix/2.0.1
Browse files Browse the repository at this point in the history
Hotfixing frontend Docker configuration
  • Loading branch information
adamzv authored Nov 11, 2020
2 parents e341401 + 17c6cb9 commit 4bd56b6
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 7 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,35 @@ In the future ports will be changed to ensure proper communication between front
- [Kristián Kluka](https://github.com/kristiankluka) - backend, SW architect related tasks
- [Ľudovít Laca](https://github.com/Ludovit-Laca) - backend, DB design
- [Martin Gajdoš](https://github.com/martingajdos) - design, frontend

## Development setup

### Backend

1) Install Composer and XAMPP (php version 7.2)
2) Install required packages using Composer
```bash
composer install
```
3) Create .env file in /backend from .env.example and generate `APP_KEY` using
```bash
php artisan key:generate
```
4) Change `DB_HOST=mysql` in .env to your MySQL server IP

Optional: change DB name or username/password to your preferred values

5) Run `php artisan migrate:fresh --seed` to generate DB tables with data or `php artisan migrate` or `php artisan migrate --seed` to migrate tables and again run seeders

6) Run `php artisan passport:keys` to generate files and keys required for Laravel Passport

Notes:

`php artisan route:list` to show every route

### Frontend

1) Install Node.js and npm
2) Run `npm install` in project folder to install required dependencies
3) In frontend .env configuration change API endpoint `VUE_APP_BACKEND_URL=` to your local address (probably `http://localhost/TP1-project/backend/public/api`), also do not commit your changes in this file
4) Run `npm run serve` to start frontend in development mode on `localhost:8080`
13 changes: 6 additions & 7 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# build stage
FROM node:lts-alpine as build-stage
FROM node:latest as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
COPY ./ .
RUN npm run build

# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
FROM nginx as production-stage
RUN mkdir /app
COPY --from=build-stage /app/dist /app
COPY nginx.conf /etc/nginx/nginx.conf
30 changes: 30 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /app;
index index.html;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
5 changes: 5 additions & 0 deletions frontend/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Vue from "vue";
import Router from "vue-router";
import Home from "./views/Home.vue";
import ManageEvent from "./views/ManageEvent.vue";
import NotFound from "./views/NotFound.vue";

Vue.use(Router);

Expand All @@ -18,6 +19,10 @@ export default new Router({
path: "/pridat",
name: "addEvent",
component: ManageEvent
},
{
path: "*",
component: NotFound
}
]
});
20 changes: 20 additions & 0 deletions frontend/src/views/NotFound.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<section class="hero is-medium">
<div class="hero-body">
<div class="container has-text-centered">
<h1 class="title is-uppercase">Chyba 404: Stránka nenájdená</h1>
<b-button class="subtitle" tag="router-link" :to="{ path: '/' }" icon-left="redo-variant">Späť na úvod</b-button>
</div>
</div>
</section>
</template>

<script>
export default {
}
</script>

<style>
</style>

0 comments on commit 4bd56b6

Please sign in to comment.