-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Añadido: proyecto manu export org files
- Loading branch information
Showing
5 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
all: down up | ||
|
||
b build: | ||
$(info Construyendo imagenes...) | ||
$(call docker_cmd, build) | ||
|
||
u up: | ||
$(info Ejecutando contenedor/es...) | ||
$(call docker_cmd, up) | ||
|
||
p pause: | ||
$(info Pausando contenedor/es...) | ||
$(call docker_cmd, pause) | ||
|
||
s stop: | ||
$(info Deteniendo contenedor/es...) | ||
$(call docker_cmd, stop) | ||
|
||
d down: | ||
$(call docker_cmd, down) | ||
|
||
l logs: | ||
$(call docker_cmd, logs --tail 50 --follow) | ||
|
||
sh: | ||
$(info Accediendo al contentendor en modo interactivo...) | ||
$(call docker_cmd, exec, /bin/sh) | ||
|
||
npm: | ||
@docker-compose exec $(CONTAINER_WEBAPP) npm $(ARGS) | ||
|
||
export: | ||
$(call make_exec, export.mk, watch) | ||
|
||
.PHONY: all sh npm export b build u up s stop l logs d down clean p pause | ||
|
||
-include Makefile.conf | ||
-include functions.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CONTAINER_WEBAPP ?= webapp | ||
|
||
# - evitamos definir los nombres de los parámetros que pasamos por terminal | ||
# - alternativa: en la orden de una regla usar $(filter-out $@,$(MAKECMDGOALS)) | ||
ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) | ||
|
||
# - requisito para que funcione el paso de parámetros sin warnings | ||
%: | ||
@: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM pandoc/core | ||
|
||
RUN apk add --no-cache make rsync | ||
|
||
RUN addgroup -g 1000 -S pandoc && adduser -u 1000 -G pandoc -D pandoc | ||
USER pandoc | ||
|
||
WORKDIR /data | ||
COPY export.mk . | ||
COPY functions.mk . | ||
COPY ./docs ./docs | ||
COPY ./src/views ./src/views | ||
|
||
# necesario, porque el punto de entrada por defecto de la imagen base es /bin/pandoc | ||
ENTRYPOINT ["/bin/sh", "-c"] | ||
CMD ["make --no-print-directory -f export.mk watch"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# --------------------------------------------------------------------------- | ||
# - MACROS | ||
.DEFAULT_GOAL := export | ||
|
||
MAKE += -f export.mk | ||
|
||
DOC_PATH := docs | ||
HTML_PATH := src/views | ||
ROOT_PATH := $(shell pwd) | ||
COMPONENTS_PATH := src/components | ||
DOC_SUBDIRS := $(sort $(dir $(wildcard $(DOC_PATH)/*/))) | ||
HTML_SUBDIRS := $(subst $(DOC_PATH),$(HTML_PATH),$(DOC_SUBDIRS)) | ||
SUBDIRS := $(DOC_SUBDIRS) $(HTML_SUBDIRS) | ||
|
||
DOC_FILES := $(foreach dir, $(DOC_SUBDIRS), $(wildcard $(dir)*.org)) | ||
HTML_FILES := $(subst $(DOC_PATH),$(HTML_PATH), $(DOC_FILES)) | ||
HTML_FILES := $(patsubst %.org,%.html, $(HTML_FILES)) | ||
|
||
RM := rm -rfv | ||
MKDIR := mkdir -vp | ||
|
||
# --------------------------------------------------------------------------- | ||
# PANDOC CONFIG | ||
|
||
PANDOC_PARAMS = \ | ||
--from=org --to=html --out=$@ --table-of-contents --toc-depth 3 \ | ||
--resource-path=$(ROOT_PATH) \ | ||
--template $(COMPONENTS_PATH)/template.html | ||
|
||
# si no está definida la variable de entorno, le definimos otro valor | ||
HOST_ENV ?= manjaro | ||
|
||
ifeq ($(HOST_ENV), container) | ||
PANDOC_CMD = @pandoc $(PANDOC_PARAMS) $< | ||
else | ||
PANDOC_CMD = \ | ||
@docker run --rm \ | ||
--volume "$(ROOT_PATH):/data" \ | ||
--user $(shell id -u):$(shell id -g) \ | ||
pandoc/minimal $(PANDOC_PARAMS) $< | ||
endif | ||
|
||
# --------------------------------------------------------------------------- | ||
# - REGLAS | ||
|
||
export: $(SUBDIRS) $(HTML_FILES) | ||
|
||
watch: | ||
$(info Observando cambios en la documentación para exportar...) | ||
$(call watch) | ||
|
||
$(SUBDIRS): | ||
$(info Creando estructura de directorios) | ||
@$(MKDIR) $@ | ||
|
||
$(HTML_FILES):$(HTML_PATH)/%.html:$(DOC_PATH)/%.org | ||
$(info Exportando a html el fichero $(subst $(DOC_PATH)/,,$<)) | ||
$(PANDOC_CMD) | ||
|
||
clean: | ||
$(info Borrando archivos html...) | ||
@-$(RM) $(HTML_FILES) | ||
|
||
.PHONY: watch export clean | ||
|
||
-include functions.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
define docker_cmd | ||
@docker-compose $1 $(ARGS) $2 | ||
endef | ||
|
||
define make_exec | ||
@$(MAKE) --no-print-directory -f $1 $2 | ||
endef | ||
|
||
define watch | ||
@while true; do $(MAKE) -q || $(MAKE) --no-print-directory; sleep 1; done | ||
endef |