Commit 0112f134 authored by Daniele Venzano's avatar Daniele Venzano

Add memcached zapp

parent 74a41a35
Pipeline #4028 failed with stage
in 15 seconds
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
.idea/
state.zoe
/zoe*.conf
zoepass.csv
stages:
- deploy
variables:
VERSION: $CI_BUILD_ID
images:
image: docker:latest
stage: deploy
before_script:
- mkdir -p /etc/docker/certs.d/$DOCKER_REGISTRY
- cp /registry-ca.crt /etc/docker/certs.d/$DOCKER_REGISTRY/ca.crt
- mkdir -p $HOME/.docker
- echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
- apk update
- apk add python findutils bash
script:
- bash build_all.sh
- python gen_json.py
artifacts:
paths:
- "*.json"
only:
- master
#!/usr/bin/env bash
set -e
if [ ! -d docker ]; then
exit
fi
REPOSITORY=${REPOSITORY:-zapps}
DOCKER_REGISTRY=${DOCKER_REGISTRY:-docker-registry:5000}
VERSION=${VERSION:-`date +%Y%m%d%H%M%S`}
built_images=''
for d in `find docker -mindepth 1 -maxdepth 1 -type d -printf '%f '`; do
pushd docker/${d}
docker build -t ${DOCKER_REGISTRY}/${REPOSITORY}/${d}:${VERSION} .
docker push ${DOCKER_REGISTRY}/${REPOSITORY}/${d}:${VERSION}
popd
built_images+="${DOCKER_REGISTRY}/${REPOSITORY}/${d}:${VERSION}\n"
done
echo "-------------END SCRIPT-----------------"
echo "Images built:"
printf ${built_images}
echo
# Copyright (c) 2016, Daniele Venzano
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Spark-Jupyter Zoe application description generator."""
import json
import sys
import os
APP_NAME = 'spark-jupyter'
ZOE_APPLICATION_DESCRIPTION_VERSION = 3
options = {
'memory_limit': {
'value': 512 * (1024**2),
'description': 'Memcached memory limit (bytes)'
}
}
REGISTRY = os.getenv("DOCKER_REGISTRY", default="docker-engine:5000")
REPOSITORY = os.getenv("REPOSITORY", default="zapps")
VERSION = os.getenv("VERSION", default="latest")
IMAGE = "memcached:alpine"
def memcached_service(memory_limit):
"""
:rtype: dict
"""
mem_limit_mb = memory_limit / (1024**2)
service = {
'name': "memcached",
'image': IMAGE,
'monitor': True,
'resources': {
"memory": {
"min": mem_limit,
"max": mem_limit
},
"cores": {
"min": 1,
"max": 1
}
}
'ports': [
{
'name': "Memcached port",
'protocol': 'tcp',
'port_number': 11211,
'url_template': '{ip_port}'
}
],
'environment': [],
'volumes': [],
'command': 'memcached -m {}m'.format(mem_limit_mb),
'total_count': 1,
'essential_count': 1,
'startup_order': 0
}
return service
if __name__ == '__main__':
app = {
'name': APP_NAME,
'version': ZOE_APPLICATION_DESCRIPTION_VERSION,
'will_end': False,
'size': 1024,
'services': [
memcached_service(options["memory_limit"]["value"])
]
}
json.dump(app, open("memcached.json", "w"), sort_keys=True, indent=4)
print("ZApp written")
icon.png

9.09 KB

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment