Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add mobile V2 version #11

Merged
merged 62 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
d234cf1
feat: replace article to discover in nav bar
ArthurFrin Mar 19, 2024
504c3a8
feat: add filepond
ArthurFrin Mar 19, 2024
fb261f5
article list view
ArthurFrin Mar 21, 2024
d2b5025
fix avecflow article list
ArthurFrin Mar 22, 2024
a183cc9
feat: add association list
ArthurFrin Mar 25, 2024
3eeccf3
feat
ArthurFrin Mar 25, 2024
3a8faa0
feat: men design
ArthurFrin Mar 26, 2024
6845fde
feat: pofile
ArthurFrin Mar 28, 2024
d7413c2
feat/addView
ArthurFrin Apr 1, 2024
3204909
feat/new view cleanwalk
ArthurFrin Apr 1, 2024
ad99426
draft new cleanwalk
ArthurFrin Apr 2, 2024
997aa21
feat: get hour and date cleanwalk in creation cleanwalk
ArthurFrin Apr 2, 2024
0526724
coneect api
ArthurFrin Apr 10, 2024
8dc1286
feat/modif api
ArthurFrin Apr 12, 2024
82c6ae6
feat: add cleanwalk (draft)
ArthurFrin Apr 14, 2024
60e1f41
feat: add front create cleanwalk
ArthurFrin Apr 15, 2024
40ee399
create login (draft)
ArthurFrin Apr 15, 2024
21688d9
user creation works!
ArthurFrin Apr 15, 2024
3bc0877
feat: connection tocker works
ArthurFrin Apr 16, 2024
70194d9
feat: modif jwt_expire_time
ArthurFrin Apr 16, 2024
4e66924
feat: logout
ArthurFrin Apr 16, 2024
523afb5
feat: uplad img front (draft)
ArthurFrin Apr 21, 2024
08b8f55
feat: api uplad route user photo
ArthurFrin Apr 21, 2024
5887229
feat: upload img route works
ArthurFrin Apr 24, 2024
8e02feb
feat: upload component
ArthurFrin Apr 24, 2024
5942ffa
feat: Toast in UtilsStore
ArthurFrin Apr 27, 2024
6bffe7e
feat/dragDrop img in addCleanwalk vue
ArthurFrin Apr 28, 2024
3360608
feat: fetch cleanwalks (draft)
ArthurFrin Apr 28, 2024
1be0a3f
feat: conect cleanwalks in map
ArthurFrin Apr 29, 2024
4f4dd4e
Update cleanwalks.py
ArthurFrin Apr 29, 2024
7e14746
feat: add clanwalk (draft)
ArthurFrin May 1, 2024
9c53b60
add auto create city
ArthurFrin May 2, 2024
2cca3d5
feat: cleanwalk works
ArthurFrin May 3, 2024
cfbf6e8
feat: add CORS allowed in api
ArthurFrin May 3, 2024
c6e6d27
Merge branch 'feat/discover-view' of https://github.com/Cleanwalk-org…
ArthurFrin May 3, 2024
a8efb5d
feat: format adress from nominatim json
ArthurFrin May 3, 2024
6b9314e
feat: update cw model in api
ArthurFrin May 5, 2024
7351fe6
feat/retun img_url in response api route upload
ArthurFrin May 6, 2024
5da5902
feat: getCleanwalkById route
ArthurFrin May 9, 2024
48c391e
feat: join and leave cleanwalk
ArthurFrin May 11, 2024
dc9d6e6
feat: leave cleanwalk
ArthurFrin May 11, 2024
f2253a0
feat: modif user pp
ArthurFrin May 11, 2024
b231578
feat: profile picture in nav bar
ArthurFrin May 12, 2024
df1bb81
feat: add signup organisatiopn,
ArthurFrin May 12, 2024
825a2cf
feat: change password + reactive nb cw in home
ArthurFrin May 13, 2024
5980a9b
feat: profile asso
ArthurFrin May 14, 2024
44f5874
fix: docker composes and config flask (draft)
ArthurFrin Jul 22, 2024
11d493b
fix: docker uploads folder docker compose
ArthurFrin Jul 23, 2024
ff96830
fix: useless function and console.log
ArthurFrin Jul 23, 2024
f20cbe4
feat: change domain name
ArthurFrin Jul 23, 2024
fd6ae46
fix: domain front name
ArthurFrin Jul 23, 2024
fef85e7
fix: certbot + nginx conf
ArthurFrin Jul 23, 2024
6e6c102
docker compose
ArthurFrin Jul 23, 2024
4302ca3
feat: add nginx proxy manager in docker compose
ArthurFrin Jul 23, 2024
5a91f2b
fix: nginx proxy manager uploads folder
ArthurFrin Jul 23, 2024
4db60b1
feat: add profile picture in search top bar
ArthurFrin Jul 24, 2024
232f136
feat: add github action
ArthurFrin Jul 24, 2024
ac24b1b
feat: deploy in feat/discover-view
ArthurFrin Jul 25, 2024
29fe0b1
fix: deploy.yml
ArthurFrin Jul 25, 2024
9b9a986
fix: deploy.yml
ArthurFrin Jul 25, 2024
ec948d7
feat: update readme for nginx proxy manager config
ArthurFrin Jul 25, 2024
733f809
fix: deploy branche to release
ArthurFrin Jul 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Deploy to VPS

on:
push:
branches:
- release # Déclencher le déploiement uniquement sur la branche release

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SECRET_KEY }} # Utilisation de la clé SSH

- name: Deploy to VPS
env:
VPS_IP: ${{ secrets.VPS_IP }}
run: |
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$VPS_IP '
cd /home/cleanwalk-org-v2 &&
git pull origin release &&
docker compose -f docker-compose.prod.yml down &&
docker compose -f docker-compose.prod.yml up -d --build
'
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ lerna-debug.log*
*.njsproj
*.sln
*.sw?

/uploads

/data-nginx
/letsencrypt
47 changes: 45 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,49 @@ To shutdown all stack or just a specific one:
docker compose down
```

### Production
## Production

### config nginx proxy manager

**first login**: connect to @server_ip:81
- username: [email protected]
- password: changeme **! change admin info**

**proxy hosts**
Go to Hosts > Proxy Hosts and click on Add Proxy Host.

**frontend**
- Domain Names: yourdomain.example, www.yourdomain.example
- Scheme: http
- Forward Hostname / IP: frontend
- Forward Port: 80

**API**
- Domain Names: api.yourdomain.example
- Scheme: http
- Forward Hostname / IP: api
- Forward Port: 5000

**uploads**
- Domain Names : uploads.yourdomain.example
- Scheme : http
- Forward Hostname / IP : nginx-proxy-manager
- Forward Port : 81

in advanced add:
```
location / {
alias /var/www/uploads/;
autoindex on;
}
```

**SSL Config**
- check Force SSL
- select Request a new SSL certificate
- add email and save





Use Portainer for easier management. To install it, launch the script named "install-portainer.sh" and to access it you can check the service on port 9000.
4 changes: 3 additions & 1 deletion api/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DATABASE_URI=mysql+mysqlconnector://root:root@localhost:3306/cleanwalk_db
DATABASE_URI=mysql+pymysql://user:password@localhost/cleanwalk_db
API_KEY=1234567890
JWT_SECRET_KEY=098765433
UPLOAD_FOLDER=uploads
UPLOADS_URL=https://uploads.cleanwalk.org
23 changes: 0 additions & 23 deletions api/Dockerfile

This file was deleted.

20 changes: 20 additions & 0 deletions api/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Utilisez une image Python comme image de base
FROM python:3.8-alpine

# Définissez le répertoire de travail dans le conteneur
WORKDIR /app

# Copiez les fichiers de dépendances dans le conteneur
COPY requirements.txt .

# Installez les dépendances
RUN pip install --no-cache-dir -r requirements.txt

# Copiez le reste du code dans le conteneur
COPY . .

# Exposez le port sur lequel l'API s'exécute
EXPOSE 5000

# Démarrez l'API
CMD ["python3", "app.py"]
23 changes: 23 additions & 0 deletions api/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Utiliser une image Python comme image de base
FROM python:3.8-alpine

# Définir le répertoire de travail dans le conteneur
WORKDIR /app

# Copier les fichiers de dépendances dans le conteneur
COPY requirements.txt .

# Installer les dépendances
RUN pip install --no-cache-dir -r requirements.txt

# Copier le reste du code dans le conteneur
COPY . .

# Créer le dossier pour les uploads et définir les permissions
RUN mkdir -p /app/uploads && chmod -R 755 /app/uploads

# Exposer le port sur lequel l'API s'exécute
EXPOSE 5000

# Démarrer l'API avec Gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "wsgi:app"]
40 changes: 3 additions & 37 deletions api/app.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,7 @@
from flask import Flask
from flask_jwt_extended import JWTManager
from app.models import db
from dotenv import load_dotenv
import os
from datetime import timedelta

# load environement variables from .env file
load_dotenv()

ACCESS_EXPIRES = timedelta(minutes=1)

app = Flask(__name__)

#configure the SQLAlchemy database using environment variables
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URI')
app.config['API_KEY'] = os.getenv('API_KEY')
app.config['JWT_SECRET_KEY'] = os.getenv('JWT_SECRET_KEY')
app.config["JWT_ACCESS_TOKEN_EXPIRES"] = ACCESS_EXPIRES

#Init the JWTManager extension
jwt = JWTManager(app)

# Init the SQLAlchemy database
db.init_app(app)

from app.routes.users import users_bp
from app.routes.articles import articles_bp
from app.routes.cleanwalks import cleanwalks_bp
from app.routes.cities import cities_bp
from app.routes.admin import admin_bp

app.register_blueprint(users_bp , url_prefix='/users')
app.register_blueprint(articles_bp , url_prefix='/articles')
app.register_blueprint(cleanwalks_bp , url_prefix='/cleanwalks')
app.register_blueprint(cities_bp , url_prefix='/cities')
app.register_blueprint(admin_bp , url_prefix='/admin')
# app.py
from app import create_app

app = create_app()

if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)
46 changes: 46 additions & 0 deletions api/app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# app/__init__.py
from flask import Flask
from flask_jwt_extended import JWTManager
from flask_sqlalchemy import SQLAlchemy
from flask_cors import CORS
from dotenv import load_dotenv
import os
from datetime import timedelta

# Charger les variables d'environnement
load_dotenv()

# Initialiser l'extension SQLAlchemy
db = SQLAlchemy()

def create_app():
app = Flask(__name__)
CORS(app)
# Configurer l'application
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URI')
app.config['API_KEY'] = os.getenv('API_KEY')
app.config['JWT_SECRET_KEY'] = os.getenv('JWT_SECRET_KEY')
app.config["JWT_ACCESS_TOKEN_EXPIRES"] = timedelta(days=30)
app.config['UPLOAD_FOLDER'] = os.getenv('UPLOAD_FOLDER')
app.config['UPLOADS_URL'] = os.getenv('UPLOADS_URL')

# Initialiser les extensions
db.init_app(app)
JWTManager(app)

# Enregistrer les blueprints
from app.routes.users import users_bp
from app.routes.articles import articles_bp
from app.routes.cleanwalks import cleanwalks_bp
from app.routes.cities import cities_bp
from app.routes.admin import admin_bp
from app.routes.upload import upload_bp

app.register_blueprint(users_bp, url_prefix='/users')
app.register_blueprint(articles_bp, url_prefix='/articles')
app.register_blueprint(cleanwalks_bp, url_prefix='/cleanwalks')
app.register_blueprint(cities_bp, url_prefix='/cities')
app.register_blueprint(admin_bp, url_prefix='/admin')
app.register_blueprint(upload_bp, url_prefix='/upload')

return app
19 changes: 14 additions & 5 deletions api/app/models.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()
from app import db

class User(db.Model):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key=True)
firstname = db.Column(db.String(255), nullable=False)
lastname = db.Column(db.String(255), nullable=False)
name = db.Column(db.String(255), nullable=False)
email = db.Column(db.String(255), unique=True, index=True, nullable=False)
password = db.Column(db.String(255), nullable=False)
salt = db.Column(db.BINARY(16), nullable=True)
created_at = db.Column(db.TIMESTAMP, nullable=False)
profile_picture = db.Column(db.String(255), nullable=True)
role_id = db.Column(db.Integer, db.ForeignKey('roles.id'), nullable=False)

class Organisation(db.Model):
__tablename__ = 'organisations'
user_id = db.Column(db.Integer, db.ForeignKey('users.id'), primary_key=True)
description = db.Column(db.String(255), nullable=True)
web_site = db.Column(db.String(255), nullable=True)
social_media = db.Column(db.JSON, nullable=True)
banner_img = db.Column(db.String(255), nullable=True)

# Relation vers User
user = db.relationship('User', backref=db.backref('organisation', uselist=False))

class Cleanwalk(db.Model):
__tablename__ = 'cleanwalks'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255), nullable=False)
pos_lat = db.Column(db.Float, nullable=False)
pos_long = db.Column(db.Float, nullable=False)
date_begin = db.Column(db.TIMESTAMP, nullable=False)
img_url = db.Column(db.String(255), nullable=True)
duration = db.Column(db.Integer, nullable=False)
description = db.Column(db.String(255), nullable = False)
address = db.Column(db.String(255), nullable=False)
Expand Down
2 changes: 2 additions & 0 deletions api/app/routes/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

@admin_bp.before_request
def check_api_key():
if request.method == 'OPTIONS': # Handle preflight requests to enable CORS
return
api_key = request.headers.get('X-API-Key') # Get the api key from the header

# Verify the api key
Expand Down
2 changes: 2 additions & 0 deletions api/app/routes/articles.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

@articles_bp.before_request
def check_api_key():
if request.method == 'OPTIONS': # Handle preflight requests to enable CORS
return
api_key = request.headers.get('X-API-Key') # Get the api key from the header

# Verify the api key
Expand Down
2 changes: 2 additions & 0 deletions api/app/routes/cities.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

@cities_bp.before_request
def check_api_key():
if request.method == 'OPTIONS': # Handle preflight requests to enable CORS
return
api_key = request.headers.get('X-API-Key') # Get the api key from the header

# Verify the api key
Expand Down
Loading