Add docker support

This commit is contained in:
Jesús 2022-01-13 18:08:28 -05:00
parent b77c06257f
commit 4317b0ba5d
No known key found for this signature in database
GPG Key ID: F6EE7BC59A315766
66 changed files with 324 additions and 1061 deletions

6
.gitignore vendored
View File

@ -3,14 +3,16 @@
*.pot
*.pyc
__pycache__/
personalsite/settings.py
django/personalsite/settings.py
db.sqlite3
media
static
venv/
core/static/admin/
django/core/static/admin/
### Sass ###
.sass-cache/
*.css.map
*.sass.map
*.scss.map
### Docker ###
config.env

View File

@ -112,6 +112,12 @@ DATABASES = {
$ python manage.py check --deploy
```
- Make migrations
```console
$ python manage.py makemigrations
```
- Migrate changes.
```console

35
config.env.example Normal file
View File

@ -0,0 +1,35 @@
#
# yt-local options
#
WEB_SITE_URL='http://example.org'
APP_DEBUG=True
SECRET_KEY=
#
# DataBase
#
NAME_DB=personalsite
USER_DB=postgres
PASS_DB=postgres
HOST_DB=172.23.0.6
PORT_DB=5432
#
# E-mail options
#
EMAIL_HOST=smtp.example.com
EMAIL_HOST_USER=username
EMAIL_HOST_PASSWORD=password
EMAIL_HOST_PORT=587
EMAIL_USE_TLS=True
#
# Gunicorn options
#
GUNICORN_PORT_NUMBER=8080
GUNICORN_NUM_WORKERS=4
GUNICORN_TIMEOUT=120

View File

@ -1,21 +0,0 @@
## Hacking
## SASS to CSS
1. Requeriments:
```
gem install sass
```
2. Generate CSS from SASS:
```
sass -t compressed --sourcemap=none sass/estilos.sass:css/estilos.min.css
```
3. Show CSS to SASS live
```
sass --watch -t compressed --sourcemap=none sass/estilos.sass:css/estilos.min.css
```

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,60 +0,0 @@
/*
@licstart The following is the entire license notice for the
JavaScript code in this page.
Copyleft 2021 | Heckyel
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@licend The above is the entire license notice
for the JavaScript code in this page.
*/
(function main() {
'use strict';
document.addEventListener('DOMContentLoaded', (event) => {
// buttons
const $aboutUs = document.getElementById('btn-acerca-de');
const $project = document.getElementById('btn-trabajos');
const $contact = document.getElementById('btn-contacto');
// sections
const $acercaDe = document.getElementById('acerca-de');
const $trabajos = document.getElementById('trabajos');
const $contacto = document.getElementById('contacto');
$aboutUs.addEventListener('click', (e) => {
e.preventDefault();
window.scroll({top: 240, behavior: 'smooth'});
location.hash = $aboutUs.hash;
});
$project.addEventListener('click', (e) => {
e.preventDefault();
$trabajos.scrollIntoView({
behavior: "smooth",
block: "start",
inline: "nearest"
});
location.hash = $project.hash;
});
$contact.addEventListener('click', (e) => {
e.preventDefault();
$contacto.scrollIntoView({
behavior: "smooth",
block: "start",
inline: "nearest"
});
location.hash = $contact.hash;
});
});
}());

View File

@ -1,65 +0,0 @@
/*
@licstart The following is the entire license notice for the
JavaScript code in this page.
Copyleft 2021 | Heckyel
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
@licend The above is the entire license notice
for the JavaScript code in this page.
*/
(function main(){
'use strict';
var formulario = document.getElementById('formulario'),
nombre = formulario.name,
correo = formulario.email,
mensaje = formulario.content,
error = document.getElementById('error');
function validarNombre(e){
if(nombre.value == '' || nombre.value == null){
console.info('Por favor completa el nombre');
error.style.display = 'block';
error.innerHTML = error.innerHTML + '<li>Por favor completa el nombre</li>';
e.preventDefault();
}
}
function validarCorreo(e){
if(correo.value == '' || correo.value == null){
console.info('Por favor completa el correo');
error.style.display = 'block';
error.innerHTML = error.innerHTML + '<li>Por favor completa el correo</li>';
e.preventDefault();
}
}
function validarMensaje(e){
if(mensaje.value == '' || mensaje.value == null){
console.info('Por favor completa el mensaje');
error.style.display = 'block';
error.innerHTML = error.innerHTML + '<li>Por favor completa el mensaje</li>';
e.preventDefault();
}
}
function validarFormulario(e){
error.innerHTML = '';
error.style.display = 'none';
validarNombre(e);
validarCorreo(e);
validarMensaje(e);
}
formulario.addEventListener('submit', validarFormulario);
}());

View File

@ -1,24 +0,0 @@
{
"name": "normalize-css",
"description": "A modern alternative to CSS resets",
"main": "normalize.css",
"license": "MIT",
"ignore": [
"CHANGELOG.md",
"CONTRIBUTING.md",
"package.json",
"README.md",
"test.html"
],
"homepage": "https://github.com/necolas/normalize.css",
"version": "7.0.0",
"_release": "7.0.0",
"_resolution": {
"type": "version",
"tag": "7.0.0",
"commit": "cd79468238394513cf481338c9dcb9aa8bd9b59c"
},
"_source": "https://github.com/necolas/normalize.css.git",
"_target": "~7.0.0",
"_originalSource": "normalize-css"
}

View File

@ -1,2 +0,0 @@
normalize.css linguist-vendored=false
test.html linguist-vendored

View File

@ -1 +0,0 @@
node_modules

View File

@ -1,3 +0,0 @@
language: node_js
node_js:
- stable

View File

@ -1,21 +0,0 @@
# The MIT License (MIT)
Copyright © Nicolas Gallagher and Jonathan Neal
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,13 +0,0 @@
{
"name": "normalize-css",
"description": "A modern alternative to CSS resets",
"main": "normalize.css",
"license": "MIT",
"ignore": [
"CHANGELOG.md",
"CONTRIBUTING.md",
"package.json",
"README.md",
"test.html"
]
}

View File

@ -1,447 +0,0 @@
/*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in
* IE on Windows Phone and in iOS.
*/
html {
line-height: 1.15; /* 1 */
-ms-text-size-adjust: 100%; /* 2 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/* Sections
========================================================================== */
/**
* Remove the margin in all browsers (opinionated).
*/
body {
margin: 0;
}
/**
* Add the correct display in IE 9-.
*/
article,
aside,
footer,
header,
nav,
section {
display: block;
}
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/* Grouping content
========================================================================== */
/**
* Add the correct display in IE 9-.
* 1. Add the correct display in IE.
*/
figcaption,
figure,
main { /* 1 */
display: block;
}
/**
* Add the correct margin in IE 8.
*/
figure {
margin: 1em 40px;
}
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box; /* 1 */
height: 0; /* 1 */
overflow: visible; /* 2 */
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
pre {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/* Text-level semantics
========================================================================== */
/**
* 1. Remove the gray background on active links in IE 10.
* 2. Remove gaps in links underline in iOS 8+ and Safari 8+.
*/
a {
background-color: transparent; /* 1 */
-webkit-text-decoration-skip: objects; /* 2 */
}
/**
* 1. Remove the bottom border in Chrome 57- and Firefox 39-.
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none; /* 1 */
text-decoration: underline; /* 2 */
text-decoration: underline dotted; /* 2 */
}
/**
* Prevent the duplicate application of `bolder` by the next rule in Safari 6.
*/
b,
strong {
font-weight: inherit;
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/**
* Add the correct font style in Android 4.3-.
*/
dfn {
font-style: italic;
}
/**
* Add the correct background and color in IE 9-.
*/
mark {
background-color: #ff0;
color: #000;
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Embedded content
========================================================================== */
/**
* Add the correct display in IE 9-.
*/
audio,
video {
display: inline-block;
}
/**
* Add the correct display in iOS 4-7.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/**
* Remove the border on images inside links in IE 10-.
*/
img {
border-style: none;
}
/**
* Hide the overflow in IE.
*/
svg:not(:root) {
overflow: hidden;
}
/* Forms
========================================================================== */
/**
* 1. Change the font styles in all browsers (opinionated).
* 2. Remove the margin in Firefox and Safari.
*/
button,
input,
optgroup,
select,
textarea {
font-family: sans-serif; /* 1 */
font-size: 100%; /* 1 */
line-height: 1.15; /* 1 */
margin: 0; /* 2 */
}
/**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/
button,
input { /* 1 */
overflow: visible;
}
/**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/
button,
select { /* 1 */
text-transform: none;
}
/**
* 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`
* controls in Android 4.
* 2. Correct the inability to style clickable types in iOS and Safari.
*/
button,
html [type="button"], /* 1 */
[type="reset"],
[type="submit"] {
-webkit-appearance: button; /* 2 */
}
/**
* Remove the inner border and padding in Firefox.
*/
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
/**
* Restore the focus styles unset by the previous rule.
*/
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
/**
* Correct the padding in Firefox.
*/
fieldset {
padding: 0.35em 0.75em 0.625em;
}
/**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/
legend {
box-sizing: border-box; /* 1 */
color: inherit; /* 2 */
display: table; /* 1 */
max-width: 100%; /* 1 */
padding: 0; /* 3 */
white-space: normal; /* 1 */
}
/**
* 1. Add the correct display in IE 9-.
* 2. Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
display: inline-block; /* 1 */
vertical-align: baseline; /* 2 */
}
/**
* Remove the default vertical scrollbar in IE.
*/
textarea {
overflow: auto;
}
/**
* 1. Add the correct box sizing in IE 10-.
* 2. Remove the padding in IE 10-.
*/
[type="checkbox"],
[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/
[type="search"] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
}
/**
* Remove the inner padding and cancel buttons in Chrome and Safari on macOS.
*/
[type="search"]::-webkit-search-cancel-button,
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
/* Interactive
========================================================================== */
/*
* Add the correct display in IE 9-.
* 1. Add the correct display in Edge, IE, and Firefox.
*/
details, /* 1 */
menu {
display: block;
}
/*
* Add the correct display in all browsers.
*/
summary {
display: list-item;
}
/* Scripting
========================================================================== */
/**
* Add the correct display in IE 9-.
*/
canvas {
display: inline-block;
}
/**
* Add the correct display in IE.
*/
template {
display: none;
}
/* Hidden
========================================================================== */
/**
* Add the correct display in IE 10-.
*/
[hidden] {
display: none;
}

View File

@ -1,22 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript license information</title>
<link rel="icon" href="./images/favicon.png" sizes="192x192" />
</head>
<body>
<table id="jslicense-labels1">
<tr>
<td><a href="./js/formulario.js">formulario.js</a></td>
<td><a href="http://www.gnu.org/licenses/gpl-3.0.html">GNU-GPL-3.0-or-later</a></td>
<td><a href="./js/formulario.js">formulario.js</a></td>
</tr>
<tr>
<td><a href="./js/efectos.js">efectos.js</a></td>
<td><a href="http://www.gnu.org/licenses/gpl-3.0.html">GNU-GPL-3.0-or-later</a></td>
<td><a href="./js/efectos.js">efectos.js</a></td>
</tr>
</table>
</body>
</html>

View File

@ -1,244 +0,0 @@
html
scroll-behavior: smooth
body
background: #fff
font-family: "liberation serif", "times new roman", calibri, carlito, sans-serif, serif
font-size: 16px
.contenedor
width: 90%
max-width: 1000px
margin: auto
overflow: hidden
/* ---- ---- HEADER ---- ---- */
header
background: url("./../images/BG.jpg") #68bdea
background-repeat: no-repeat
background-position: center
max-height: 600px
.menu
margin: 40px 0px
text-align: right
a
margin: 0px 20px
color: #fff
padding-bottom: 9px
display: inline-block
text-decoration: none
border-bottom: 2px solid transparent
font-size: 1rem
&:hover
border-bottom: 2px solid #fff
.contenedor-texto
display: flex
justify-content: center
align-content: center
margin: 190px 0px
.texto
border: 2px solid rgba(255, 255, 255, 0.5)
border-radius: 3px
display: inline-block
text-align: center
padding: 20px 60px
h1, h2
color: #fff
font-weight: 300
margin: 0px
.nombre
margin-bottom: 10px
font-size: 3.125rem
line-height: 50px
.profesion
font-size: 1.5rem
line-height: 25px
/* ---- ---- MAIN ---- ---- */
main
.contenedor
overflow: visible
.acerca-de
text-align: center
.foto
margin-top: -60px
img
vertical-align: top
border-radius: 50%
border: 5px solid rgba(255, 255, 255, 0.2)
.texto
color: #5a5a5a
font-weight: 600
font-size: 1rem
line-height: 30px
width: 80%
margin: 40px auto 60px auto
.titulo
font-size: 2.125rem
margin-bottom: 40px
font-weight: 300
color: #dd820d
text-align: center
.bold
color: #3895ea
text-decoration: underline
.trabajos
background: #f2f2f2
padding: 60px 0
.contenedor
overflow: hidden
.titulo
font-size: 2.125rem
line-height: 34px
margin-bottom: 40px
font-weight: 300
color: #323068
text-align: center
.contenedor-trabajos
display: flex
flex-direction: row
flex-wrap: wrap
justify-content: space-between
.trabajo
width: 23%
margin-bottom: 40px
.thumb
width: 100%
margin-bottom: 10px
img
width: 100%
vertical-align: top
border-radius: 3px
.descripcion
text-align: center
.nombre
font-weight: 700
color: #3895ea
margin-bottom: 10px
a
text-decoration: none
color: #3895ea
.categoria
font-size: 0.8rem
color: #636363
/* ---- ---- FOOTER ---- ---- */
footer
.contacto
padding: 60px 0
.titulo
font-size: 2.125rem
line-height: 34px
margin-bottom: 40px
font-weight: 300
color: #3895ea
text-align: center
.formulario
display: flex
flex-wrap: wrap
justify-content: space-between
input
&[type="text"], &[type="email"]
background: #f3f4f7
border: 2px solid #cecece
border-radius: 5px
padding: 15px 20px
font-size: 1.125rem
color: #a4a4a4
textarea
background: #f3f4f7
border: 2px solid #cecece
border-radius: 5px
padding: 15px 20px
font-size: 1.25rem
color: #a4a4a4
input
&[type="text"]:focus, &[type="email"]:focus
border: 2px solid #3895ea
textarea:focus
border: 2px solid #3895ea
input
&[type="text"], &[type="email"]
width: 45%
margin-bottom: 15px
textarea
width: 100%
height: 100px
max-width: 100%
min-height: 100px
max-height: 300px
margin-bottom: 15px
.error
display: none
margin-top: 20px
border-radius: 3px
background: #fc636b
color: #fff
padding: 15px 10px
padding-left: 40px
width: 100%
.boton
margin: auto
background: #3895ea
color: #fff
border: none
border-radius: 3px
padding: 15px 40px
cursor: pointer
&:hover
background: #387bea
.alert
&.success
color: #3895ea
white-space: pre-line
&.danger
color: #ee4c58
white-space: pre-line
.redes-sociales-libres
background: #1e2b38
padding: 60px 0
.contenedor
display: flex
justify-content: center
a
color: #fff
text-align: center
width: 100px
display: block
padding: 15px 0
border-radius: 3px
font-size: 1.8rem
margin: 0 20px
svg
fill: currentcolor
width: 24px
.diaspora:hover
background: #010101
.gnusocial:hover
background: #a42833
.gitlab:hover
background: #e24329
.libregit:hover
background: #333333
.mediagoblin:hover
background: #775fa3
.notabug:hover
background: #244664
.peertube:hover
background: #f1680d
.copyleft
background: #192633
padding: 5px 0
p
color: #fff
text-align: center
font-size: 0.75rem
a
color: #3895ea
text-decoration: none
svg
width: 0.5rem
fill: currentcolor

View File

@ -1,41 +0,0 @@
@media screen and (max-width: 985px)
footer .contacto .formulario input
&[type="text"], &[type="email"]
width: 44%
@media screen and (max-width: 830px)
footer .contacto .formulario input
&[type="text"], &[type="email"]
width: 42%
@media screen and (max-width: 800px)
header .menu
text-align: center
main .trabajos .contenedor-trabajos .trabajo
width: 46%
footer .contacto .formulario [type="text"], [type="email"]
width: 100%
@media screen and (max-width: 630px)
footer .contacto .formulario input
&[type="text"], &[type="email"]
width: 100%
@media screen and (max-width: 500px)
header .contenedor-texto .texto
.nombre
font-size: 35px
.profesion
font-size: 18px
footer .redes-sociales-libres .contenedor
flex-wrap: wrap
padding: 20px 0
@media screen and (max-width: 320px)
footer .contacto .formulario input
&[type="text"], &[type="email"]
width: 84%
footer
.copyleft
p
font-size: 0.60rem

View File

@ -1,8 +0,0 @@
// Estilos para Portafolio
// License AGPLv3 or later
/* ---- Frontend ---- */
@import front
/* ---- MEDIA QUERIES ---- */
@import mediaqueries

47
django/Dockerfile Normal file
View File

@ -0,0 +1,47 @@
FROM python:3-alpine AS base
LABEL MAINTAINER="heckyel@riseup.net"
# Image to Build Dependencies
FROM base AS builder
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
RUN apk add --no-cache musl-dev build-base make gcc g++ \
libxml2-dev libffi-dev zlib-dev libjpeg lcms2-dev libimagequant-dev \
libjpeg-turbo-dev libwebp-dev openjpeg-dev tk-dev py3-pillow
ARG APP_DIR="/srv/app"
RUN mkdir --parents "$APP_DIR"
WORKDIR "$APP_DIR"
COPY requirements_prod.txt .
RUN pip install --no-cache-dir --prefix=/install wheel gunicorn
RUN pip install --no-cache-dir --prefix=/install -r requirements_prod.txt
# Runtime Environment Image
FROM base
WORKDIR /srv/app
# Runtime Dependencies
RUN apk add py3-olefile brotli-libs libpng freetype libxcb \
libimagequant libjpeg-turbo lcms2 openjpeg libwebp zstd-libs \
tiff libxau libmd libbsd libxdmcp nginx
COPY --from=builder /install /usr/local
COPY core/ /srv/app/core
COPY personalsite/ /srv/app/personalsite
COPY project/ /srv/app/project
COPY social/ /srv/app/social
COPY manage.py /srv/app
COPY nginx.conf /etc/nginx/http.d/default.conf
EXPOSE 80
COPY entrypoint.sh /
RUN chmod u+x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

161
django/entrypoint.sh Normal file
View File

@ -0,0 +1,161 @@
#!/usr/bin/env sh
## Config
if [ ! -f "/srv/app/personalsite/settings.py" ]; then
# generate config
cat > /srv/app/personalsite/settings.py <<- EOF
"""
Django settings for personalsite project.
Generated by 'django-admin startproject' using Django 2.1.2.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '${SECRET_KEY:-8$oylik7o2-dbx+5a77=2a532w8lx&=ofiyv!1bs9a9)0t%6r2}'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = ${APP_DEBUG:-False}
ALLOWED_HOSTS = ["${WEB_SITE_URL:-example.com}", "localhost", "127.0.0.1", "0.0.0.0", "django"]
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'core',
'project.apps.ProjectConfig',
'social.apps.SocialConfig',
'django_cleanup.apps.CleanupConfig',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'personalsite.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'social.processors.ctx_dict',
],
},
},
]
WSGI_APPLICATION = 'personalsite.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '${NAME_DB:-site}',
'USER': '${USER_DB:-site}',
'PASSWORD': '${PASS_DB:-site}',
'HOST': '${HOST_DB:-127.0.0.1}',
'PORT': '${PORT_DB:-5432}',
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'es'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
# Media files
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# Incoming Email
EMAIL_FROM = '${EMAIL_FROM:-noreply@example.com}'
EMAIL_TO = '${EMAIL_TO:-user@example.com}'
# Email config
EMAIL_HOST = '${EMAIL_HOST:-smtp.example.com}'
EMAIL_HOST_USER = '${EMAIL_HOST_USER:-username}'
EMAIL_HOST_PASSWORD = '${EMAIL_HOST_PASSWORD:-password}'
EMAIL_PORT = '${EMAIL_HOST_PORT:-587}'
EMAIL_USE_TLS = ${EMAIL_USE_TLS:-True}
EOF
fi
cd /srv/app || exit
/usr/local/bin/python3 manage.py makemigrations --no-input
/usr/local/bin/python3 manage.py migrate --no-input
/usr/local/bin/python3 manage.py collectstatic --no-input
gunicorn -b "0.0.0.0:${GUNICORN_PORT_NUMBER:-8080}" --timeout "${GUNICORN_TIMEOUT:-30}" --workers "${GUNICORN_NUM_WORKERS:-4}" personalsite.wsgi &
exec nginx -g "daemon off;"

25
django/nginx.conf Normal file
View File

@ -0,0 +1,25 @@
upstream django {
server 127.0.0.1:8080;
}
server {
listen 80;
access_log /dev/null;
error_log /dev/null;
location / {
proxy_pass http://django;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
location /static/ {
autoindex on;
alias /srv/app/static/;
}
location /media/ {
autoindex on;
alias /srv/app/media/;
}
}

View File

@ -125,7 +125,7 @@ USE_TZ = True
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'core/static')
MEDIA_ROOT = os.path.join(BASE_DIR, 'static')
# Media files
MEDIA_URL = '/media/'

View File

@ -0,0 +1,5 @@
Django==2.2.16
django-cleanup==5.0.0
Pillow==8.4.0
psycopg2-binary
pytz

40
docker-compose.yml Normal file
View File

@ -0,0 +1,40 @@
version: '3'
services:
app:
image: rusian/personalsite
container_name: personalsite
env_file: config.env
ports:
- "7012:80"
tty: true
restart: "always"
networks:
teanet:
ipv4_address: 172.23.0.5
personalsite-db:
image: postgres:alpine
container_name: personalsite-db
ports:
- 5432:5432
restart: always
volumes:
- personalsite_db:/var/lib/postgresql/data
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=personalsite
networks:
teanet:
ipv4_address: 172.23.0.6
volumes:
personalsite_db:
networks:
teanet:
driver: bridge
ipam:
config:
- subnet: 172.23.0.0/16

View File

@ -1,19 +0,0 @@
"""
WSGI config for personalsite project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
"""
import os, sys
from django.core.wsgi import get_wsgi_application
sys.path.append('/path/to/site/personalsite')
sys.path.append('/path/to/site')
os.environ['DJANGO_SETTINGS_MODULE'] = 'personalsite.settings'
application = get_wsgi_application()

View File

@ -1,31 +0,0 @@
# Generated by Django 2.1.2 on 2018-10-04 02:27
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Project',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200, verbose_name='Titulo')),
('decription', models.TextField(verbose_name='Descripción')),
('image', models.ImageField(upload_to='projects/uploads/%Y/%m/%d/', verbose_name='Imagen')),
('link', models.URLField(blank=True, null=True, verbose_name='Sitio web')),
('created', models.DateTimeField(auto_now_add=True, verbose_name='Fecha de creación')),
('updated', models.DateTimeField(auto_now=True, verbose_name='Fecha de modificación')),
],
options={
'verbose_name': 'proyecto',
'verbose_name_plural': 'proyectos',
'ordering': ['-created'],
},
),
]

View File

@ -1,5 +0,0 @@
Django==2.2.16
django-cleanup==5.0.0
Pillow==9.0.0
psycopg2-binary==2.8.1
pytz==2018.9

View File

@ -1,30 +0,0 @@
# Generated by Django 2.1.2 on 2018-10-04 21:04
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Link',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('key', models.SlugField(max_length=100, unique=True, verbose_name='Nombre clave')),
('name', models.CharField(max_length=200, verbose_name='Red social')),
('url', models.URLField(blank=True, null=True, verbose_name='Enlace')),
('created', models.DateTimeField(auto_now_add=True, verbose_name='Fecha de creación')),
('updated', models.DateTimeField(auto_now=True, verbose_name='Fecha de modificación')),
],
options={
'verbose_name': 'enlace',
'verbose_name_plural': 'enlaces',
'ordering': ['name'],
},
),
]