From b44688f26748e4a8c6dee496c78134a19aeff479 Mon Sep 17 00:00:00 2001
From: Vincent Mazenod <vmazenod@gmail.com>
Date: Fri, 29 Jul 2022 15:41:06 +0200
Subject: [PATCH] fixup! fix ci
---
.docker/build/pelican/Dockerfile | 54 +++++++++++++++++++++++++
.env | 3 ++
Makefile | 69 ++++++++++++++++++++++++++++++++
docker-compose.yml | 16 ++++++++
4 files changed, 142 insertions(+)
create mode 100644 .docker/build/pelican/Dockerfile
create mode 100644 .env
create mode 100644 Makefile
create mode 100644 docker-compose.yml
diff --git a/.docker/build/pelican/Dockerfile b/.docker/build/pelican/Dockerfile
new file mode 100644
index 0000000..6ac80d9
--- /dev/null
+++ b/.docker/build/pelican/Dockerfile
@@ -0,0 +1,54 @@
+# FROM nikolaik/python-nodejs:python3.7-nodejs16-bullseye AS compile-image
+FROM nikolaik/python-nodejs:python3.7-nodejs16-bullseye AS source-image
+ARG DEBIAN_FRONTEND=noninteractive
+
+RUN { \
+ echo krb5-config krb5-config/default_realm string 'LOCAL.ISIMA.FR'; \
+ echo tzdata tzdata/Areas string 'Etc'; \
+ echo tzdata tzdata/Zones/Etc string 'UTC'; \
+ } | debconf-set-selections \
+ && \
+ apt-get update && apt-get install -y --no-install-recommends \
+ build-essential \
+ gcc \
+ apt-utils \
+ krb5-user \
+ krb5-config \
+ 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
+COPY content/package.json ./content/package.json
+RUN cd content && yarn install
+
+# FROM nikolaik/python-nodejs:python3.7-nodejs16-bullseye AS build-image
+# COPY --from=compile-image /root/.local /root/.local
+# COPY --from=compile-image /usr/bin /usr/bin
+# COPY --from=compile-image /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu
+# LABEL stage=builder
+
+ENV SRV_DIR=//srv
+ENV WORKING_DIR=//srv/pelican
+ENV PORT=8000
+ENV PATH=/root/.local/bin:$PATH
+
+ADD . $SRV_DIR
+WORKDIR $WORKING_DIR
+RUN mkdir output content cache
+VOLUME ["$WORKING_DIR/"]
+
+# make python server in foreground
+RUN sed -i 's/\$port &/\$port/g' $SRV_DIR/develop_server.sh
+
+RUN chmod +x $SRV_DIR/develop_server.sh
+
+EXPOSE $PORT
+
+ENTRYPOINT $SRV_DIR/develop_server.sh start $PORT
+
diff --git a/.env b/.env
new file mode 100644
index 0000000..7a6eab4
--- /dev/null
+++ b/.env
@@ -0,0 +1,3 @@
+REGISTRY_URL=docker.isima.fr
+NAMESPACE=docker.isima.fr/vimazeno
+APP_NAME=pelican_perso
\ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..533e07a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,69 @@
+BOLD := \033[1m
+RESET := \033[0m
+RED := \033[31m
+GREEN := \033[32m
+YELLOW := \033[33m
+BLUE := \033[34m
+MAGENTA := \033[35m
+
+SHELL := /bin/bash
+IMAGES := $(shell docker-compose config --services)
+TAG := $(shell git rev-parse --short HEAD)
+VOLUMES := content/node_modules output
+
+# Executables (local)
+DOCKER_COMP := docker-compose
+.DEFAULT_GOAL := help
+
+# Docker containers
+PELICAN_CONT := $(DOCKER_COMP) exec pelican
+
+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
+ @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} ;
+.PHONY: push
+
+up: ## Make required containers up
+ @$(DOCKER_COMP) up --remove-orphans
+.PHONY: up
+
+down: ## Make required containers down
+ @$(DOCKER_COMP) down
+.PHONY: down
+
+logs: ## Show live containers logs. Pass the parameter "c=" to see one specific container's logs, example: make logs c='frontend'
+ @$(eval c ?=)
+ @if [ -z "$(c)" ]; then \
+ $(DOCKER_COMP) logs --follow; \
+ else \
+ $(DOCKER_COMP) logs --timestamps --follow $(c); \
+ fi
+.PHONY: logs
+
+errors: ## Show live container errors.
+ @$(DOCKER_COMP) logs | grep error
+.PHONY: errors
+
+pelican: ## Open bash on php container
+ @$(PELICAN_CONT) bash
+.PHONY: pelican
+
+clean: ## Remove node and php folders and files
+ @for volume in ${VOLUMES} ; do \
+ sudo rm -rf $${volume} ; \
+ done
+.PHONY: clean
+
+help:
+ @grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
+.PHONY: help
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..192a726
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,16 @@
+version: '3.5'
+
+services:
+
+ pelican:
+ image: ${NAMESPACE}/${APP_NAME}:latest
+ build:
+ context: .
+ dockerfile: .docker/build/pelican/Dockerfile
+ container_name: pelican
+ environment:
+ TZ: ${TIMEZONE:-Europe/Paris}
+ volumes:
+ - .:/srv/pelican
+ ports:
+ - "8000:8000"
\ No newline at end of file
--
GitLab