Skip to content

Commit

Permalink
backend dev server monolingual and mutlilingual
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuess committed Nov 2, 2024
1 parent ed58370 commit 738692c
Show file tree
Hide file tree
Showing 48 changed files with 1,026 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ node_modules
results
yarn.lock
/public
cypress/screenshots/*
cypress/screenshots/*
backend/dockerfiles/backend/.venv/
backend/dockerfiles/backend/instance/
4 changes: 4 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# backend with collective.elastic.plone and ElasticSearch


## rohberg.voltosearchkitblocktestingprofiles

Profiles for monolingual and multilingual testing
11 changes: 7 additions & 4 deletions backend/dockerfiles/backend/Dockerfile.dev.monolingual
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# The language is set here:
# PROFILES … rohberg.volto:monolingual
# PROFILES …:monolingual
ARG SEED=1000
ARG PLONE_VERSION=6.0
FROM plone/plone-backend:${PLONE_VERSION}
Expand All @@ -12,7 +12,7 @@ LABEL maintainer="Plone Foundation <[email protected]>" \
org.label-schema.vendor="Rohberg"

# Add local code
COPY ./backend .
COPY backend .

# # Install local requirements and fix permissions
# RUN <<EOT
Expand All @@ -26,6 +26,9 @@ COPY ./backend .

# Install local requirements and fix permissions
RUN <<EOT
set -e
# remove potentially existing virtualenv from local build
rm -rf .venv
mv requirements-docker.txt requirements.txt
./bin/pip install -r requirements.txt
chown -R plone: /app
Expand All @@ -39,8 +42,8 @@ EOT
# Create a new site with content
RUN <<EOT
SEED=${SEED}
# export ADDONS="collective.elastic.plone[redis,opensearch] rohberg.volto[test]@git+https://github.com/rohberg/rohberg.volto.git"
export PROFILES="collective.elastic.plone:default rohberg.volto:monolingual"
# export ADDONS="collective.elastic.plone[redis,opensearch] rohberg.voltosearchkitblocktestingprofiles"
export PROFILES="collective.elastic.plone:default rohberg.voltosearchkitblocktestingprofiles:monolingual"
export DEBUG_MODE=on
export DELETE_EXISTING=true
./docker-entrypoint.sh create-site
Expand Down
14 changes: 8 additions & 6 deletions backend/dockerfiles/backend/Dockerfile.dev.multilingual
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# The language is set here:
# PROFILES … rohberg.volto:multilingual
# PROFILES …:multilingual
ARG SEED=1000
ARG PLONE_VERSION=6.0
FROM plone/plone-backend:${PLONE_VERSION}
Expand All @@ -12,7 +12,7 @@ LABEL maintainer="Plone Foundation <[email protected]>" \
org.label-schema.vendor="Rohberg"

# Add local code
COPY ./backend .
COPY backend .

# # Install local requirements and fix permissions
# RUN <<EOT
Expand All @@ -26,6 +26,9 @@ COPY ./backend .

# Install local requirements and fix permissions
RUN <<EOT
set -e
# remove potentially existing virtualenv from local build
rm -rf .venv
mv requirements-docker.txt requirements.txt
./bin/pip install -r requirements.txt
chown -R plone: /app
Expand All @@ -36,12 +39,11 @@ RUN <<EOT
mv collective.elastic.plone-configure.zcml etc/package-includes/collective.elastic.plone-configure.zcml
EOT

# Create a new site with content
# Create a new site with packages installed
RUN <<EOT
SEED=${SEED}
# # ADDITIONAL_PROFILES=collective.elastic.plone:default
export ADDONS="collective.elastic.plone[redis,opensearch] rohberg.volto[test]@git+https://github.com/rohberg/rohberg.volto.git"
export PROFILES="collective.elastic.plone:default rohberg.volto:multilingual"
# export ADDONS="collective.elastic.plone[redis,opensearch] rohberg.voltosearchkitblocktestingprofiles"
export PROFILES="collective.elastic.plone:default rohberg.voltosearchkitblocktestingprofiles:multilingual"
export DEBUG_MODE=on
export DELETE_EXISTING=true
./docker-entrypoint.sh create-site
Expand Down
90 changes: 90 additions & 0 deletions backend/dockerfiles/backend/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
### Defensive settings for make:
# https://tech.davis-hansson.com/p/make/
SHELL:=bash
.ONESHELL:
.SHELLFLAGS:=-xeu -o pipefail -O inherit_errexit -c
.SILENT:
.DELETE_ON_ERROR:
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules

# We like colors
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`

IMAGE_NAME_PREFIX=ghcr.io/rohberg/volto-searchkit-block-testing-profiles
IMAGE_TAG=latest

# Python checks
PYTHON?=python3

# installed?
ifeq (, $(shell which $(PYTHON) ))
$(error "PYTHON=$(PYTHON) not found in $(PATH)")
endif

# version ok?
PYTHON_VERSION_MIN=3.8
PYTHON_VERSION_OK=$(shell $(PYTHON) -c "import sys; print((int(sys.version_info[0]), int(sys.version_info[1])) >= tuple(map(int, '$(PYTHON_VERSION_MIN)'.split('.'))))")
ifeq ($(PYTHON_VERSION_OK),0)
$(error "Need python $(PYTHON_VERSION) >= $(PYTHON_VERSION_MIN)")
endif

PLONE_SITE_ID=Plone
BACKEND_FOLDER=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
PLONE_VERSION=$(shell cat $(BACKEND_FOLDER)/version.txt)
EXAMPLE_CONTENT_FOLDER=${BACKEND_FOLDER}/src/project/title/setuphandlers/examplecontent

GIT_FOLDER=$(BACKEND_FOLDER)/.git
VENV_FOLDER=$(BACKEND_FOLDER)/.venv
BIN_FOLDER=$(VENV_FOLDER)/bin


all: build

# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
.PHONY: help
help: ## This help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

$(BIN_FOLDER)/pip $(BIN_FOLDER)/tox $(BIN_FOLDER)/pipx $(BIN_FOLDER)/uv $(BIN_FOLDER)/mxdev:
@echo "$(GREEN)==> Setup Virtual Env$(RESET)"
$(PYTHON) -m venv $(VENV_FOLDER)
$(BIN_FOLDER)/pip install -U "pip" "uv" "wheel" "pipx" "mxdev" "tox" "pre-commit"
if [ -d $(GIT_FOLDER) ]; then $(BIN_FOLDER)/pre-commit install; else echo "$(RED) Not installing pre-commit$(RESET)";fi

instance/etc/zope.ini: $(BIN_FOLDER)/pip ## Create instance configuration
@echo "$(GREEN)==> Create instance configuration$(RESET)"
$(BIN_FOLDER)/pipx run cookiecutter -f --no-input --config-file instance.yaml gh:plone/cookiecutter-zope-instance

.PHONY: config
config: instance/etc/zope.ini

.PHONY: build-dev
build-dev: config ## Install Plone packages
@echo "$(GREEN)==> Setup Build$(RESET)"
$(BIN_FOLDER)/mxdev -c mx.ini
$(BIN_FOLDER)/uv pip install -r requirements-mxdev.txt

.PHONY: install
install: build-dev ## Install Plone

.PHONY: build
build: build-dev ## Install Plone

.PHONY: clean
clean: ## Clean environment
@echo "$(RED)==> Cleaning environment and build$(RESET)"
rm -rf $(VENV_FOLDER) pyvenv.cfg .installed.cfg instance .tox .venv .pytest_cache

.PHONY: start
start: ## Start a Plone instance on localhost:8080
PYTHONWARNINGS=ignore $(BIN_FOLDER)/runwsgi instance/etc/zope.ini

.PHONY: console
console: instance/etc/zope.ini ## Start a console into a Plone instance
PYTHONWARNINGS=ignore $(BIN_FOLDER)/zconsole debug instance/etc/zope.conf
Loading

0 comments on commit 738692c

Please sign in to comment.