Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
boulch committed Jul 8, 2021
0 parents commit 1746066
Show file tree
Hide file tree
Showing 21 changed files with 1,085 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
*.egg-info
*.log
*.mo
*.py?
*.swp
# dirs
.idea/
.vscode/
.tox/
bin/
buildout-cache/
devel/
develop-eggs/
dist/*
eggs/
htmlcov/
include/
lib/
lib64
local/
node_modules/
parts/
reports/
share/
src/
var/
# files
.coverage
.installed.cfg
.mr.developer.cfg
Gruntfile.js
buildout.cfg
coverage.json
log.html
output.xml
package.json
package-lock.json
pip-selfcheck.json
pyvenv.cfg
report.html
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
6.0.0a1 (unreleased)
--------------------

- Initial release
[boulch]
85 changes: 85 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
FROM imiobe/base:py3-ubuntu-20.04 as builder
LABEL maintainer="Benoît Suttor <[email protected]>"
ENV PIP=19.3.1 \
ZC_BUILDOUT=2.13.2 \
SETUPTOOLS=45.3.0 \
WHEEL=0.33.6 \
PLONE_MAJOR=5.2 \
PLONE_VERSION=5.2.4

# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
gcc \
git \
libbz2-dev \
libc6-dev \
libffi-dev \
libjpeg62-dev \
libopenjp2-7-dev \
libmemcached-dev \
libpcre3-dev \
libpq-dev \
libreadline-dev \
libssl-dev \
libxml2-dev \
libxslt1-dev \
python3-dev \
python3-pip \
wget \
zlib1g-dev \
&& pip3 install --no-cache-dir pip==$PIP setuptools==$SETUPTOOLS zc.buildout==$ZC_BUILDOUT

WORKDIR /plone
RUN chown imio:imio -R /plone && mkdir /data && chown imio:imio -R /data

COPY --chown=imio eggs /plone/eggs/
COPY --chown=imio *.cfg /plone/
COPY --chown=imio scripts /plone/scripts
RUN su -c "buildout -c prod.cfg -t 30 -N" -s /bin/sh imio

FROM imiobe/base:py3-ubuntu-20.04
ENV PIP=19.3.1 \
ZC_BUILDOUT=2.13.2 \
SETUPTOOLS=45.3.0 \
WHEEL=0.33.6 \
PLONE_MAJOR=5.2 \
PLONE_VERSION=5.2.4 \
ZEO_HOST=db \
ZEO_PORT=8100 \
HOSTNAME_HOST=local \
PROJECT_ID=smartweb

RUN mkdir -p /data/blobstorage && chown imio:imio -R /data
VOLUME /data/blobstorage
WORKDIR /plone

# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends \
libjpeg62 \
libmemcached11 \
libopenjp2-7 \
libpq5 \
libtiff5 \
libxml2 \
libxslt1.1 \
lynx \
netcat \
poppler-utils \
python3-distutils \
rsync \
wv \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN curl -L https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_amd64.deb > /tmp/dumb-init.deb && dpkg -i /tmp/dumb-init.deb && rm /tmp/dumb-init.deb
COPY --chown=imio --from=builder /plone .
COPY --from=builder /usr/local/lib/python3.8/dist-packages /usr/local/lib/python3.8/dist-packages
COPY --chown=imio docker-initialize.py docker-entrypoint.sh /

USER imio
EXPOSE 8080
HEALTHCHECK --interval=1m --timeout=5s --start-period=30s \
CMD nc -z -w5 127.0.0.1 8080 || exit 1

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["console"]
10 changes: 10 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@Library('jenkins-pipeline-scripts') _

dockerDeliveryPipeline (
imageName: "smartweb/news",
productId: "news",
updateStagingRundeckJobId: "4ffee35c-a889-4733-a630-bacd57c82e7f",
updateRundeckJobId: "2a8d6335-a6ed-423f-a85c-4eca6dec5db4",
updateNowRundeckJobId: "2a8d6335-a6ed-423f-a85c-4eca6dec5db4",
suffixEmail: "support-web",
)
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/make
all: buildout

IMAGE_NAME=smartweb/news:latest

buildout.cfg:
ln -fs dev.cfg buildout.cfg

bin/buildout: bin/pip buildout.cfg
bin/pip install -I -r requirements.txt

buildout: bin/instance

bin/instance: bin/buildout
bin/buildout

bin/pip:
python3 -m venv .

run: bin/instance
bin/instance fg

cleanall:
rm -fr develop-eggs downloads eggs parts .installed.cfg lib lib64 include bin .mr.developer.cfg local/ share/

upgrade-steps:
bin/instance -O plone run scripts/run_portal_upgrades.py

eggs: ## Copy eggs from docker image to speed up docker build
-docker run --entrypoint='' docker-staging.imio.be/$(IMAGE_NAME) tar -c -C /plone eggs | tar x
mkdir -p eggs

docker-image: eggs ## Build docker image
docker build --pull --no-cache -t $(IMAGE_NAME) .

lint:
pre-commit run --all
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
buildout.news
-----------------

This is the iMio news (for smartweb) buildout.
9 changes: 9 additions & 0 deletions backup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[buildout]
parts +=
backup

[backup]
recipe = collective.recipe.backup
location = ${buildout:news}/var/backups/filestorage
blob-storage = /data/blobstorage
blobbackuplocation = ${buildout:news}/var/backups/blobstorage
43 changes: 43 additions & 0 deletions base.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[buildout]

show-picked-versions = true

parts =
instance
omelette

extensions =
mr.developer

extends =
versions.cfg
plone6.cfg

find-links +=
https://eggs.imio.be/find-links/common

versions = versions

[instance]
recipe = plone.recipe.zope2instance
zodb-temporary-storage = off
environment-vars =
zope_i18n_compile_mo_files true
TZ Europe/Brussels
eggs =
Plone
imio.news.core
# imio.news.policy
collective.upgrade
zcml =
imio.news.core
# imio.news.policy

[omelette]
recipe = collective.recipe.omelette
eggs = ${instance:eggs}

[debug-products]
eggs =
ipdb
Products.PDBDebugMode
31 changes: 31 additions & 0 deletions dev.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[buildout]
extends =
base.cfg
sources.cfg

extensions =
mr.developer

parts +=
resources

auto-checkout +=
collective.bigbang
imio.news.core
# imio.news.policy
imio.smartweb.common
imio.smartweb.locales
eea.facetednavigation

[instance]
debug-mode = on
verbose-security = on
user = admin:admin
eggs +=
${debug-products:eggs}

[resources]
recipe = zc.recipe.egg
eggs =
plone.staticresources
scripts = plone-compile-resources
61 changes: 61 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
version: '2.1'
volumes:
smartweb_news-blobstorage:
smartweb_news-postgres:
services:
instance:
build:
context: .
dockerfile: Dockerfile
image: smartweb/news:latest
ports:
- "8080:8080"
links:
- postgres:db
depends_on:
- postgres
- reverse-proxy
volumes:
- ./zodbconvert.cfg:/plone/zodbconvert.cfg
- smartweb_news-blobstorage:/data/blobstorage
environment:
- MEMCACHE_SERVER=172.17.0.1
- MEMCACHE_DEFAULT_AGE=10800
- ENV=dev
- CACHING_SERVERS=http://varnish.staging.imio.be:5000
- DOMAINS=localhost
- RELSTORAGE_DB=zope
- RELSTORAGE_USER=zope
- RELSTORAGE_PASSWORD=zope
- RELSTORAGE_HOSTNAME=db
- PROJECT_ID=test
healthcheck:
test: ['CMD', 'nc', '-z', '-w5', '127.0.0.1', '8080']
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.instance.rule=Host(`portal.localhost`)'
- 'traefik.http.services.instance.loadbalancer.server.port=8080'
- "traefik.http.routers.instance.middlewares=add-plone"
- "traefik.http.middlewares.add-plone.addprefix.prefix=/VirtualHostBase/http/portal.localhost:8080/Plone/VirtualHostRoot"
reverse-proxy:
image: traefik:v2.4
command: --api.insecure=true --providers.docker
ports:
- "80:80" # The HTTP port
- "8000:8080" # The Web UI (enabled by --api)
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
postgres:
image: postgres:11.10
environment:
- POSTGRES_DB=zope
- POSTGRES_USER=zope
- POSTGRES_PASSWORD=zope
volumes:
- smartweb_news-postgres:/var/lib/postgresql/data
memcached:
image: memcached:1.5.20
command:
- "-m"
- "1024"
55 changes: 55 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/dumb-init /bin/bash
set -e
COMMANDS="debug help logtail show stop adduser fg kill quit run wait console foreground logreopen reload shell status"
START="start restart zeoserver"
CMD="bin/instance"

python3 /docker-initialize.py
mkdir -p /data/{log,filestorage,blobstorage}
if [ -e "custom.cfg" ]; then
if [ ! -e "bin/develop" ]; then
buildout -c custom.cfg
python3 /docker-initialize.py
fi
fi

if [[ "$1" == "zeo"* ]]; then
CMD="bin/$1"
fi

if [ -z "$HEALTH_CHECK_TIMEOUT" ]; then
HEALTH_CHECK_TIMEOUT=1
fi

if [ -z "$HEALTH_CHECK_INTERVAL" ]; then
HEALTH_CHECK_INTERVAL=1
fi

if [[ $START == *"$1"* ]]; then
_stop() {
$CMD stop
kill -TERM "$child" 2>/dev/null
}

trap _stop SIGTERM SIGINT
$CMD start
$CMD logtail &
child=$!

pid=$($CMD status | sed 's/[^0-9]*//g')
if [ -n "$pid" ]; then
echo "Application running on pid=$pid"
sleep "$HEALTH_CHECK_TIMEOUT"
while kill -0 "$pid" 2>/dev/null; do
sleep "$HEALTH_CHECK_INTERVAL"
done
else
echo "Application didn't start normally. Shutting down!"
_stop
fi
else
if [[ $COMMANDS == *"$1"* ]]; then
exec bin/instance "$@"
fi
exec "$@"
fi
Loading

0 comments on commit 1746066

Please sign in to comment.