Transformando a docker
This commit is contained in:
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
||||
venv/
|
||||
.git/
|
||||
www/
|
||||
15
Dockerfile
Normal file
15
Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM python:3 as builder
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
RUN mkdir www/
|
||||
|
||||
RUN python generator
|
||||
|
||||
###########################################################
|
||||
FROM nginx:latest as deployer
|
||||
COPY --from=builder /usr/src/app/www /usr/share/nginx/html
|
||||
34
generator
34
generator
@@ -5,9 +5,6 @@ import time
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from markdown import markdown
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import PatternMatchingEventHandler
|
||||
|
||||
|
||||
src_dir = Path('src')
|
||||
out_dir = Path('www')
|
||||
@@ -75,35 +72,6 @@ def execute():
|
||||
print('parsing {} as any'.format(path))
|
||||
process_any(path)
|
||||
|
||||
class WatchHandler(PatternMatchingEventHandler):
|
||||
patterns = ["*.py", "*.md", "*.css", "*.js"]
|
||||
|
||||
def process(self, event):
|
||||
execute()
|
||||
|
||||
def on_modified(self, event):
|
||||
self.process(event)
|
||||
|
||||
def on_created(self, event):
|
||||
self.process(event)
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) > 1 and sys.argv[1] == '--watch':
|
||||
observer = Observer()
|
||||
observer.schedule(WatchHandler(), str(src_dir), recursive=True)
|
||||
observer.start()
|
||||
|
||||
try:
|
||||
while True:
|
||||
time.sleep(1)
|
||||
except KeyboardInterrupt:
|
||||
observer.stop()
|
||||
|
||||
observer.join()
|
||||
else:
|
||||
execute()
|
||||
|
||||
|
||||
|
||||
|
||||
execute()
|
||||
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
markdown
|
||||
pygments
|
||||
watchdog
|
||||
|
||||
@@ -18,7 +18,7 @@ El codigo que he escrito para distintos proyectos lo mantengo en
|
||||
intento mantener de las redes sociales. Y finalmente, si me quieres enviar un
|
||||
correo, mi dirección es hola@danielcortes.xyz
|
||||
|
||||
##[Posts](/blog)
|
||||
##[Posts](/blog/index.html)
|
||||
Aqui posteo lo que intento escribir una vez al año. Me cuesta conseguir ideas y
|
||||
ganas para sentarme a escribir algo pero me agrada tener la posibilidad aqui.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user