lxc-build + CKAN test

This commit is contained in:
Disassembler 2018-09-05 17:41:38 +02:00
parent c3255cb00d
commit deacaa94be
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
84 changed files with 499 additions and 353 deletions

View File

@ -1,23 +0,0 @@
FROM java
LABEL maintainer="Disassembler <disassembler@dasm.cz>"
RUN \
# Download and install ActiveMQ
wget http://archive.apache.org/dist/activemq/5.15.5/apache-activemq-5.15.5-bin.tar.gz -O /tmp/activemq.tgz \
&& tar xf /tmp/activemq.tgz -C /srv \
&& mv /srv/apache-activemq-5.15.5 /srv/activemq \
&& rm -f /tmp/activemq.tgz \
# Create OS user
&& addgroup -S -g 61616 activemq \
&& adduser -S -u 61616 -h /srv/activemq -s /bin/false -g activemq -G activemq activemq \
&& mkdir /srv/activemq/tmp \
&& chown activemq:activemq /srv/activemq/tmp \
# Configure Java heap size
&& sed -i "s/-Xms64M -Xmx1G/-Xms32M -Xmx256M/" /srv/activemq/bin/env
COPY docker/ /
VOLUME ["/srv/activemq/data"]
EXPOSE 61616
CMD ["s6-svscan", "/etc/services.d"]

View File

@ -1,19 +0,0 @@
#!/sbin/openrc-run
description="ActiveMQ docker container"
depend() {
need docker
}
start() {
/usr/bin/docker run -d --rm \
--name activemq \
-h activemq \
-v /srv/activemq/data:/srv/activemq/data \
activemq
}
stop() {
/usr/bin/docker stop activemq
}

29
activemq/lxcfile Normal file
View File

@ -0,0 +1,29 @@
IMAGE activemq
LAYER shared/alpine
LAYER shared/java
LAYER activemq/activemq
SCRIPT
# Download and install ActiveMQ
wget http://archive.apache.org/dist/activemq/5.15.5/apache-activemq-5.15.5-bin.tar.gz -O /tmp/activemq.tgz
tar xf /tmp/activemq.tgz -C /srv
mv /srv/apache-activemq-5.15.5 /srv/activemq
rm -f /tmp/activemq.tgz
# Create OS user
addgroup -S -g 61616 activemq
adduser -S -u 61616 -h /srv/activemq -s /bin/false -g activemq -G activemq activemq
mkdir /srv/activemq/tmp
chown activemq:activemq /srv/activemq/tmp
# Configure Java heap size
sed -i "s/-Xms64M -Xmx1G/-Xms32M -Xmx256M/" /srv/activemq/bin/env
RUN
COPY lxc/ /
CMD /bin/s6-svscan /etc/services.d
LAYER activemq/delta0
MOUNT /srv/activemq/data srv/activemq/data

5
activemq.sh → activemq/setup.sh Executable file → Normal file
View File

@ -1,10 +1,9 @@
#!/bin/sh
set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/activemq
SOURCE_DIR=$(realpath $(dirname "${0}"))/activemq/setup
# Build Docker container
docker build -t activemq ${SOURCE_DIR}
# Create service
cp ${SOURCE_DIR}/etc/init.d/activemq /etc/init.d/activemq
rc-update -u

View File

@ -0,0 +1,15 @@
#!/sbin/openrc-run
description="ActiveMQ docker container"
depend() {
need lxc
}
start() {
/usr/bin/lxc-start -n activemq
}
stop() {
/usr/bin/lxc-stop -n activemq
}

View File

@ -1,52 +0,0 @@
#!/bin/sh
set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/basic-runtimes
# Build basic Alpine image
mkdir -p /var/lib/lxc/build
mkdir -p /var/lib/lxc/shared/alpine
wget https://github.com/gliderlabs/docker-alpine/raw/2bfe6510ee31d86cfeb2f37587f4cf866f28ffbc/versions/library-3.8/x86_64/rootfs.tar.xz -O - | tar xJf - -C /var/lib/lxc/shared/alpine
touch /var/lib/lxc/shared/alpine/etc/resolv.conf
cp ${SOURCE_DIR}/var/lib/lxc/build/config /var/lib/lxc/build/config
lxc-execute -n build -- /bin/sh -c 'apk --no-cache add s6'
# Build Java overlay
mkdir /var/lib/lxc/shared/java
sed -i 's|^lxc\.rootfs\.path.*|lxc.rootfs.path = overlay:/var/lib/lxc/shared/alpine:/var/lib/lxc/shared/java|' /var/lib/lxc/build/config
lxc-execute -n build -- /bin/sh -c 'apk --no-cache add openjdk8-jre-base'
# Build PHP overlay
mkdir /var/lib/lxc/shared/php
sed -i 's|^lxc\.rootfs\.path.*|lxc.rootfs.path = overlay:/var/lib/lxc/shared/alpine:/var/lib/lxc/shared/php|' /var/lib/lxc/build/config
lxc-execute -n build -- /bin/sh -c 'apk --no-cache add nginx php7 php7-ctype php7-fpm php7-gd php7-json php7-mbstring php7-mcrypt php7-opcache php7-session'
# Build libxml overlay
mkdir /var/lib/lxc/shared/libxml
sed -i 's|^lxc\.rootfs\.path.*|lxc.rootfs.path = overlay:/var/lib/lxc/shared/alpine:/var/lib/lxc/shared/libxml|' /var/lib/lxc/build/config
lxc-execute -n build -- /bin/sh -c 'apk --no-cache add libxml2 libxslt'
# Build Python2 overlay
mkdir /var/lib/lxc/shared/python2
sed -i 's|^lxc\.rootfs\.path.*|lxc.rootfs.path = overlay:/var/lib/lxc/shared/alpine:/var/lib/lxc/shared/libxml:/var/lib/lxc/shared/python2|' /var/lib/lxc/build/config
lxc-execute -n build -- /bin/sh -c 'apk --no-cache add python2'
# Build Python3 overlay
mkdir /var/lib/lxc/shared/python3
sed -i 's|^lxc\.rootfs\.path.*|lxc.rootfs.path = overlay:/var/lib/lxc/shared/alpine:/var/lib/lxc/shared/libxml:/var/lib/lxc/shared/python3|' /var/lib/lxc/build/config
lxc-execute -n build -- /bin/sh -c 'apk --no-cache add python3 && ln -s /usr/bin/python3 /usr/bin/python'
# Build Ruby overlay
mkdir /var/lib/lxc/shared/ruby
sed -i 's|^lxc\.rootfs\.path.*|lxc.rootfs.path = overlay:/var/lib/lxc/shared/alpine:/var/lib/lxc/shared/ruby|' /var/lib/lxc/build/config
cp -p ${SOURCE_DIR}/ruby.sh /var/lib/lxc/shared/ruby/ruby.sh
lxc-execute -n build -- /ruby.sh
rm /var/lib/lxc/shared/ruby/ruby.sh
# Build Tomcat overlay
mkdir /var/lib/lxc/shared/tomcat
sed -i 's|^lxc\.rootfs\.path.*|lxc.rootfs.path = overlay:/var/lib/lxc/shared/alpine:/var/lib/lxc/shared/java:/var/lib/lxc/shared/tomcat|' /var/lib/lxc/build/config
cp -p ${SOURCE_DIR}/tomcat.sh /var/lib/lxc/shared/tomcat/tomcat.sh
lxc-execute -n build -- /tomcat.sh
rm /var/lib/lxc/shared/tomcat/ruby.sh
cp -rp ${SOURCE_DIR}/tomcat/ /var/lib/lxc/shared/tomcat/

View File

@ -0,0 +1,5 @@
LAYER shared/alpine
SCRIPT
apk --no-cache add s6
RUN

View File

@ -0,0 +1,6 @@
LAYER shared/alpine
LAYER shared/java
SCRIPT
apk --no-cache add openjdk8-jre-base
RUN

View File

@ -0,0 +1,6 @@
LAYER shared/alpine
LAYER shared/libxml
SCRIPT
apk --no-cache add libxml2 libxslt
RUN

View File

@ -0,0 +1,6 @@
LAYER shared/alpine
LAYER shared/php
SCRIPT
apk --no-cache add nginx php7 php7-ctype php7-fpm php7-gd php7-json php7-mbstring php7-mcrypt php7-opcache php7-session
RUN

View File

@ -0,0 +1,7 @@
LAYER shared/alpine
LAYER shared/libxml
LAYER shared/python2
SCRIPT
apk --no-cache add python2
RUN

View File

@ -0,0 +1,8 @@
LAYER shared/alpine
LAYER shared/libxml
LAYER shared/python2
SCRIPT
apk --no-cache add python3
ln -s /usr/bin/python3 /usr/bin/python
RUN

View File

@ -0,0 +1,39 @@
LAYER shared/alpine
LAYER shared/ruby
SCRIPT
# Install Ruby runtime dependencies
apk --no-cache add gdbm libressl readline zlib
# Install Ruby build dependencies
apk --no-cache add --virtual .deps build-base autoconf gdbm-dev libressl-dev linux-headers readline-dev zlib-dev
# Download and unpack Ruby
wget http://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.6.tar.xz -O ruby.tar.xz
mkdir -p /usr/src/ruby
tar xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1
rm ruby.tar.xz
cd /usr/src/ruby
# Hackfix to suppress "Insecure world writable dir" warning
sed -ni 'p;13a #define ENABLE_PATH_CHECK 0' file.c
# Configure compilation + hackfix to detect isnan/isinf macros
autoconf
ac_cv_func_isnan=yes ac_cv_func_isinf=yes ./configure --build=x86_64-linux-musl --disable-install-doc --enable-shared
# Compile and install Ruby
make -j $(nproc)
make install
# Install RubyGems and Bundler
mkdir -p /usr/local/etc
echo -e 'install: --no-document\nupdate: --no-document' >/usr/local/etc/gemrc
gem update --system
# Cleanup
cd /tmp
rm -r /usr/src/ruby
apk --no-cache del .deps
rm -rf /root/.gem
RUN

View File

@ -1,34 +0,0 @@
# Install Ruby runtime dependencies
apk --no-cache add gdbm libressl readline zlib
# Install Ruby build dependencies
apk --no-cache add --virtual .deps build-base autoconf gdbm-dev libressl-dev linux-headers readline-dev zlib-dev
# Download and unpack Ruby
wget http://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.6.tar.xz -O ruby.tar.xz
mkdir -p /usr/src/ruby
tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1
rm ruby.tar.xz
cd /usr/src/ruby
# Hackfix to suppress "Insecure world writable dir" warning
sed -ni 'p;13a #define ENABLE_PATH_CHECK 0' file.c
# Configure compilation + hackfix to detect isnan/isinf macros
autoconf
ac_cv_func_isnan=yes ac_cv_func_isinf=yes ./configure --build=x86_64-linux-musl --disable-install-doc --enable-shared
# Compile and install Ruby
make -j $(nproc)
make install
# Install RubyGems and Bundler
mkdir -p /usr/local/etc
echo -e 'install: --no-document\nupdate: --no-document' >/usr/local/etc/gemrc
gem update --system
# Cleanup
cd /tmp
rm -r /usr/src/ruby
apk --no-cache del .deps
rm -rf /root/.gem

View File

@ -0,0 +1,19 @@
LAYER shared/alpine
LAYER shared/java
LAYER shared/tomcat
SCRIPT
# Install Tomcat 8
wget http://mirror.hosting90.cz/apache/tomcat/tomcat-8/v8.0.53/bin/apache-tomcat-8.0.53.tar.gz -O /tmp/apache-tomcat-8.tgz
tar xf /tmp/apache-tomcat-8.tgz -C /srv
mv /srv/apache-tomcat-8.0.53 /srv/tomcat
# Make catalina.sh available globally
ln -s /srv/tomcat/bin/catalina.sh /usr/bin/catalina.sh
# Cleanup
rm -rf /srv/tomcat/webapps/ROOT /srv/tomcat/webapps/docs /srv/tomcat/webapps/examples /srv/tomcat/webapps/host-manager /srv/tomcat/webapps/manager
rm -f /tmp/apache-tomcat-8.tgz
RUN
COPY lxc-tomcat/ /

View File

@ -1,11 +0,0 @@
# Install Tomcat 8
wget http://mirror.hosting90.cz/apache/tomcat/tomcat-8/v8.0.53/bin/apache-tomcat-8.0.53.tar.gz -O /tmp/apache-tomcat-8.tgz
tar xf /tmp/apache-tomcat-8.tgz -C /srv
mv /srv/apache-tomcat-8.0.53 /srv/tomcat
# Make catalina.sh available globally
ln -s /srv/tomcat/bin/catalina.sh /usr/bin/catalina.sh
# Cleanup
rm -rf /srv/tomcat/webapps/ROOT /srv/tomcat/webapps/docs /srv/tomcat/webapps/examples /srv/tomcat/webapps/host-manager /srv/tomcat/webapps/manager
rm -f /tmp/apache-tomcat-8.tgz

View File

@ -1,24 +0,0 @@
# Hostname
lxc.uts.name = build
# Network
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.ipv4.address = 172.17.0.2/16
lxc.net.0.ipv4.gateway = auto
# Volumes
lxc.rootfs.path = /var/lib/lxc/shared/alpine
# Mounts
lxc.mount.entry = /etc/hosts etc/hosts none bind 0 0
lxc.mount.entry = /etc/resolv.conf etc/resolv.conf none bind 0 0
# Halt
lxc.signal.halt = SIGTERM
# Other
lxc.arch = x86_64
lxc.cap.drop = sys_admin
lxc.include = /usr/share/lxc/config/alpine.common.conf

View File

@ -1,6 +0,0 @@
FROM alpine:3.8
LABEL maintainer="Disassembler <disassembler@dasm.cz>"
RUN \
# Install S6 supervisor
apk --no-cache add s6

27
build-all.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))
# Build basic Alpine LXC image
mkdir -p /var/lib/lxc/shared/alpine
wget https://github.com/gliderlabs/docker-alpine/raw/2bfe6510ee31d86cfeb2f37587f4cf866f28ffbc/versions/library-3.8/x86_64/rootfs.tar.xz -O - | tar xJf - -C /var/lib/lxc/shared/alpine
touch /var/lib/lxc/shared/alpine/etc/resolv.conf
lxc-build ${SOURCE_DIR}/basic-runtimes/alpine.lxcfile
# Build runtime overlays
lxc-build ${SOURCE_DIR}/basic-runtimes/java.lxcfile
lxc-build ${SOURCE_DIR}/basic-runtimes/libxml.lxcfile
#lxc-build ${SOURCE_DIR}/basic-runtimes/php.lxcfile
lxc-build ${SOURCE_DIR}/basic-runtimes/python2.lxcfile
lxc-build ${SOURCE_DIR}/basic-runtimes/python3.lxcfile
#lxc-build ${SOURCE_DIR}/basic-runtimes/ruby.lxcfile
#lxc-build ${SOURCE_DIR}/basic-runtimes/tomcat.lxcfile
# Build applications
lxc-build ${SOURCE_DIR}/activemq
lxc-build ${SOURCE_DIR}/ckan
lxc-build ${SOURCE_DIR}/ckan-datapusher
lxc-build ${SOURCE_DIR}/postgres
lxc-build ${SOURCE_DIR}/redis
lxc-build ${SOURCE_DIR}/solr

View File

@ -1,33 +0,0 @@
FROM python2
LABEL maintainer="Disassembler <disassembler@dasm.cz>"
RUN \
# Install runtime dependencies
apk --no-cache add libffi libressl uwsgi-python
RUN \
# Install build dependencies
apk --no-cache add --virtual .deps build-base git libffi-dev libressl-dev libxml2-dev libxslt-dev py2-pip python2-dev \
# Install CKAN DataPusher
&& mkdir -p /srv/ckan-datapusher \
&& cd /srv/ckan-datapusher \
&& pip install -U setuptools \
&& pip install -e 'git+https://github.com/ckan/datapusher.git#egg=datapusher' \
# Hackfix the X509_STORE_CTX wrapper
&& sed -i 's/\[security\]//' /srv/ckan-datapusher/src/datapusher/requirements.txt \
&& pip install -r /srv/ckan-datapusher/src/datapusher/requirements.txt \
# Create OS user
&& addgroup -S -g 8004 ckandp \
&& adduser -S -u 8004 -h /srv/ckan-datapusher -s /bin/false -g ckandp -G ckandp ckandp \
&& chown -R ckandp:ckandp /srv/ckan-datapusher \
# Cleanup
&& apk --no-cache del .deps \
&& find /srv/ckan-datapusher/src -name '.git*' -exec rm -rf {} + \
&& rm -rf /root/.cache
COPY docker/ /
VOLUME ["/etc/ckan-datapusher", "/srv/ckan-datapusher/data"]
EXPOSE 8080
CMD ["s6-svscan", "/etc/services.d"]

44
ckan-datapusher/lxcfile Normal file
View File

@ -0,0 +1,44 @@
IMAGE ckan-datapusher
LAYER shared/alpine
LAYER shared/libxml
LAYER shared/python2
LAYER ckan-datapusher/ckan-datapusher
SCRIPT
# Install runtime dependencies
apk --no-cache add libffi libressl uwsgi-python
# Install build dependencies
apk --no-cache add --virtual .deps build-base git libffi-dev libressl-dev libxml2-dev libxslt-dev py2-pip python2-dev
# Install CKAN DataPusher
mkdir -p /srv/ckan-datapusher
cd /srv/ckan-datapusher
pip install -U setuptools
pip install -e 'git+https://github.com/ckan/datapusher.git#egg=datapusher'
# Hackfix the X509_STORE_CTX wrapper
sed -i 's/\[security\]//' /srv/ckan-datapusher/src/datapusher/requirements.txt
pip install -r /srv/ckan-datapusher/src/datapusher/requirements.txt
# Prepare mountpoint for selfsigned certificate
touch /etc/ssl/services.pem
# Create OS user
addgroup -S -g 8004 ckandp
adduser -S -u 8004 -h /srv/ckan-datapusher -s /bin/false -g ckandp -G ckandp ckandp
chown -R ckandp:ckandp /srv/ckan-datapusher
# Cleanup
apk --no-cache del .deps
find /srv/ckan-datapusher/src -name '.git*' -exec rm -rf {} +
rm -rf /root/.cache
RUN
COPY lxc/ /
VOLUME /etc/ssl/services.pem etc/ssl/services.pem
VOLUME /srv/ckan-datapusher/conf etc/ckan-datapusher
VOLUME /srv/ckan-datapusher/data srv/ckan-datapusher/data
CMD /bin/s6-svscan /etc/services.d

View File

@ -4,7 +4,6 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/ckan-datapusher
# Build Docker container
docker build -t ckan-datapusher ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/ckan-datapusher /etc/init.d/ckan-datapusher
rc-update -u

View File

@ -1,46 +0,0 @@
FROM python2
LABEL maintainer="Disassembler <disassembler@dasm.cz>"
RUN \
# Add edge/testing repository
echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing' >>/etc/apk/repositories \
# Install runtime dependencies
&& apk --no-cache add geos@edge libjpeg-turbo libmagic libpq mailcap py2-pip zlib
RUN \
# Install build dependencies
apk --no-cache add --virtual .deps build-base git libjpeg-turbo-dev libxml2-dev libxslt-dev postgresql-dev python2-dev zlib-dev \
# Hackfix for python find_library('c') call
&& ln -s /lib/ld-musl-x86_64.so.1 /lib/libc.so.1 \
# Install CKAN
&& mkdir -p /srv/ckan \
&& cd /srv/ckan \
&& pip install -U setuptools \
&& pip install flask-debugtoolbar \
&& pip install -e 'git+https://github.com/ckan/ckan.git#egg=ckan' \
&& pip install -r /srv/ckan/src/ckan/requirements.txt \
# Install CKAN extensions
&& pip install -e 'git+https://github.com/ckan/ckanext-basiccharts#egg=ckanext_basiccharts' \
&& pip install -e 'git+https://github.com/ckan/ckanext-spatial#egg=ckanext_spatial' \
&& pip install -e 'git+https://github.com/ckan/ckanext-geoview#egg=ckanext_geoview' \
&& pip install -e 'git+https://github.com/ckan/ckanext-mapviews#egg=ckanext_mapviews' \
&& pip install -e 'git+https://github.com/XVTSolutions/ckanext-spatialUI#egg=ckanext_spatialui' \
&& pip install -e 'git+https://github.com/aptivate/ckanext-datasetthumbnail#egg=ckanext_datasetthumbnail' \
&& pip install -e 'git+https://github.com/datagvat/ckanext-dgvat_xls#egg=ckanext_dgvat_xls' \
&& pip install -r /srv/ckan/src/ckanext-spatial/pip-requirements.txt \
&& pip install -r /srv/ckan/src/ckanext-dgvat-xls/requirements.txt \
# Create OS user
&& addgroup -S -g 8003 ckan \
&& adduser -S -u 8003 -h /srv/ckan -s /bin/false -g ckan -G ckan ckan \
&& chown -R ckan:ckan /srv/ckan \
# Cleanup
&& apk --no-cache del .deps \
&& find /srv/ckan/src -name '.git*' -exec rm -rf {} + \
&& rm -rf /root/.cache
COPY docker/ /
VOLUME ["/etc/ckan", "/srv/ckan/storage"]
EXPOSE 8080
CMD ["s6-svscan", "/etc/services.d"]

55
ckan/lxcfile Normal file
View File

@ -0,0 +1,55 @@
IMAGE ckan
LAYER shared/alpine
LAYER shared/libxml
LAYER shared/python2
LAYER ckan/ckan
SCRIPT
# Add edge/testing repository
echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing' >>/etc/apk/repositories
# Install runtime dependencies
apk --no-cache add geos@edge libjpeg-turbo libmagic libpq mailcap py2-pip zlib
# Install build dependencies
apk --no-cache add --virtual .deps build-base git libjpeg-turbo-dev libxml2-dev libxslt-dev postgresql-dev python2-dev zlib-dev
# Hackfix for python find_library('c') call
ln -s /lib/ld-musl-x86_64.so.1 /lib/libc.so.1
# Install CKAN
mkdir -p /srv/ckan
cd /srv/ckan
pip install -U setuptools
pip install flask-debugtoolbar
pip install -e 'git+https://github.com/ckan/ckan.git#egg=ckan'
pip install -r /srv/ckan/src/ckan/requirements.txt
# Install CKAN extensions
pip install -e 'git+https://github.com/ckan/ckanext-basiccharts#egg=ckanext_basiccharts'
pip install -e 'git+https://github.com/ckan/ckanext-spatial#egg=ckanext_spatial'
pip install -e 'git+https://github.com/ckan/ckanext-geoview#egg=ckanext_geoview'
pip install -e 'git+https://github.com/ckan/ckanext-mapviews#egg=ckanext_mapviews'
pip install -e 'git+https://github.com/XVTSolutions/ckanext-spatialUI#egg=ckanext_spatialui'
pip install -e 'git+https://github.com/aptivate/ckanext-datasetthumbnail#egg=ckanext_datasetthumbnail'
pip install -e 'git+https://github.com/datagvat/ckanext-dgvat_xls#egg=ckanext_dgvat_xls'
pip install -r /srv/ckan/src/ckanext-spatial/pip-requirements.txt
pip install -r /srv/ckan/src/ckanext-dgvat-xls/requirements.txt
# Create OS user
addgroup -S -g 8003 ckan
adduser -S -u 8003 -h /srv/ckan -s /bin/false -g ckan -G ckan ckan
chown -R ckan:ckan /srv/ckan
# Cleanup
apk --no-cache del .deps
find /srv/ckan/src -name '.git*' -exec rm -rf {} +
rm -rf /root/.cache
RUN
COPY lxc/ /
MOUNT /srv/ckan/conf etc/ckan
MOUNT /srv/ckan/data srv/ckan/storage
CMD /bin/s6-svscan /etc/services.d

8
ckan.sh → ckan/setup.sh Executable file → Normal file
View File

@ -4,17 +4,11 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/ckan
# Check prerequisites
docker image ls | grep -q ckan-datapusher || $(realpath $(dirname "${0}"))/ckan-datapusher.sh
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
docker image ls | grep -q redis || $(realpath $(dirname "${0}"))/redis.sh
docker image ls | grep -q solr || $(realpath $(dirname "${0}"))/solr.sh
service postgres start
service redis start
service solr start
# Build Docker container
docker build -t ckan ${SOURCE_DIR}
# Install service
cp ${SOURCE_DIR}/etc/init.d/ckan /etc/init.d/ckan
rc-update -u

View File

@ -4,8 +4,8 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/crisiscleanup
# Check prerequisites
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container

View File

@ -4,7 +4,7 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/cts
# Check prerequisites
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container

View File

@ -4,8 +4,8 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/gnuhealth
# Check prerequisites
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container

View File

@ -4,8 +4,8 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/kanboard
# Check prerequisites
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container

129
lxc-build Executable file
View File

@ -0,0 +1,129 @@
#!/usr/bin/python3
import os
import shutil
import subprocess
import sys
image = 'build'
layers = []
mounts = []
uid = 0
gid = 0
cmd = '/bin/sh'
script = []
in_script = False
LXC_ROOT = '/var/lib/lxc'
CONFIG_TEMPLATE = '''# Image name
lxc.uts.name = {image}
# Network
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.ipv4.address = 172.17.0.2/16
lxc.net.0.ipv4.gateway = auto
# Volumes
lxc.rootfs.path = {rootfs}
# Mounts
lxc.mount.entry = /etc/hosts etc/hosts none bind 0 0
lxc.mount.entry = /etc/resolv.conf etc/resolv.conf none bind 0 0
{mounts}
# Init
lxc.init.cmd = {cmd}
lxc.init.uid = {uid}
lxc.init.gid = {gid}
# Halt
lxc.signal.halt = SIGTERM
# Other
lxc.arch = x86_64
lxc.cap.drop = sys_admin
lxc.include = /usr/share/lxc/config/alpine.common.conf
'''
if os.path.isfile(sys.argv[1]):
lxcfile = os.path.realpath(sys.argv[1])
build_context = os.path.basepath(lxcfile)
else:
build_context = os.path.realpath(sys.argv[1])
lxcfile = os.path.join(build_context, 'lxcfile')
def main():
with open(lxcfile, 'r') as fd:
recipe = fd.readlines()
for line in recipe:
if line == 'RUN':
in_script = False
run_script()
elif in_script and not line and not line.startswith('#'):
script.append()
elif line == 'SCRIPT':
script = []
in_script = True
elif line.startswith('IMAGE'):
image = line.split()[1]
os.makedirs(os.path.join(LXC_ROOT, image), 0o755, True)
elif line.startswith('LAYER'):
layers.append(line.split()[1])
rebuild_config()
fix_world()
elif line.startswith('COPY'):
copy_files(*line.split()[1:2])
elif line.startswith('MOUNT'):
mounts.append(line.split()[1])
rebuild_config()
elif line.startswith('USER'):
uid = line.split()[1]
gid = line.split()[2]
rebuild_config()
elif line.startswith('CMD'):
cmd = line.split()[1]
rebuild_config()
layers.append('{}/delta0'.format(image))
def rebuild_config():
rootfs_layers = [os.path.join(LXC_ROOT, l) for l in layers]
for layer in rootfs_layers:
os.makedirs(layer, 0o755, True)
if len(rootfs_layers) == 1:
rootfs_path = rootfs_layers[0]
else:
rootfs_path = 'overlay:{}'.format(':'.join(rootfs_layers))
mount_entries = '\n'.join(['lxc.mount.entry = {} none bind 0 0'.format(m) for m in mounts])
with open(os.path.join(LXC_ROOT, image, 'config'), 'w') as fd:
fd.write(CONFIG_TEMPLATE.format(image=image, rootfs=rootfs_path, mounts=mount_entries, uid=uid, gid=gid, cmd=cmd))
def fix_world():
world_items = []
last_world = []
for layer in layers[:-1]:
with open(os.path.join(LXC_ROOT, layer, 'etc/apk/world'), 'r') as fd:
last_world = fd.read().splitlines()
world_items.extend(last_world)
world_items = sorted(set(world_items))
if world_items != sorted(last_world):
os.makedirs(os.path.join(LXC_ROOT, layers[-1], 'etc/apk'))
with open(os.path.join(LXC_ROOT, layers[-1], 'etc/apk/world'), 'w') as fd:
fd.writelines(world_items)
def run_script():
script_filename = os.path.join(LXC_ROOT, layers[-1], 'run.sh')
with open(script_filename, 'w') as fd:
fd.write(' && '.join([s for s in script]))
os.chmod(script_filename, 0o700)
subprocess.run(['lxc-execute', '-n', image, '--', '/bin/sh', '-lvc', '/run.sh'], check=True)
os.unlink(script_filename)
def copy_files(src, dst):
src = os.path.join(build_context, src)
dst = os.path.join(LXC_ROOT, layers[-1], dst)
shutil.copytree(src, dst)
if __name__ == '__init__':
main()

View File

@ -4,8 +4,8 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/mifosx
# Check prerequisites
docker image ls | grep -q mariadb || $(realpath $(dirname "${0}"))/mariadb.sh
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
lxc-ls | grep -q mariadb || $(realpath $(dirname "${0}"))/mariadb.sh
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
service mariadb start
# Build Docker container

View File

@ -4,9 +4,9 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/motech
# Check prerequisites
docker image ls | grep -q activemq || $(realpath $(dirname "${0}"))/activemq.sh
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
lxc-ls | grep -q activemq || $(realpath $(dirname "${0}"))/activemq.sh
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container

View File

@ -4,7 +4,7 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/opendatakit-build
# Check prerequisites
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container

View File

@ -4,8 +4,8 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/opendatakit
# Check prerequisites
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
service postgres start
# Build Docker container

View File

@ -4,9 +4,9 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/pandora
# Check prerequisites
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
docker image ls | grep -q rabbitmq || $(realpath $(dirname "${0}"))/rabbitmq.sh
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
lxc-ls | grep -q rabbitmq || $(realpath $(dirname "${0}"))/rabbitmq.sh
service postgres start
service rabbitmq start

View File

@ -1,20 +0,0 @@
FROM alpine:3.8
LABEL maintainer="Disassembler <disassembler@dasm.cz>"
RUN \
# Modify OS user (which will be picked up later by apk add)
sed -i 's/postgres:x:70:70/postgres:x:5432:5432/' /etc/passwd \
&& sed -i 's/postgres:x:70/postgres:x:5432/' /etc/group \
# Add edge/testing repository for postgis support
&& echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing' >>/etc/apk/repositories \
# Install PostgreSQL + PostGIS
&& apk --no-cache add postgresql postgresql-contrib postgis@edge \
# Create socket directory
&& mkdir /run/postgresql \
&& chown postgres:postgres /run/postgresql
VOLUME ["/var/lib/postgresql"]
EXPOSE 5432
USER postgres
CMD ["postgres", "-D", "/var/lib/postgresql"]

24
postgres/lxcfile Normal file
View File

@ -0,0 +1,24 @@
IMAGE postgres
LAYER shared/alpine
LAYER postgres/postgres
SCRIPT
# Modify OS user (which will be picked up later by apk add)
sed -i 's/postgres:x:70:70/postgres:x:5432:5432/' /etc/passwd
sed -i 's/postgres:x:70/postgres:x:5432/' /etc/group
# Add edge/testing repository for postgis support
echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing' >>/etc/apk/repositories
# Install PostgreSQL + PostGIS
apk --no-cache add postgresql postgresql-contrib postgis@edge
# Create socket directory
mkdir /run/postgresql
chown postgres:postgres /run/postgresql
RUN
MOUNT /srv/postgres/data var/lib/postgresql
USER 5432 5432
CMD postgres -D /var/lib/postgresql

View File

@ -4,7 +4,6 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/postgres
# Build Docker container
docker build -t postgres ${SOURCE_DIR}
cp ${SOURCE_DIR}/etc/init.d/postgres /etc/init.d/postgres
rc-update -u

View File

@ -1,15 +0,0 @@
FROM alpine:3.8
LABEL maintainer="Disassembler <disassembler@dasm.cz>"
RUN \
# Create OS user (which will be picked up later by apk add)
addgroup -S -g 6379 redis \
&& adduser -S -u 6379 -h /var/lib/redis -s /bin/false -g redis -G redis redis \
# Install Redis
&& apk --no-cache add redis
VOLUME ["/var/lib/redis"]
EXPOSE 6379
USER redis
CMD ["redis-server", "/etc/redis.conf"]

18
redis/lxcfile Normal file
View File

@ -0,0 +1,18 @@
IMAGE redis
LAYER shared/alpine
LAYER redis/redis
SCRIPT
# Create OS user (which will be picked up later by apk add)
addgroup -S -g 6379 redis
adduser -S -u 6379 -h /var/lib/redis -s /bin/false -g redis -G redis redis
# Install Redis
apk --no-cache add redis
RUN
MOUNT /srv/redis/conf/redis.conf etc/redis.conf
MOUNT /srv/redis/data var/lib/redis
USER 6379 6379
CMD /usr/bin/redis-server /etc/redis.conf

View File

@ -5,8 +5,8 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/sahana-demo
export TEMPLATE=${TEMPLATE:-"default"}
# Check prerequisites
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container

View File

@ -4,8 +4,8 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/sahana
# Check prerequisites
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container

View File

@ -4,8 +4,8 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/sambro
# Check prerequisites
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container

View File

@ -4,8 +4,8 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/seeddms
# Check prerequisites
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
service postgres start
# Build Docker container

View File

@ -4,8 +4,8 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/sigmah
# Check prerequisites
docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
lxc-ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
service postgres start
# Build Docker container

View File

@ -1,28 +0,0 @@
FROM java
LABEL maintainer="Disassembler <disassembler@dasm.cz>"
RUN \
# Install runtime dependencies
apk --no-cache add bash lsof
RUN \
# Download and install Solr
wget http://archive.apache.org/dist/lucene/solr/6.5.1/solr-6.5.1.tgz -O /tmp/solr-6.5.1.tgz \
&& mkdir /opt \
&& tar xzf /tmp/solr-6.5.1.tgz -C /opt/ \
&& mv /opt/solr-6.5.1 /opt/solr \
&& rm -f /tmp/solr-6.5.1.tgz \
# Create OS user
&& addgroup -S -g 8983 solr \
&& adduser -S -u 8983 -h /var/lib/solr -s /bin/false -g solr -G solr solr \
&& chown -R solr:solr /opt/solr/ \
# Copy basic configuration file to data location
&& cp -p /opt/solr/server/solr/solr.xml /var/lib/solr/solr.xml \
# Make start/stop script visible globally
&& ln -s /opt/solr/bin/solr /usr/local/bin/solr
VOLUME ["/var/lib/solr"]
EXPOSE 8983
USER solr
CMD ["solr", "start", "-f"]

29
solr/lxcfile Normal file
View File

@ -0,0 +1,29 @@
IMAGE solr
LAYER shared/alpine
LAYER shared/java
LAYER solr/solr
SCRIPT
# Install runtime dependencies
apk --no-cache add bash lsof
# Download and install Solr
wget http://archive.apache.org/dist/lucene/solr/6.5.1/solr-6.5.1.tgz -O /tmp/solr-6.5.1.tgz
mkdir /opt
tar xzf /tmp/solr-6.5.1.tgz -C /opt/
mv /opt/solr-6.5.1 /opt/solr
rm -f /tmp/solr-6.5.1.tgz
# Create OS user
addgroup -S -g 8983 solr
adduser -S -u 8983 -h /var/lib/solr -s /bin/false -g solr -G solr solr
chown -R solr:solr /opt/solr/
# Copy basic configuration file to data location
cp -p /opt/solr/server/solr/solr.xml /var/lib/solr/solr.xml
RUN
MOUNT /srv/solr/data var/lib/solr
USER 8983 8983
CMD /opt/solr/bin/solr start -f

View File

@ -4,8 +4,8 @@ set -e
SOURCE_DIR=$(realpath $(dirname "${0}"))/ushahidi
# Check prerequisites
docker image ls | grep -q mariadb || $(realpath $(dirname "${0}"))/mariadb.sh
docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
lxc-ls | grep -q mariadb || $(realpath $(dirname "${0}"))/mariadb.sh
lxc-ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh
service mariadb start
# Build Docker container