Skip to content

Commit 656449b

Browse files
author
John Van de Meulebrouck Brendgard
committed
Dockerified the pyop example app
1 parent 23e627c commit 656449b

File tree

6 files changed

+87
-0
lines changed

6 files changed

+87
-0
lines changed

Dockerfile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM ubuntu:16.04
2+
3+
ENV DEBIAN_FRONTEND noninteractive
4+
5+
RUN /bin/echo -e "deb http://se.archive.ubuntu.com/ubuntu xenial main restricted universe\ndeb http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe\ndeb http://security.ubuntu.com/ubuntu xenial-security main restricted universe" > /etc/apt/sources.list
6+
7+
RUN apt-get update && \
8+
apt-get -y dist-upgrade && \
9+
apt-get -y install \
10+
python3-pip \
11+
python-virtualenv \
12+
libpython3-dev \
13+
python-setuptools \
14+
build-essential \
15+
libffi-dev \
16+
libssl-dev \
17+
iputils-ping \
18+
&& apt-get clean
19+
20+
RUN rm -rf /var/lib/apt/lists/*
21+
22+
RUN adduser --system --no-create-home --shell /bin/false --group pyop
23+
24+
COPY . /opt/pyop/src/
25+
COPY docker/setup.sh /opt/pyop/setup.sh
26+
COPY docker/start.sh /start.sh
27+
RUN /opt/pyop/setup.sh
28+
29+
# Add Dockerfile to the container as documentation
30+
COPY Dockerfile /Dockerfile
31+
32+
WORKDIR /
33+
34+
EXPOSE 9090
35+
36+
CMD ["bash", "/start.sh"]

application.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
example/application.cfg

docker/setup.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
#
3+
# Install all requirements
4+
#
5+
6+
set -e
7+
set -x
8+
9+
PYPI="https://pypi.nordu.net/simple/"
10+
ping -c 1 -q pypiserver.docker && PYPI="http://pypiserver.docker:8080/simple/"
11+
12+
echo "#############################################################"
13+
echo "$0: Using PyPi URL ${PYPI}"
14+
echo "#############################################################"
15+
16+
virtualenv -p python3 /opt/pyop
17+
/opt/pyop/bin/pip install -U pip
18+
19+
# setup.py points to current directory
20+
# so we need to change to the right one.
21+
cd /opt/pyop/src
22+
23+
/opt/pyop/bin/python3 setup.py install
24+
/opt/pyop/bin/pip install Flask
25+
/opt/pyop/bin/pip install gunicorn

docker/start.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
3+
set -e
4+
set -x
5+
6+
. /opt/pyop/bin/activate
7+
8+
# nice to have in docker run output, to check what
9+
# version of something is actually running.
10+
/opt/pyop/bin/pip freeze
11+
12+
export PYTHONPATH=/opt/pyop/src
13+
14+
start-stop-daemon --start \
15+
-c pyop:pyop \
16+
--exec /opt/pyop/bin/gunicorn \
17+
--pidfile /var/run/pyop.pid \
18+
--chdir /opt/pyop/src \
19+
-- \
20+
example.wsgi:app \
21+
-b :9090 \
22+
--certfile example/https.crt \
23+
--keyfile example/https.key
24+

example/__init__.py

Whitespace-only changes.

signing_key.pem

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
example/signing_key.pem

0 commit comments

Comments
 (0)