Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add images for 6.0.0a3 and 5.2.7 #49

Merged
merged 1 commit into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions 5.2/5.2.7/Dockerfile.python38
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM python:3.8-slim-buster as base
FROM base as builder

ENV PIP_PARAMS="--use-deprecated legacy-resolver"
ENV PLONE_VERSION=5.2.7
ENV PLONE_VOLTO="plone.volto==3.1.0a4"
ENV EXTRA_PACKAGES="relstorage==3.4.5 psycopg2==2.9.3 python-ldap==3.4.0"

RUN mkdir /wheelhouse

RUN apt-get update \
&& buildDeps="dpkg-dev gcc libbz2-dev libc6-dev libffi-dev libjpeg62-turbo-dev libldap2-dev libopenjp2-7-dev libpcre3-dev libpq-dev libsasl2-dev libssl-dev libtiff5-dev libxml2-dev libxslt1-dev wget zlib1g-dev python3-dev build-essential" \
&& apt-get install -y --no-install-recommends $buildDeps\
&& rm -rf /var/lib/apt/lists/* /usr/share/doc

RUN pip wheel Paste Plone ${PLONE_VOLTO} ${EXTRA_PACKAGES} -c https://dist.plone.org/release/$PLONE_VERSION/constraints.txt ${PIP_PARAMS} --wheel-dir=/wheelhouse

FROM base

ENV PIP_PARAMS="--use-deprecated legacy-resolver"
ENV PIP_VERSION=21.3

LABEL maintainer="Plone Community <dev@plone.org>" \
org.label-schema.name="plone-backend" \
org.label-schema.description="Plone backend image image using Python 3.8" \
org.label-schema.vendor="Plone Foundation" \
org.label-schema.docker.cmd="docker run -d -p 8080:8080 plone/plone-backend:5.2.6-python38"

COPY --from=builder /wheelhouse /wheelhouse

RUN useradd --system -m -d /app -U -u 500 plone \
&& runDeps="git libjpeg62 libopenjp2-7 libpq5 libtiff5 libxml2 libxslt1.1 lynx poppler-utils rsync wv busybox gosu" \
&& apt-get update \
&& apt-get install -y --no-install-recommends $runDeps \
&& busybox --install -s \
&& rm -rf /var/lib/apt/lists/* /usr/share/doc \
&& mkdir -p /data/filestorage /data/blobstorage /data/log /data/cache

WORKDIR /app

RUN python -m venv . \
&& ./bin/pip install -U "pip==${PIP_VERSION}" \
&& ./bin/pip install --force-reinstall --no-index --no-deps ${PIP_PARAMS} /wheelhouse/* \
&& find . \( -type f -a -name '*.pyc' -o -name '*.pyo' \) -exec rm -rf '{}' + \
&& rm -rf .cache

COPY skeleton/ /app

RUN ln -s /data var \
&& find /data -not -user plone -exec chown plone:plone {} \+ \
&& find /app -not -user plone -exec chown plone:plone {} \+

EXPOSE 8080
VOLUME /data

HEALTHCHECK --interval=10s --timeout=5s --start-period=30s CMD wget -q http://127.0.0.1:8080/ok -O - | grep OK || exit 1

ENTRYPOINT [ "/app/docker-entrypoint.sh" ]
CMD ["start"]
56 changes: 56 additions & 0 deletions 5.2/5.2.7/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
### 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

IMAGE_NAME=plone/plone-backend
IMAGE_TAG=5.2.6
IMAGE_VARIATIONS=python36 python37 python38
IMAGE_DEFAULT_VARIATION=python38
IMAGE_ADDITIONAL_TAGS=5.2 latest

# 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`

.PHONY: all
all: build-images

# 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: build-images
build-images: ## Build Docker Images
@echo "Building $(IMAGE_NAME):$(IMAGE_TAG)"
$(foreach VARIATION,$(IMAGE_VARIATIONS),docker build . -t $(IMAGE_NAME):$(IMAGE_TAG)-${VARIATION} -f Dockerfile.${VARIATION};)

.PHONY: push-images
tag-images: ## Tag images
@echo "Tag $(IMAGE_NAME):$(IMAGE_TAG)-${IMAGE_DEFAULT_VARIATION} as $(IMAGE_NAME):$(IMAGE_TAG)"
@docker tag $(IMAGE_NAME):$(IMAGE_TAG)-${IMAGE_DEFAULT_VARIATION} $(IMAGE_NAME):$(IMAGE_TAG)
@echo "Tag $(IMAGE_NAME):$(IMAGE_TAG) with additional tags, if any"
$(foreach TAG,$(IMAGE_ADDITIONAL_TAGS),docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(IMAGE_NAME):$(TAG);)

.PHONY: push-images
push-images: ## Push docker image to dockerhub
@echo "Push $(IMAGE_NAME):$(IMAGE_TAG) to Docker Hub"
@docker push $(IMAGE_NAME):$(IMAGE_TAG)
@echo "Push $(IMAGE_NAME):$(IMAGE_TAG) additional tags to Docker Hub"
$(foreach TAG,$(IMAGE_ADDITIONAL_TAGS),docker push $(IMAGE_NAME):$(TAG);)
@echo "Push all $(IMAGE_NAME):$(IMAGE_TAG) variations to Docker Hub"
$(foreach VARIATION,$(IMAGE_VARIATIONS),docker push $(IMAGE_NAME):$(IMAGE_TAG)-${VARIATION};)

.PHONY: release
release: build-images push-images ## Build and push the image to docker hub
@echo "Releasing $(IMAGE_NAME):$(IMAGE_TAG)"
113 changes: 113 additions & 0 deletions 5.2/5.2.7/skeleton/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/bin/bash
set -e

if [ -z "${PIP_PARAMS}" ]; then
PIP_PARAMS="--use-deprecated legacy-resolver"
fi

# CLIENT HOME
CLIENT_HOME="/data/$(hostname)/$(hostid)"
export CLIENT_HOME=$CLIENT_HOME

USER="$(id -u)"

# Create directories to be used by Plone
mkdir -p /data/filestorage /data/blobstorage /data/cache /data/log $CLIENT_HOME
if [ "$USER" = '0' ]; then
find /data -not -user plone -exec chown plone:plone {} \+
sudo="gosu plone"
else
sudo=""
fi

# MAIN ENV Vars
[ -z ${SECURITY_POLICY_IMPLEMENTATION+x} ] && export SECURITY_POLICY_IMPLEMENTATION=C
[ -z ${VERBOSE_SECURITY+x} ] && export VERBOSE_SECURITY=off
[ -z ${DEFAULT_ZPUBLISHER_ENCODING+x} ] && export DEFAULT_ZPUBLISHER_ENCODING=utf-8
[ -z ${DEBUG_MODE+x} ] && export DEBUG_MODE=off

# ZODB ENV Vars
[ -z ${ZODB_CACHE_SIZE+x} ] && export ZODB_CACHE_SIZE=50000

if [[ -v RELSTORAGE_DSN ]]; then
MSG="Using Relstorage configuration"
CONF=relstorage.conf
# Relstorage ENV Vars
[ -z ${RELSTORAGE_NAME+x} ] && export RELSTORAGE_NAME=storage
[ -z ${RELSTORAGE_READ_ONLY+x} ] && export RELSTORAGE_READ_ONLY=off
[ -z ${RELSTORAGE_KEEP_HISTORY+x} ] && export RELSTORAGE_KEEP_HISTORY=true
[ -z ${RELSTORAGE_COMMIT_LOCK_TIMEOUT+x} ] && export RELSTORAGE_COMMIT_LOCK_TIMEOUT=30
[ -z ${RELSTORAGE_CREATE_SCHEMA+x} ] && export RELSTORAGE_CREATE_SCHEMA=true
[ -z ${RELSTORAGE_SHARED_BLOB_DIR+x} ] && export RELSTORAGE_SHARED_BLOB_DIR=false
[ -z ${RELSTORAGE_BLOB_CACHE_SIZE+x} ] && export RELSTORAGE_BLOB_CACHE_SIZE=100mb
[ -z ${RELSTORAGE_BLOB_CACHE_SIZE_CHECK+x} ] && export RELSTORAGE_BLOB_CACHE_SIZE_CHECK=10
[ -z ${RELSTORAGE_BLOB_CACHE_SIZE_CHECK_EXTERNAL+x} ] && export RELSTORAGE_BLOB_CACHE_SIZE_CHECK_EXTERNAL=false
[ -z ${RELSTORAGE_BLOB_CHUNK_SIZE+x} ] && export RELSTORAGE_BLOB_CHUNK_SIZE=1048576
[ -z ${RELSTORAGE_CACHE_LOCAL_MB+x} ] && export RELSTORAGE_CACHE_LOCAL_MB=10
[ -z ${RELSTORAGE_CACHE_LOCAL_OBJECT_MAX+x} ] && export RELSTORAGE_CACHE_LOCAL_OBJECT_MAX=16384
[ -z ${RELSTORAGE_CACHE_LOCAL_COMPRESSION+x} ] && export RELSTORAGE_CACHE_LOCAL_COMPRESSION=none
[ -z ${RELSTORAGE_CACHE_DELTA_SIZE_LIMIT+x} ] && export RELSTORAGE_CACHE_DELTA_SIZE_LIMIT=100000
elif [[ -v ZEO_ADDRESS ]]; then
MSG="Using ZEO configuration"
CONF=zeo.conf
# Check ZEO variables
[ -z ${ZEO_SHARED_BLOB_DIR+x} ] && export ZEO_SHARED_BLOB_DIR=off
[ -z ${ZEO_READ_ONLY+x} ] && export ZEO_READ_ONLY=false
[ -z ${ZEO_CLIENT_READ_ONLY_FALLBACK+x} ] && export ZEO_CLIENT_READ_ONLY_FALLBACK=false
[ -z ${ZEO_STORAGE+x} ] && export ZEO_STORAGE=1
[ -z ${ZEO_CLIENT_CACHE_SIZE+x} ] && export ZEO_CLIENT_CACHE_SIZE=128MB
[ -z ${ZEO_DROP_CACHE_RATHER_VERIFY+x} ] && export ZEO_DROP_CACHE_RATHER_VERIFY=false
else
MSG="Using default configuration"
CONF=zope.conf
fi

# Handle ADDONS installation
if [[ -v ADDONS ]]; then
echo "======================================================================================="
echo "Installing ADDONS ${ADDONS}"
echo "THIS IS NOT MEANT TO BE USED IN PRODUCTION"
echo "Read about it: https://github.com/plone/plone-backend/#extending-from-this-image"
echo "======================================================================================="
/app/bin/pip install ${ADDONS} ${PIP_PARAMS}
fi

# Handle development addons
if [[ -v DEVELOP ]]; then
echo "======================================================================================="
echo "Installing DEVELOPment addons ${DEVELOP}"
echo "THIS IS NOT MEANT TO BE USED IN PRODUCTION"
echo "Read about it: https://github.com/plone/plone-backend/#extending-from-this-image"
echo "======================================================================================="
/app/bin/pip install --editable ${DEVELOP} ${PIP_PARAMS}
fi

# Handle Site creation
if [[ -v SITE ]]; then
export TYPE=${TYPE:-volto}
echo "======================================================================================="
echo "Creating Plone ${TYPE} SITE: ${SITE}"
echo "Aditional profiles: ${PROFILES}"
echo "THIS IS NOT MEANT TO BE USED IN PRODUCTION"
echo "Read about it: https://github.com/plone/plone-backend/#extending-from-this-image"
echo "======================================================================================="
export SITE_ID=${SITE}
$sudo /app/bin/zconsole run etc/${CONF} /app/scripts/create_site.py
fi

if [[ "$1" == "start" ]]; then
echo $MSG
exec $sudo /app/bin/runwsgi -v etc/zope.ini config_file=${CONF}
elif [[ "$1" == "create-classic" ]]; then
export TYPE=classic
exec $sudo /app/bin/zconsole run etc/${CONF} /app/scripts/create_site.py
elif [[ "$1" == "create-volto" ]]; then
export TYPE=volto
exec $sudo /app/bin/zconsole run etc/${CONF} /app/scripts/create_site.py
elif [[ "$1" == "create-site" ]]; then
export TYPE=volto
exec $sudo /app/bin/zconsole run etc/${CONF} /app/scripts/create_site.py
else
# Custom
exec "$@"
fi
38 changes: 38 additions & 0 deletions 5.2/5.2.7/skeleton/etc/relstorage.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
%define INSTANCE /app
instancehome $INSTANCE

%define CLIENTHOME $(CLIENT_HOME)
clienthome $CLIENTHOME

debug-mode $(DEBUG_MODE)
security-policy-implementation $(SECURITY_POLICY_IMPLEMENTATION)
verbose-security $(VERBOSE_SECURITY)
default-zpublisher-encoding $(DEFAULT_ZPUBLISHER_ENCODING)

<environment>
zope_i18n_compile_mo_files true
CHAMELEON_CACHE $INSTANCE/var/cache
</environment>

<zodb_db main>
# Main database
cache-size $(ZODB_CACHE_SIZE)
%import relstorage
<relstorage>
name $(RELSTORAGE_NAME)
read-only $(RELSTORAGE_READ_ONLY)
keep-history $(RELSTORAGE_KEEP_HISTORY)
commit-lock-timeout $(RELSTORAGE_COMMIT_LOCK_TIMEOUT)
create-schema $(RELSTORAGE_CREATE_SCHEMA)
blob-dir $INSTANCE/var/blobstorage
shared-blob-dir $(RELSTORAGE_SHARED_BLOB_DIR)
blob-cache-size $(RELSTORAGE_BLOB_CACHE_SIZE)
blob-cache-size-check $(RELSTORAGE_BLOB_CACHE_SIZE_CHECK)
blob-cache-size-check-external $(RELSTORAGE_BLOB_CACHE_SIZE_CHECK_EXTERNAL)
blob-chunk-size $(RELSTORAGE_BLOB_CHUNK_SIZE)
<postgresql>
dsn $(RELSTORAGE_DSN)
</postgresql>
</relstorage>
mount-point /
</zodb_db>
20 changes: 20 additions & 0 deletions 5.2/5.2.7/skeleton/etc/site.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:meta="http://namespaces.zope.org/meta"
xmlns:five="http://namespaces.zope.org/five">

<include package="Zope2.App" />

<!-- Load the meta -->
<include files="package-includes/*-meta.zcml" />
<five:loadProducts file="meta.zcml"/>

<!-- Load the configuration -->
<include files="package-includes/*-configure.zcml" />
<five:loadProducts />

<!-- Load the configuration overrides-->
<includeOverrides files="package-includes/*-overrides.zcml" />
<five:loadProductsOverrides />

</configure>
33 changes: 33 additions & 0 deletions 5.2/5.2.7/skeleton/etc/zeo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
%define INSTANCE /app
instancehome $INSTANCE

%define CLIENTHOME $(CLIENT_HOME)
clienthome $CLIENTHOME

debug-mode $(DEBUG_MODE)
security-policy-implementation $(SECURITY_POLICY_IMPLEMENTATION)
verbose-security $(VERBOSE_SECURITY)
default-zpublisher-encoding $(DEFAULT_ZPUBLISHER_ENCODING)

<environment>
zope_i18n_compile_mo_files true
CHAMELEON_CACHE $INSTANCE/var/cache
</environment>

<zodb_db main>
# Main database
cache-size $(ZODB_CACHE_SIZE)
<zeoclient>
name zeostorage
var $INSTANCE/var
blob-dir $INSTANCE/var/blobstorage
read-only $(ZEO_READ_ONLY)
read-only-fallback $(ZEO_CLIENT_READ_ONLY_FALLBACK)
shared-blob-dir $(ZEO_SHARED_BLOB_DIR)
server $(ZEO_ADDRESS)
storage $(ZEO_STORAGE)
cache-size $(ZEO_CLIENT_CACHE_SIZE)
drop-cache-rather-verify $(ZEO_DROP_CACHE_RATHER_VERIFY)
</zeoclient>
mount-point /
</zodb_db>
26 changes: 26 additions & 0 deletions 5.2/5.2.7/skeleton/etc/zope.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
%define INSTANCE /app
instancehome $INSTANCE

debug-mode $(DEBUG_MODE)
security-policy-implementation $(SECURITY_POLICY_IMPLEMENTATION)
verbose-security $(VERBOSE_SECURITY)
default-zpublisher-encoding $(DEFAULT_ZPUBLISHER_ENCODING)

<environment>
zope_i18n_compile_mo_files true
CHAMELEON_CACHE $INSTANCE/var/cache
</environment>

<zodb_db main>
# Main database
cache-size $(ZODB_CACHE_SIZE)
# Blob-enabled FileStorage database
<blobstorage>
blob-dir $INSTANCE/var/blobstorage
# FileStorage database
<filestorage>
path $INSTANCE/var/filestorage/Data.fs
</filestorage>
</blobstorage>
mount-point /
</zodb_db>
Loading