mirror of
https://github.com/joaovitoriasilva/endurain.git
synced 2026-01-10 00:07:57 -05:00
Fixed some issues, added .env file
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,10 +1,8 @@
|
||||
# Python
|
||||
backend/__pycache__/
|
||||
backend/*/__pycache__/
|
||||
backend/*.pyc
|
||||
|
||||
# Logs
|
||||
backend/logs/
|
||||
backend/*.log
|
||||
|
||||
# Environment variables
|
||||
backend/config/.env
|
||||
backend/*.log
|
||||
@@ -17,7 +17,7 @@ RUN apt-get update
|
||||
EXPOSE 80
|
||||
|
||||
# Define environment variables
|
||||
ENV APACHE_DOCUMENT_ROOT /var/www/html/public
|
||||
ENV APACHE_DOCUMENT_ROOT /var/www/html
|
||||
|
||||
# Enable Apache modules
|
||||
RUN a2enmod rewrite
|
||||
|
||||
14
backend/config/.env
Normal file
14
backend/config/.env
Normal file
@@ -0,0 +1,14 @@
|
||||
# .env
|
||||
DB_HOST=mariadb
|
||||
DB_PORT=3306
|
||||
DB_USER=gearguardian
|
||||
DB_PASSWORD=changeme
|
||||
DB_DATABASE=gearguardian
|
||||
SECRET_KEY=changeme123!
|
||||
ALGORITHM=HS256
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES=30
|
||||
STRAVA_CLIENT_ID=changeme
|
||||
STRAVA_CLIENT_SECRET=changeme
|
||||
STRAVA_AUTH_CODE=changeme
|
||||
JAEGER_HOST=jaeger
|
||||
STRAVA_DAYS_ACTIVITIES_ONLINK=30
|
||||
@@ -1,46 +1,36 @@
|
||||
version: '3'
|
||||
services:
|
||||
gearguardian-frontend:
|
||||
image: gearguardian-frontend:latest
|
||||
# frontend logic
|
||||
frontend:
|
||||
container_name: frontend
|
||||
image: ghcr.io/joaovitoriasilva/gearguardian/frontend:dev_29112023
|
||||
environment:
|
||||
- APACHE_DOCUMENT_ROOT=/var/www/html
|
||||
volumes:
|
||||
- ./app:/app
|
||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf
|
||||
- /home/joaovitoriasilva/Documents/containers/gearguardian/frontend:/var/www/html
|
||||
ports:
|
||||
- "8080:80"
|
||||
networks:
|
||||
- frontend_network
|
||||
- backend_network
|
||||
restart: unless-stopped
|
||||
|
||||
|
||||
# API logic
|
||||
gearguardian-backend:
|
||||
container_name: gearguardian-backend
|
||||
image: gearguardian-backend:latest
|
||||
backend:
|
||||
container_name: backend
|
||||
image: ghcr.io/joaovitoriasilva/gearguardian/backend:dev_01122023
|
||||
environment:
|
||||
- DB_HOST=<change me> #required
|
||||
- DB_PORT=3306 #optional - will use port 3306 by default
|
||||
- DB_USER=<change me> #required
|
||||
- DB_PASSWORD=<change me> #required
|
||||
- DB_DATABASE=<change me> #required
|
||||
- SECRET_KEY=<change me> #required
|
||||
- ALGORITHM=HS256 #optional - will use HS256 by default
|
||||
- ACCESS_TOKEN_EXPIRE_MINUTES=30 #optional - will use 30 minutes by default
|
||||
- STRAVA_CLIENT_ID=<change me> #required
|
||||
- STRAVA_CLIENT_SECRET=<change me> #required
|
||||
- STRAVA_AUTH_CODE=<change me> #required
|
||||
- JAEGER_HOST=<change me> #required
|
||||
- STRAVA_DAYS_ACTIVITIES_ONLINK=30 #optional - will use 30 days by default
|
||||
- DB_PASSWORD=changeme
|
||||
- SECRET_KEY=changeme
|
||||
- STRAVA_CLIENT_ID=changeme
|
||||
- STRAVA_CLIENT_SECRET=changeme
|
||||
- STRAVA_AUTH_CODE=changeme
|
||||
ports:
|
||||
- "98:8000"
|
||||
- "98:80"
|
||||
volumes:
|
||||
- <host_path>/gearguardian-api:/app
|
||||
- /home/joaovitoriasilva/Documents/containers/gearguardian/backend:/app
|
||||
env_file:
|
||||
- ./app/config/.env # this will be removed. .env file will be moved to root folder
|
||||
- config/.env
|
||||
depends_on:
|
||||
- mariadb
|
||||
- otel-collector
|
||||
networks:
|
||||
- backend_network
|
||||
- jaeger
|
||||
restart: unless-stopped
|
||||
|
||||
# mysql mariadb logic
|
||||
@@ -48,30 +38,17 @@ services:
|
||||
image: mariadb:latest
|
||||
container_name: mariadb
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=<change me> #required
|
||||
- MYSQL_DATABASE=<change me> #required
|
||||
- MYSQL_USER=<change me> #required
|
||||
- MYSQL_PASSWORD=<change me> #required
|
||||
- MYSQL_ROOT_PASSWORD=123Testes@
|
||||
- MYSQL_DATABASE=gearguardian
|
||||
- MYSQL_USER=gearguardian
|
||||
- MYSQL_PASSWORD=123Testes@
|
||||
ports:
|
||||
- "3306:3306"
|
||||
volumes:
|
||||
- <host_path>/mariadb:/var/lib/mysql
|
||||
networks:
|
||||
- backend_network
|
||||
restart: unless-stopped
|
||||
|
||||
otel-collector:
|
||||
image: otel/opentelemetry-collector-contrib:latest
|
||||
container_name: otel-collector
|
||||
# Add any necessary configuration for the OpenTelemetry Collector here
|
||||
volumes:
|
||||
- <host_path>/otel-collector/otel-collector-config.yaml:/etc/otel-collector-config.yaml
|
||||
ports:
|
||||
- "4317:4317"
|
||||
networks:
|
||||
- backend_network
|
||||
- /home/joaovitoriasilva/Documents/containers/mariadb:/var/lib/mysql
|
||||
restart: unless-stopped
|
||||
|
||||
# Jaeger for opentelemetry
|
||||
jaeger:
|
||||
container_name: jaeger
|
||||
image: jaegertracing/all-in-one:latest
|
||||
@@ -91,12 +68,22 @@ services:
|
||||
- 14268:14268
|
||||
- 14269:14269
|
||||
- 9411:9411
|
||||
networks:
|
||||
- backend_network
|
||||
restart: unless-stopped
|
||||
|
||||
# phpmyadmin for DB manipulation
|
||||
phpmyadmin:
|
||||
container_name: phpmyadmin
|
||||
image: phpmyadmin
|
||||
ports:
|
||||
- 81:80
|
||||
environment:
|
||||
- PMA_HOST=mariadb
|
||||
- PMA_ARBITRARY=1
|
||||
depends_on:
|
||||
- mariadb
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
backend_network:
|
||||
driver: bridge
|
||||
frontend_network:
|
||||
driver: bridge
|
||||
default:
|
||||
external: true
|
||||
name: backend_network
|
||||
@@ -1,15 +1,21 @@
|
||||
<?php
|
||||
// Load the language file based on the user's preferred language
|
||||
switch ($_SESSION["preferred_language"]) {
|
||||
case 'en':
|
||||
$translationsTemplateTop = include $_SERVER['DOCUMENT_ROOT'].'/lang/inc/Template-Top/en.php';
|
||||
break;
|
||||
case 'pt':
|
||||
$translationsTemplateTop = include $_SERVER['DOCUMENT_ROOT'].'/lang/inc/Template-Top/pt.php';
|
||||
break;
|
||||
// ...
|
||||
default:
|
||||
$translationsTemplateTop = include $_SERVER['DOCUMENT_ROOT'].'/lang/inc/Template-Top/en.php';
|
||||
// Check if the "preferred_language" key is set in the session
|
||||
if (isset($_SESSION["preferred_language"])) {
|
||||
// Load the language file based on the user's preferred language
|
||||
switch ($_SESSION["preferred_language"]) {
|
||||
case 'en':
|
||||
$translationsTemplateTop = include $_SERVER['DOCUMENT_ROOT'].'/lang/inc/Template-Top/en.php';
|
||||
break;
|
||||
case 'pt':
|
||||
$translationsTemplateTop = include $_SERVER['DOCUMENT_ROOT'].'/lang/inc/Template-Top/pt.php';
|
||||
break;
|
||||
// ...
|
||||
default:
|
||||
$translationsTemplateTop = include $_SERVER['DOCUMENT_ROOT'].'/lang/inc/Template-Top/en.php';
|
||||
}
|
||||
} else {
|
||||
// Set a default language or handle the case when "preferred_language" is not set
|
||||
$translationsTemplateTop = include $_SERVER['DOCUMENT_ROOT'].'/lang/inc/Template-Top/en.php';
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
@@ -443,5 +443,4 @@
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
@@ -172,5 +172,4 @@
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
/* ************************************************************************** */
|
||||
/* Get to call a API route */
|
||||
function callAPIRoute($endpoint, $multipleReturns, $callType, $dataFields){
|
||||
$api_url = 'http://192.168.2.80:98';
|
||||
$api_url = 'http://127.0.1.1:98';
|
||||
$responseArray = [];
|
||||
|
||||
// Initialize a new cURL session
|
||||
@@ -77,6 +77,4 @@
|
||||
curl_close($ch);
|
||||
|
||||
return $responseArray;
|
||||
}
|
||||
?>
|
||||
|
||||
}
|
||||
@@ -34,18 +34,6 @@
|
||||
|
||||
/* Do a login */
|
||||
function loginUser($username, $password, $neverExpires){
|
||||
#$api_url = 'http://192.168.2.80:98';
|
||||
#$ch = curl_init();
|
||||
#curl_setopt($ch, CURLOPT_URL, $api_url . '/token');
|
||||
#curl_setopt($ch, CURLOPT_POST, 1);
|
||||
#curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
|
||||
# 'username' => $username,
|
||||
# 'password' => $password,
|
||||
# 'loginNeverExpires' => $neverExpires,
|
||||
#]));
|
||||
#curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
#$response = curl_exec($ch);
|
||||
#curl_close($ch);
|
||||
$response = callAPIRoute("/token", 0, 5, json_encode(array(
|
||||
'username' => $username,
|
||||
'password' => $password,
|
||||
@@ -107,5 +95,4 @@
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
@@ -32,7 +32,7 @@
|
||||
function linkStrava($state){
|
||||
// Example PHP code for the authentication link
|
||||
$client_id = '115321';
|
||||
$redirect_uri = urlencode('https://api-gearguardian.jvslab.pt/strava/strava-callback');
|
||||
$redirect_uri = urlencode('https://backend:98/strava/strava-callback');
|
||||
$scope = 'read,read_all,profile:read_all,activity:read,activity:read_all'; // Set your required scope
|
||||
|
||||
$strava_auth_url = "http://www.strava.com/oauth/authorize?client_id={$client_id}&response_type=code&redirect_uri={$redirect_uri}&approval_prompt=force&scope={$scope}&state={$state}";
|
||||
@@ -51,6 +51,4 @@
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
@@ -202,5 +202,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
@@ -17,5 +17,4 @@
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
@@ -5,5 +5,4 @@
|
||||
require_once $_SERVER['DOCUMENT_ROOT']."/inc/func/gear-funcs.php";
|
||||
require_once $_SERVER['DOCUMENT_ROOT']."/inc/func/activities-funcs.php";
|
||||
require_once $_SERVER['DOCUMENT_ROOT']."/inc/func/waypoints-funcs.php";
|
||||
require_once $_SERVER['DOCUMENT_ROOT']."/inc/func/strava-funcs.php";
|
||||
?>
|
||||
require_once $_SERVER['DOCUMENT_ROOT']."/inc/func/strava-funcs.php";
|
||||
@@ -53,11 +53,11 @@
|
||||
|
||||
<main class="form-signin w-100 m-auto text-center p-5" style="max-width: 500px">
|
||||
<!-- Info banners -->
|
||||
<?php if($_GET["sessionExpired"] == 1){ ?>
|
||||
<?php if(isset($_GET["sessionExpired"]) && $_GET["sessionExpired"] == 1){ ?>
|
||||
<div class="alert alert-warning alert-dismissible d-flex align-items-center" role="alert">
|
||||
<i class="fa-solid fa-triangle-exclamation me-1"></i>
|
||||
<div>
|
||||
<?php if($_GET["sessionExpired"] == 1){ ?>
|
||||
<?php if(isset($_GET["sessionExpired"]) && $_GET["sessionExpired"] == 1){ ?>
|
||||
<?php echo $translationsLogin['login_info_session expired']; ?>.
|
||||
<?php } ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
|
||||
Reference in New Issue
Block a user