Skip to content

Commit

Permalink
Merge pull request #11 from mbarde/backend-distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
steffenri authored May 14, 2024
2 parents 103d7b9 + b743677 commit 3828d0e
Show file tree
Hide file tree
Showing 146 changed files with 4,627 additions and 1,017 deletions.
10 changes: 10 additions & 0 deletions backend/CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

<!--
You should *NOT* be adding new change log entries to this file.
You should create a file in the news directory instead.
For helpful instructions, please see:
https://github.com/plone/plone.releaser/blob/master/ADD-A-NEWS-ITEM.rst
-->

<!-- towncrier release notes start -->
File renamed without changes.
28 changes: 14 additions & 14 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# syntax=docker/dockerfile:1
ARG PLONE_VERSION=6.0.10
ARG PLONE_VERSION=6
FROM plone/server-builder:${PLONE_VERSION} as builder

WORKDIR /app

# Add local code
COPY . .
COPY . src/plone.edu

# Install local requirements and pre-compile mo files
RUN <<EOT
set -e
bin/pip install mxdev
mv requirements-docker.txt requirements.txt
sed -i 's/-e src\/plone_edu\[test\]/src\/plone_edu/g' mx.ini
bin/mxdev -c mx.ini
bin/pip install -r requirements-mxdev.txt
mv src/plone.edu/requirements-docker.txt ./requirements.txt
bin/pip install -r requirements.txt
bin/python /compile_mo.py
rm -Rf src/
rm -Rf src/ /compile_mo.py compile_mo.log
EOT

FROM plone/server-prod-config:${PLONE_VERSION}

LABEL maintainer="Plone Foundation <collective@plone.org>" \
org.label-schema.name="plone-edu-backend" \
org.label-schema.description="Plone EDU backend image." \
org.label-schema.vendor="Plone Foundation"
LABEL maintainer="Plone Community <collective@plone.org>" \
org.label-schema.name="ghcr.io/collective/edu" \
org.label-schema.description="A new Plone Distribution" \
org.label-schema.vendor="Plone Community"

# Disable MO Compilation
ENV zope_i18n_compile_mo_files=
# Show only our distributions
ENV ALLOWED_DISTRIBUTIONS=edu

# Copy /app from builder
COPY --from=builder /app /app

RUN <<EOT
set -e
ln -s /data /app/var
EOT
38 changes: 0 additions & 38 deletions backend/Dockerfile.acceptance

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion backend/src/plone_edu/LICENSE.md → backend/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
plone_edu Copyright 2022, Plone Foundatiuon
plone.edu Copyright 2022, Plone Foundatiuon

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
Expand Down
20 changes: 20 additions & 0 deletions backend/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
graft src/plone
graft docs
graft news
graft scripts
graft tests
include .coveragerc
include .dockerignore
include .editorconfig
include *.txt
include *.yml
include *.md
exclude *-mxdev.txt
exclude Dockerfile
exclude *.mo
exclude mx.ini
exclude Makefile
recursive-exclude frontend *
exclude instance.yaml
global-exclude *.pyc
global-exclude .DS_Store
166 changes: 70 additions & 96 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,16 @@ GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`

BACKEND_FOLDER=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

PLONE_VERSION=$$(cat version.txt)

CODE_QUALITY_VERSION=2.1
ifndef LOG_LEVEL
LOG_LEVEL=INFO
endif
CURRENT_USER=$$(whoami)
USER_INFO=$$(id -u ${CURRENT_USER})
LINT=docker run --rm -e LOG_LEVEL="${LOG_LEVEL}" -v "${BACKEND_FOLDER}":/github/workspace plone/code-quality:${CODE_QUALITY_VERSION} check
FORMAT=docker run --rm --user="${USER_INFO}" -e LOG_LEVEL="${LOG_LEVEL}" -v "${BACKEND_FOLDER}":/github/workspace plone/code-quality:${CODE_QUALITY_VERSION} format
# Set distributions still in development
DISTRIBUTIONS="edu"
ALLOWED_DISTRIBUTIONS="edu"

IMAGE_NAME=ghcr.io/collective/plone-edu-backend
# Docker Image name
IMAGE_NAME=ghcr.io/collective/edu
IMAGE_TAG=latest

PLONE6=6.0-latest

# Python checks
PYTHON?=python3

Expand All @@ -42,126 +36,106 @@ 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)
ifeq ($(PYTHON_VERSION_OK),False)
$(error "Need python $(PYTHON_VERSION) >= $(PYTHON_VERSION_MIN)")
endif

BACKEND_FOLDER=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

GIT_FOLDER=$(BACKEND_FOLDER)/.git


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}'

.PHONY: clean
clean: clean-build clean-pyc clean-test clean-venv clean-instance ## remove all build, test, coverage and Python artifacts

.PHONY: clean-instance
clean-instance: ## remove existing instance
rm -fr instance etc inituser var

.PHONY: clean-venv
clean-venv: ## remove virtual environment
rm -fr bin include lib lib64

.PHONY: clean-build
clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -rf {} +

.PHONY: clean-pyc
clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +

.PHONY: clean-test
clean-test: ## remove test and coverage artifacts
rm -f .coverage
rm -fr htmlcov/

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

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

# i18n
bin/i18ndude: bin/pip
@echo "$(GREEN)==> Install translation tools$(RESET)"
bin/pip install i18ndude

.PHONY: i18n
i18n: bin/i18ndude ## Update locales
@echo "$(GREEN)==> Updating locales$(RESET)"
bin/update_locale

# TODO `make build`
# build:

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

.PHONY: format
format: ## Format the codebase according to our standards
@echo "$(GREEN)==> Format codebase$(RESET)"
$(FORMAT)
.PHONY: install
install: build-dev ## Install Plone 6.0

.PHONY: lint
lint: lint-isort lint-black lint-flake8 lint-zpretty ## check code style

.PHONY: lint-black
lint-black: ## validate black formating
$(LINT) black
.PHONY: build
build: build-dev ## Install Plone 6.0

.PHONY: lint-flake8
lint-flake8: ## validate black formating
$(LINT) flake8

.PHONY: lint-isort
lint-isort: ## validate using isort
$(LINT) isort
.PHONY: clean
clean: ## Remove old virtualenv and creates a new one
@echo "$(RED)==> Cleaning environment and build$(RESET)"
rm -rf bin lib lib64 include share etc var inituser pyvenv.cfg .installed.cfg instance .tox .pytest_cache

.PHONY: lint-pyroma
lint-pyroma: ## validate using pyroma
$(LINT) pyroma
.PHONY: start
start: ## Start a Plone instance on localhost:8080
DEVELOP_DISTRIBUTIONS=$(DISTRIBUTIONS) ALLOWED_DISTRIBUTIONS=$(DISTRIBUTIONS) PYTHONWARNINGS=ignore ./bin/runwsgi instance/etc/zope.ini

.PHONY: lint-zpretty
lint-zpretty: ## validate ZCML/XML using zpretty
$(LINT) zpretty
.PHONY: console
console: ## Start a zope console
DEVELOP_DISTRIBUTIONS=$(DISTRIBUTIONS) ALLOWED_DISTRIBUTIONS=$(DISTRIBUTIONS) PYTHONWARNINGS=ignore ./bin/zconsole debug instance/etc/zope.conf

.PHONY: test
test: ## run tests
bin/pytest src/plone_edu/tests
.PHONY: create-site
create-site: ## Create a new site using default distribution and default answers
DEVELOP_DISTRIBUTIONS=$(DISTRIBUTIONS) ALLOWED_DISTRIBUTIONS=$(DISTRIBUTIONS) PYTHONWARNINGS=ignore ./bin/zconsole run instance/etc/zope.conf scripts/create-site.py

.PHONY: apply-content
apply-content: ## Apply distribution content and override any content that might be present
DELETE_EXISTING=1 make create-site

.PHONY: test_quiet
test_quiet: ## run tests removing deprecation warnings
bin/pytest --disable-warnings src/plone_edu/tests
.PHONY: fetch-content
fetch-content: ## Export content to filesystem
curl -i -X GET http://localhost:8080/Plone/@@dist_export_all --user admin:admin

.PHONY: create-site
create-site: instance/etc/zope.ini ## Create a new site from scratch
PYTHONWARNINGS=ignore ./bin/zconsole run instance/etc/zope.conf ./scripts/create_site.py
.PHONY: format
format: bin/tox ## Format the codebase according to our standards
@echo "$(GREEN)==> Format codebase$(RESET)"
bin/tox -e format

.PHONY: start
start: ## Start a Plone instance on localhost:8080
PYTHONWARNINGS=ignore ./bin/runwsgi instance/etc/zope.ini
.PHONY: lint
lint: ## check code style
bin/tox -e lint

.PHONY: debug
debug: instance/etc/zope.ini ## Run debug console
PYTHONWARNINGS=ignore ./bin/zconsole debug instance/etc/zope.conf
# i18n
bin/i18ndude: bin/pip
@echo "$(GREEN)==> Install translation tools$(RESET)"
bin/pip install i18ndude

.PHONY: i18n
i18n: bin/i18ndude ## Update locales
@echo "$(GREEN)==> Updating locales$(RESET)"
bin/update_dist_locale

# Tests
.PHONY: test
test: bin/tox ## run tests
DEVELOP_DISTRIBUTIONS=$(DISTRIBUTIONS) bin/tox -e test

.PHONY: test-coverage
test-coverage: bin/tox ## run tests with coverage
DEVELOP_DISTRIBUTIONS=$(DISTRIBUTIONS) bin/tox -e coverage

# Docker image
.PHONY: build-image
build-image: ## Build Docker Image
@DOCKER_BUILDKIT=1 docker build . -t $(IMAGE_NAME):$(IMAGE_TAG) -f Dockerfile --build-arg PLONE_VERSION=$(PLONE_VERSION)

.PHONY: run-image
run-image: build-image ## Build Docker Image
docker run --rm -it -p 8080:8080 $(IMAGE_NAME):$(IMAGE_TAG)
Loading

0 comments on commit 3828d0e

Please sign in to comment.