mirror of
https://github.com/rjNemo/villafleurie
synced 2026-06-12 13:26:47 +00:00
NginX docker
This commit is contained in:
parent
6e4348521e
commit
a8b1f2035e
10 changed files with 69 additions and 166 deletions
|
|
@ -1,16 +0,0 @@
|
||||||
version: 2
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
machine: true
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
|
|
||||||
- run: |
|
|
||||||
docker-compose up
|
|
||||||
|
|
||||||
- run: |
|
|
||||||
docker login --username=$HEROKU_USERNAME --password=$HEROKU_API_KEY registry.heroku.com
|
|
||||||
docker tag villafleurie registry.heroku.com/$HEROKU_APP_NAME/web
|
|
||||||
docker push registry.heroku.com/$HEROKU_APP_NAME/web
|
|
||||||
curl https://cli-assets.heroku.com/install.sh | sh
|
|
||||||
heroku container:release web -a $HEROKU_APP_NAME
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -8,5 +8,5 @@ villafleurie/staticfiles/
|
||||||
.vscode/
|
.vscode/
|
||||||
rental/client_secrets.json
|
rental/client_secrets.json
|
||||||
token.pickle
|
token.pickle
|
||||||
prod.env
|
*.env
|
||||||
*.tar
|
*.tar
|
||||||
|
|
@ -103,9 +103,7 @@ Le visiteur doit pouvoir :
|
||||||
- Envoyer devis réservation par mail et notification aux hôtes (put it in a background process, personnaliser les htmails : contact, admin et réservation)
|
- Envoyer devis réservation par mail et notification aux hôtes (put it in a background process, personnaliser les htmails : contact, admin et réservation)
|
||||||
- Ajout page/module de paiement
|
- Ajout page/module de paiement
|
||||||
- ajouter les témoignages depuis Booking, AirBnb, ajouter le lien
|
- ajouter les témoignages depuis Booking, AirBnb, ajouter le lien
|
||||||
- changer la couleur des liens hypertextes
|
|
||||||
- changer l'adresse de l'admin, personnaliser le back-end (design et les infos displayed per model)
|
- changer l'adresse de l'admin, personnaliser le back-end (design et les infos displayed per model)
|
||||||
- ajouter un diaporama en bas de page de location ?
|
|
||||||
- factoriser le code de réservation
|
- factoriser le code de réservation
|
||||||
- formulaire de réservation : les apparts sont hard codés rendre ça dynamique (use choicefields)
|
- formulaire de réservation : les apparts sont hard codés rendre ça dynamique (use choicefields)
|
||||||
\_ nettoyer les statics files. Garder que les définitions utiles
|
\_ nettoyer les statics files. Garder que les définitions utiles
|
||||||
|
|
@ -118,6 +116,8 @@ Le visiteur doit pouvoir :
|
||||||
- Internationalisation
|
- Internationalisation
|
||||||
- Connect to domain name
|
- Connect to domain name
|
||||||
- Système de facturation: CRUD Réservations et envoi. Automatisation si possible
|
- Système de facturation: CRUD Réservations et envoi. Automatisation si possible
|
||||||
|
- Réservation page : Ajouter des photos. Renvoyer vers la page Location onClick sur Réserver TX. Proposer Upsells : navette + location voiture.
|
||||||
|
- Vider le contenu du folder root ?
|
||||||
|
|
||||||
## BUGS
|
## BUGS
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,31 @@
|
||||||
version: "3"
|
version: "3"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
static_files:
|
||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres
|
image: postgres
|
||||||
|
|
||||||
web:
|
web:
|
||||||
build: .
|
build: .
|
||||||
# command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py loaddata villafleurie.json && python manage.py runserver 0.0.0.0:8000"
|
command: bash -c "python manage.py migrate && python manage.py loaddata villafleurie.json && gunicorn -w 4 villafleurie.wsgi -b 0.0.0.0:8000"
|
||||||
command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py loaddata villafleurie.json && gunicorn -w 4 villafleurie.wsgi -b 0.0.0.0:8000"
|
|
||||||
# command: gunicorn villafleurie.wsgi -b 0.0.0.0:8000 # Production server more secure
|
|
||||||
container_name: villafleurie
|
container_name: villafleurie
|
||||||
volumes:
|
volumes:
|
||||||
- .:/villafleurie
|
- .:/villafleurie
|
||||||
|
- static_files:/static_files
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
env_file: prod.env
|
env_file: prod.env
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
# image: nginx
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: nginx/Dockerfile
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
volumes:
|
||||||
|
- static_files:/static_files
|
||||||
|
|
|
||||||
5
nginx/Dockerfile
Normal file
5
nginx/Dockerfile
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
FROM nginx
|
||||||
|
|
||||||
|
RUN rm /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
COPY nginx/villafleurie.conf /etc/nginx/conf.d/
|
||||||
16
nginx/villafleurie.conf
Normal file
16
nginx/villafleurie.conf
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
access_log /var/log/nginx/example.log;
|
||||||
|
|
||||||
|
location static/ {
|
||||||
|
autoindex off;
|
||||||
|
alias /static_files/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:8000;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -81,7 +81,10 @@ def synchronize_calendars(place):
|
||||||
|
|
||||||
place = get_object_or_404(Place, name=place.name)
|
place = get_object_or_404(Place, name=place.name)
|
||||||
price = get_reservation_price(
|
price = get_reservation_price(
|
||||||
place, reservation['start'], reservation['end'])
|
place,
|
||||||
|
reservation['start'],
|
||||||
|
reservation['end']
|
||||||
|
)
|
||||||
start = reservation['start']
|
start = reservation['start']
|
||||||
end = reservation['end']
|
end = reservation['end']
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,118 +0,0 @@
|
||||||
jQuery(document).ready(function($) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
//Contact
|
|
||||||
$('form.contactForm').submit(function() {
|
|
||||||
var f = $(this).find('.form-group'),
|
|
||||||
ferror = false,
|
|
||||||
emailExp = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i;
|
|
||||||
|
|
||||||
f.children('input').each(function() { // run all inputs
|
|
||||||
|
|
||||||
var i = $(this); // current input
|
|
||||||
var rule = i.attr('data-rule');
|
|
||||||
|
|
||||||
if (rule !== undefined) {
|
|
||||||
var ierror = false; // error flag for current input
|
|
||||||
var pos = rule.indexOf(':', 0);
|
|
||||||
if (pos >= 0) {
|
|
||||||
var exp = rule.substr(pos + 1, rule.length);
|
|
||||||
rule = rule.substr(0, pos);
|
|
||||||
} else {
|
|
||||||
rule = rule.substr(pos + 1, rule.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (rule) {
|
|
||||||
case 'required':
|
|
||||||
if (i.val() === '') {
|
|
||||||
ferror = ierror = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'minlen':
|
|
||||||
if (i.val().length < parseInt(exp)) {
|
|
||||||
ferror = ierror = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'email':
|
|
||||||
if (!emailExp.test(i.val())) {
|
|
||||||
ferror = ierror = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'checked':
|
|
||||||
if (! i.is(':checked')) {
|
|
||||||
ferror = ierror = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'regexp':
|
|
||||||
exp = new RegExp(exp);
|
|
||||||
if (!exp.test(i.val())) {
|
|
||||||
ferror = ierror = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i.next('.validation').html((ierror ? (i.attr('data-msg') !== undefined ? i.attr('data-msg') : 'wrong Input') : '')).show('blind');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
f.children('textarea').each(function() { // run all inputs
|
|
||||||
|
|
||||||
var i = $(this); // current input
|
|
||||||
var rule = i.attr('data-rule');
|
|
||||||
|
|
||||||
if (rule !== undefined) {
|
|
||||||
var ierror = false; // error flag for current input
|
|
||||||
var pos = rule.indexOf(':', 0);
|
|
||||||
if (pos >= 0) {
|
|
||||||
var exp = rule.substr(pos + 1, rule.length);
|
|
||||||
rule = rule.substr(0, pos);
|
|
||||||
} else {
|
|
||||||
rule = rule.substr(pos + 1, rule.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (rule) {
|
|
||||||
case 'required':
|
|
||||||
if (i.val() === '') {
|
|
||||||
ferror = ierror = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'minlen':
|
|
||||||
if (i.val().length < parseInt(exp)) {
|
|
||||||
ferror = ierror = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i.next('.validation').html((ierror ? (i.attr('data-msg') != undefined ? i.attr('data-msg') : 'wrong Input') : '')).show('blind');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (ferror) return false;
|
|
||||||
else var str = $(this).serialize();
|
|
||||||
var action = $(this).attr('action');
|
|
||||||
if( ! action ) {
|
|
||||||
action = 'contactform/contactform.php';
|
|
||||||
}
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: action,
|
|
||||||
data: str,
|
|
||||||
success: function(msg) {
|
|
||||||
// alert(msg);
|
|
||||||
if (msg == 'OK') {
|
|
||||||
$("#sendmessage").addClass("show");
|
|
||||||
$("#errormessage").removeClass("show");
|
|
||||||
$('.contactForm').find("input, textarea").val("");
|
|
||||||
} else {
|
|
||||||
$("#sendmessage").removeClass("show");
|
|
||||||
$("#errormessage").addClass("show");
|
|
||||||
$('#errormessage').html(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
@ -214,7 +214,6 @@
|
||||||
<script src="{% static 'rental/lib/easing/easing.min.js' %}"></script>
|
<script src="{% static 'rental/lib/easing/easing.min.js' %}"></script>
|
||||||
<script src="{% static 'rental/lib/owlcarousel/owl.carousel.min.js' %}"></script>
|
<script src="{% static 'rental/lib/owlcarousel/owl.carousel.min.js' %}"></script>
|
||||||
<script src="{% static 'rental/lib/scrollreveal/scrollreveal.min.js' %}"></script>
|
<script src="{% static 'rental/lib/scrollreveal/scrollreveal.min.js' %}"></script>
|
||||||
<script src="{% static 'rental/contactform/contactform.js' %}"></script>
|
|
||||||
<script src="{% static 'rental/js/main.js' %}"></script>
|
<script src="{% static 'rental/js/main.js' %}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
# import dj_database_url
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||||
|
|
@ -9,15 +8,10 @@ ADMINS = [
|
||||||
]
|
]
|
||||||
|
|
||||||
SECRET_KEY = os.environ.get('SECRET_KEY')
|
SECRET_KEY = os.environ.get('SECRET_KEY')
|
||||||
# SECRET_KEY = 'q00_4wqdc^n=7)p2lm)!gy&fms8md_b4#1aqysllvqq==2c9!$'
|
|
||||||
|
|
||||||
if os.environ.get('ENV') == 'PRODUCTION':
|
if os.environ.get('ENV') == 'PRODUCTION':
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
# STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
# STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||||
# Heroku
|
|
||||||
# db_from_env = dj_database_url.config(conn_max_age=500)
|
|
||||||
# DATABASES['default'].update(db_from_env)
|
|
||||||
# Docker
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql',
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
|
|
@ -28,16 +22,19 @@ if os.environ.get('ENV') == 'PRODUCTION':
|
||||||
'ATOMIC_REQUESTS': True
|
'ATOMIC_REQUESTS': True
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
|
# PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
|
||||||
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
|
# STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
|
||||||
STATIC_TMP = os.path.join(PROJECT_ROOT, 'static')
|
# STATIC_TMP = os.path.join(PROJECT_ROOT, 'static')
|
||||||
# Extra places for collectstatic to find static files.
|
# # Extra places for collectstatic to find static files.
|
||||||
STATICFILES_DIRS = (os.path.join(PROJECT_ROOT, 'static'),)
|
# STATICFILES_DIRS = (os.path.join(PROJECT_ROOT, 'static'),)
|
||||||
os.makedirs(STATIC_TMP, exist_ok=True)
|
# os.makedirs(STATIC_TMP, exist_ok=True)
|
||||||
os.makedirs(STATIC_ROOT, exist_ok=True)
|
# os.makedirs(STATIC_ROOT, exist_ok=True)
|
||||||
|
STATIC_ROOT = "/static_files/"
|
||||||
CSRF_COOKIE_SECURE = True
|
CSRF_COOKIE_SECURE = True
|
||||||
SESSION_COOKIE_SECURE = True
|
SESSION_COOKIE_SECURE = True
|
||||||
CONN_MAX_AGE = 500
|
CONN_MAX_AGE = 500
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
|
|
@ -55,17 +52,22 @@ else:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
STATICFILES_DIRS = [os.path.join(BASE_DIR, "rental", "static", "rental"), ]
|
STATICFILES_DIRS = [os.path.join(BASE_DIR, "rental", "static", "rental"), ]
|
||||||
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
|
# PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
|
||||||
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
|
# STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = [
|
||||||
|
'127.0.0.1',
|
||||||
|
'localhost'
|
||||||
|
]
|
||||||
|
|
||||||
|
# PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
# STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
|
||||||
|
# STATIC_TMP = os.path.join(PROJECT_ROOT, 'static')
|
||||||
|
# # Extra places for collectstatic to find static files.
|
||||||
|
# STATICFILES_DIRS = (os.path.join(PROJECT_ROOT, 'static'),)
|
||||||
|
# os.makedirs(STATIC_TMP, exist_ok=True)
|
||||||
|
# os.makedirs(STATIC_ROOT, exist_ok=True)
|
||||||
|
|
||||||
if os.environ.get('ENV') == 'PRODUCTION':
|
|
||||||
ALLOWED_HOSTS = [os.environ.get('ALLOWED_HOSTS')]
|
|
||||||
else:
|
|
||||||
ALLOWED_HOSTS = [
|
|
||||||
'127.0.0.1',
|
|
||||||
'localhost'
|
|
||||||
]
|
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
|
|
@ -81,7 +83,7 @@ SITE_ID = 1
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
# 'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
|
@ -146,4 +148,3 @@ EMAIL_SUBJECT_PREFIX = "[VillaFleurieGuadeloupe] "
|
||||||
DEFAULT_FROM_EMAIL = "'Nilka, VillaFleurie' <location.villaFleurie@gmail.com>"
|
DEFAULT_FROM_EMAIL = "'Nilka, VillaFleurie' <location.villaFleurie@gmail.com>"
|
||||||
EMAIL_HOST_USER = "location.villafleurie@gmail.com"
|
EMAIL_HOST_USER = "location.villafleurie@gmail.com"
|
||||||
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
|
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
|
||||||
EMAIL_HOST_PASSWORD = "location229818"
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue