Skip to content

Commit

Permalink
Import demo Dockerfiles and sample project
Browse files Browse the repository at this point in the history
  • Loading branch information
mjj29 committed Sep 3, 2018
1 parent b6bee8d commit f79f5a3
Show file tree
Hide file tree
Showing 14 changed files with 212 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Dockerfile.centos:7
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM centos:7

# Install python from EPEL repository
RUN yum install -y epel-release && yum install -y python36 && alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
ENV AP_PYTHONHOME=/usr

# Add sample project to image
COPY core /opt/apamacore
COPY project /opt/project
COPY launch.sh /opt/launch.sh

# Launch image with correct settings to run project
ENTRYPOINT ["/opt/launch.sh"]
CMD ["correlator", "--config", "/opt/project"]
14 changes: 14 additions & 0 deletions Dockerfile.debian:buster
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM debian:buster

# Install python from main repository
RUN apt-get update && apt-get install -y python3.6 libpython3.6
ENV AP_PYTHONHOME=/usr

# Add sample project to image
COPY core /opt/apamacore
COPY project /opt/project
COPY launch.sh /opt/launch.sh

# Launch image with correct settings to run project
ENTRYPOINT ["/opt/launch.sh"]
CMD ["correlator", "--config", "/opt/project"]
21 changes: 21 additions & 0 deletions Dockerfile.debian:jessie
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM debian:jessie as builder

# download and build Python
RUN apt-get update && apt-get install -y libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev wget
RUN wget -O /root/Python-3.6.6.tar.xz https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz && (cd /root; tar xf Python-3.6.6.tar.xz)
RUN (cd /root/Python-3.6.6; ./configure --enable-optimizations --enable-shared && make -j 8 build_all && make altinstall)

FROM debian:jessie

# Copy built python to fresh image
COPY --from=builder /usr/local /usr/local
ENV AP_PYTHONHOME=/usr/local

# Add sample project to image
COPY core /opt/apamacore
COPY project /opt/project
COPY launch.sh /opt/launch.sh

# Launch image with correct settings to run project
ENTRYPOINT ["/opt/launch.sh"]
CMD ["correlator", "--config", "/opt/project"]
21 changes: 21 additions & 0 deletions Dockerfile.debian:stretch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM debian:stretch as builder

# download and build Python
RUN apt-get update && apt-get install -y libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev wget
RUN wget -O /root/Python-3.6.6.tar.xz https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz && (cd /root; tar xf Python-3.6.6.tar.xz)
RUN (cd /root/Python-3.6.6; ./configure --enable-optimizations --enable-shared && make -j 8 build_all && make altinstall)

FROM debian:jessie

# Copy built python to fresh image
COPY --from=builder /usr/local /usr/local
ENV AP_PYTHONHOME=/usr/local

# Add sample project to image
COPY core /opt/apamacore
COPY project /opt/project
COPY launch.sh /opt/launch.sh

# Launch image with correct settings to run project
ENTRYPOINT ["/opt/launch.sh"]
CMD ["correlator", "--config", "/opt/project"]
14 changes: 14 additions & 0 deletions Dockerfile.opensuse:15.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM opensuse/leap:15.0

# Add Python from default repository
RUN zypper --non-interactive install python3
ENV AP_PYTHONHOME=/usr

# Add sample project to image
COPY core /opt/apamacore
COPY project /opt/project
COPY launch.sh /opt/launch.sh

# Launch image with correct settings to run project
ENTRYPOINT ["/opt/launch.sh"]
CMD ["correlator", "--config", "/opt/project"]
22 changes: 22 additions & 0 deletions Dockerfile.opensuse:42.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM opensuse/leap:42.3 as builder

# download and build Python
RUN zypper --non-interactive install readline-devel sqlite3-devel libbz2-devel zlib-devel libopenssl-devel wget tar gcc make
RUN wget -O /root/Python-3.6.6.tar.xz https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz && (cd /root; tar xf Python-3.6.6.tar.xz)
RUN (cd /root/Python-3.6.6; ./configure --enable-optimizations --enable-shared && make -j 8 build_all && make altinstall)

FROM opensuse/leap:42.3

# Copy built python to fresh image
COPY --from=builder /usr/local /usr/local
ENV AP_PYTHONHOME=/usr/local

# Add sample project to image
COPY core /opt/apamacore
COPY project /opt/project
COPY launch.sh /opt/launch.sh

# Launch image with correct settings to run project
ENTRYPOINT ["/opt/launch.sh"]
CMD ["correlator", "--config", "/opt/project"]

14 changes: 14 additions & 0 deletions Dockerfile.ubuntu:bionic
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ubuntu:bionic

# Install from main repository
RUN apt-get update && apt-get install -y python3.6 libpython3.6
ENV AP_PYTHONHOME=/usr

# Add sample project to image
COPY core /opt/apamacore
COPY project /opt/project
COPY launch.sh /opt/launch.sh

# Launch image with correct settings to run project
ENTRYPOINT ["/opt/launch.sh"]
CMD ["correlator", "--config", "/opt/project"]
16 changes: 16 additions & 0 deletions Dockerfile.ubuntu:xenial
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ubuntu:xenial

# Install from deadsnakes PPA
RUN apt-get update && apt-get install -y software-properties-common && add-apt-repository ppa:deadsnakes/ppa && apt-get update && apt-get install -y python3.6 libpython3.6
ENV AP_PYTHONHOME=/usr

# Add sample project to image
COPY core /opt/apamacore
COPY project /opt/project
COPY launch.sh /opt/launch.sh

# Launch image with correct settings to run project
ENTRYPOINT ["/opt/launch.sh"]
CMD ["correlator", "--config", "/opt/project"]


48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,46 @@
# linux-python-apama-docker
Dockerfiles to demonstrate installing Python on different operating systems and using them with Apama
# Apama core python installation in Docker

This project contains Dockerfile for installing Python 3.6 on various Linux
base images. It also contains a simple Apama project to demonstrate use of
this Python with Apama.

## License

Copyright (c) 2018 Software AG, Darmstadt, Germany and/or its licensors

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.

## Using the Dockerfiles

To use these Dockerfiles you will need a copy of the Apama 10.3 core
installation from [http://www.apamacommunity.com](http://www.apamacommunity.com/). Unpack it into this directory
under a folder named 'core'.

Next, choose one of the following Linux distributions to use as your base image:

* CentOS 7 (Installs Python from EPEL repository)
* Ubuntu Bionic (Installs Python from main repository)
* Debian Buster (Installs Python from main repository)
* OpenSuse Leap 15 (Installs Python from main repository)
* Ubuntu Xenial (Installs Python from a PPA)
* Debian Stretch (Builds Python from source)
* Debian Jessie (Builds Python from source)
* OpenSuse Leap 42 (Builds Python from source)

Once you have chosen the distribution and release to use as a base image, build the image with:

docker build -t projectimage -f Dockerfile.distribution:release .

Once that has completed you can run the demo project in the docker image with:

docker run --rm -t -i projectimage

## Using Python within Apama

For more details about how to use Python within Apama please see the documentation and forums on [http://www.apamacommunity.com](http://www.apamacommunity.com)
4 changes: 4 additions & 0 deletions launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash --
. /opt/apamacore/Apama/bin/apama_env

"$@"
Binary file added project/.test.py.swp
Binary file not shown.
6 changes: 6 additions & 0 deletions project/test.mon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
monitor m {
import "test" as test;
action onload() {
test.helloWorld();
}
}
11 changes: 11 additions & 0 deletions project/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from apama.eplplugin import EPLPluginBase, EPLAction


class test(EPLPluginBase):
def __init__(self, init):
super(test, self).__init__(init)

@EPLAction('action<>')
def helloWorld(self):
self.getLogger().info("Hello World")

9 changes: 9 additions & 0 deletions project/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
eplPlugins:
test:
pythonFile: ${PARENT_DIR}/test.py
class: test

correlator:
initialization:
list:
- ${PARENT_DIR}/test.mon

0 comments on commit f79f5a3

Please sign in to comment.