diff --git a/.docker/build/python/Dockerfile b/.docker/build/python/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8a1d3e29b0121f18094a26182124760e6a81651b --- /dev/null +++ b/.docker/build/python/Dockerfile @@ -0,0 +1,17 @@ +FROM debian:stable + +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3 \ + python3-pip \ + locales \ + rsync \ + && \ + locale-gen fr_FR \ + locale-gen fr_FR.UTF-8 \ + update-locale LANG=fr_FR.UTF-8 \ + . /etc/default/locale + +COPY requirements.txt . +RUN pip install --user -r requirements.txt + +WORKDIR /srv/blog \ No newline at end of file diff --git a/.docker/scripts/python/command.dev.sh b/.docker/scripts/python/command.dev.sh index 19b564fff0f09d58f865dbb8b9036feeb7cfbe78..9d95f98d8a21b4b00d118e84b9008c8101ec6d42 100755 --- a/.docker/scripts/python/command.dev.sh +++ b/.docker/scripts/python/command.dev.sh @@ -1,7 +1,3 @@ -apt-get update -apt-get -y --no-install-recommends install python3 python3-pip #python3-gettext -cd /srv/blog -pip install --user -r requirements.txt sed -i 's/\$port &/\$port/g' ./develop_server.sh chmod +x develop_server.sh export PATH=/root/.local/bin:$PATH diff --git a/.env b/.env index 6764631349e5119e35e5a610534b9341851bced3..b36eff3d113f45c50366527b4fa9d2b5d81de803 100644 --- a/.env +++ b/.env @@ -1,3 +1,4 @@ +PORT=8000 REGISTRY_URL=docker.isima.fr NAMESPACE=docker.isima.fr/vimazeno APP_NAME=pelican_perso diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c673508df7fe46da2cbc920ad7ee93e474e71788..c9f1818b1be945af3e6ede0b852dcd9bb5316c4e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,14 +1,24 @@ -image: docker.isima.fr/vimazeno/pelican_perso - cache: paths: - output/ # le répertoire où se trouve le HTML statique généré +install: + image: node:latest + stage: install + script: + - cd /srv/blog/content/slides && yarn + build: + image: docker.isima.fr/vimazeno/pelican_perso_python stage: build + script: + - pelican + +deploy: + image: docker.isima.fr/vimazeno/pelican_perso_kerberos + stage: deploy script: # récupération du KEYTAB en hexa - - ls - echo "$KEYTAB" > my.keytab.hex # conversion du KEYTAB en hexa en binaire - sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' my.keytab.hex | xargs printf > my.keytab @@ -27,8 +37,4 @@ build: - ssh -o StrictHostKeyChecking=no -K vimazeno@perso.local.isima.fr "echo ' Header set Content-Disposition attachment' >> ~/public_html/_/.htaccess" - ssh -o StrictHostKeyChecking=no -K vimazeno@perso.local.isima.fr "echo '</FilesMatch>' >> ~/public_html/_/.htaccess" # rsync du HTML statique généré - - rsync -az --exclude '_' -e "ssh -o StrictHostKeyChecking=no -K" output/ vimazeno@perso.local.isima.fr:~/public_html/ - - ssh -o StrictHostKeyChecking=no -K vimazeno@perso.local.isima.fr "mkdir -p ~/public_html/node_modules" - - rsync -az -e "ssh -o StrictHostKeyChecking=no -K" content/node_modules/ vimazeno@perso.local.isima.fr:~/public_html/node_modules - # le déploiement se fera uniquement lorsque je clique sur le "play" de la CI via l'interface gitlab - when: manual \ No newline at end of file + - rsync -az --exclude '_' -e "ssh -o StrictHostKeyChecking=no -K" output/ vimazeno@perso.local.isima.fr:~/public_html/ \ No newline at end of file diff --git a/Makefile b/Makefile index 767489b3a6419aaa547d3f20351023ec9c2f2381..00818ef8ac884a8e49bcf9141b7ffeaef0d1d6ac 100644 --- a/Makefile +++ b/Makefile @@ -22,21 +22,27 @@ include .env build: ## Build required docker compose images @$(DOCKER_COMP) build - @docker image prune -f --filter label=stage=source-image - @docker image prune -f --filter label=stage=build-image .PHONY: build push: ## Push build docker compose images + @TAG=$(shell git rev-parse --short HEAD) @docker login ${REGISTRY_URL} - @docker push ${NAMESPACE}/${APP_NAME}:latest - @docker image tag ${NAMESPACE}/${APP_NAME}:latest ${NAMESPACE}/${APP_NAME}:${TAG} - @docker push ${NAMESPACE}/${APP_NAME}:${TAG} ; + @docker push ${NAMESPACE}/${APP_NAME}_python:latest ; + @docker tag ${NAMESPACE}/${APP_NAME}_python:latest ${NAMESPACE}/${APP_NAME}_python:${TAG} ; + @docker push ${NAMESPACE}/${APP_NAME}_python:${TAG} ; + @docker push ${NAMESPACE}/${APP_NAME}_kerberos:latest ; + @docker tag ${NAMESPACE}/${APP_NAME}_kerberos:latest ${NAMESPACE}/${APP_NAME}_kerberos:${TAG} ; + @docker push ${NAMESPACE}/${APP_NAME}_kerberos:${TAG} ; .PHONY: push up: ## Make required containers up @$(DOCKER_COMP) up --remove-orphans node -# @$(DOCKER_COMP) run dockerize -timeout 180s -wait-retry-interval 3s \ -# -wait file:///tmp/content/node_modules/.yarn-integrity ; + @echo -e "Ⱐ${BOLD}${GREEN}Wait for node to install needed js (there's no problem we're just wait)...${RESET}" + @$(DOCKER_COMP) run dockerize -timeout 180s -wait-retry-interval 3s \ + -wait file:///tmp/content/node_modules/.yarn-integrity ; + @echo -e "Ⱐ${BOLD}${GREEN}Wait for pelican to generate content (there's no problem we're just wait)...${RESET}" + @echo -e "${GREEN}${BOLD}up and running${RESET}" + @echo -e " 🳠blog in docker ${BLUE}${BOLD}http://localhost:${PORT}${RESET}" @$(DOCKER_COMP) up --remove-orphans python .PHONY: up diff --git a/docker-compose.yml b/docker-compose.yml index 189f9cb88aed8699aae784560e0638aa6bab0a68..4afd73f4030ab4f9d0d4a0ffbf1b21a5abfd8d64 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: node: image: node:latest - container_name: blog_node_dev + container_name: ${APP_NAME}_node environment: TZ: ${TIMEZONE:-Europe/Paris} working_dir: /srv/blog @@ -13,23 +13,26 @@ services: command: bash /srv/blog/.docker/scripts/node/command.dev.sh python: - image: debian:stable - container_name: blog_python_dev + image: ${NAMESPACE}/${APP_NAME}_python:latest + build: + context: . + dockerfile: .docker/build/python/Dockerfile + container_name: ${APP_NAME}_python environment: TZ: ${TIMEZONE:-Europe/Paris} working_dir: /srv/blog volumes: - .:/srv/blog ports: - - "8000:8000" + - "${PORT-8000}:8000" command: bash /srv/blog/.docker/scripts/python/command.dev.sh kerberos: - image: ${NAMESPACE}/${APP_NAME}_kerberos_dev:latest + image: ${NAMESPACE}/${APP_NAME}_kerberos:latest build: context: . dockerfile: .docker/build/kerberos/Dockerfile - container_name: blog_kerberos_dev + container_name: ${APP_NAME}_kerberos environment: TZ: ${TIMEZONE:-Europe/Paris} volumes: