From eb7ea17fe0bff40096c9df05849eed8a7529958a Mon Sep 17 00:00:00 2001 From: oho Date: Tue, 9 Jan 2018 17:41:25 +0100 Subject: [PATCH] adding extra info for building and running local container --- Docker/program-y/Centos/Dockerfile | 50 ------------------- Docker/program-y/Centos/README.md | 15 ------ .../remote-git-y-bot-flask-rest/README.md | 20 +++++++- .../remote-git-y-bot-webchat/Dockerfile | 7 +-- .../Centos/remote-git-y-bot-webchat/README.md | 20 +++++++- .../Centos/remote-git-y-bot-webchat/launch.sh | 5 +- 6 files changed, 41 insertions(+), 76 deletions(-) delete mode 100644 Docker/program-y/Centos/Dockerfile delete mode 100644 Docker/program-y/Centos/README.md diff --git a/Docker/program-y/Centos/Dockerfile b/Docker/program-y/Centos/Dockerfile deleted file mode 100644 index 5c03b4b5d..000000000 --- a/Docker/program-y/Centos/Dockerfile +++ /dev/null @@ -1,50 +0,0 @@ -############################################################ -# Dockerfile to build program-y Application Containers -# Based on centos and python 3.6 -############################################################ - -# Set the base image to centos -FROM centos - -# File Author / Maintainer -MAINTAINER Olivier HO-A-CHUCK - -# Update the sources list -RUN yum update -y - -# Install basic applications -RUN yum install -y tar git curl nano wget dialog net-tools yum-utils - -# Install Python and Basic Python Tools -RUN yum install -y https://centos7.iuscommunity.org/ius-release.rpm -RUN yum install -y python36u python36u-pip python36u-devel - -# link python3.6 to python3 -RUN ln -s /usr/bin/python3.6 /usr/bin/python3 - -# create program-y user with password=program-y -RUN useradd -m -p program-y program-y - -# get program-y repo source as "program-y" user (could be your own repo with you own bot implementation) -RUN su -c 'git clone https://github.com/keiffster/program-y.git /home/program-y/program-y' - program-y - -# Get pip to download and install requirements: -RUN pip3.6 install -r /home/program-y/program-y/requirements.txt - -# Expose ports for flask API -EXPOSE 5000 - -# Copy the launch script inside the container -# launch.sh is : su -c 'cd /home/program-y/program-y/bots/y-bot/ && /home/program-y/program-y/bots/y-bot/y-bot-flask-rest.sh' - program-y -ADD /launch.sh /home/program-y/program-y/bots/y-bot/launch.sh - -# Set the default directory where CMD will execute -WORKDIR /home/program-y/program-y/bots/y-bot/ - -# Set the default command to execute -# when creating a new container -# Launch y-bot-flask-rest.sh as user "program-y" -# In unix (Linux, Mac OS X, BSD etc) systems, ports less than 1024 can not be bound to by normal users, -# only the root user can bind to those ports. So script like y-bot-webchat.sh would not be usable by -# user program-y unless default port 80 is changes to 8080 for instance -CMD /bin/bash ./launch.sh \ No newline at end of file diff --git a/Docker/program-y/Centos/README.md b/Docker/program-y/Centos/README.md deleted file mode 100644 index 7dad0549d..000000000 --- a/Docker/program-y/Centos/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Docker Config File - -This was created by user [@ohoachuck](https://github.com/ohoachuck) - -His notes/comments are as follows :- - - -I have successfully created a container with Centos linux distribution + Python 3.6 + Program-y. And have uploaded to Docker Store what I believe should be testable by anybody in a minute (given that you have docker installed). Unless something goes wrong, it should be as simple as doing: -```bash -docker pull ohoachuck/program-y-git-y-bot-webchat -docker run -t -i -p 80:80 ohoachuck/program-y-git-y-bot-webchat -``` -to do so I did nothing complicated, and just wrote a simple Dockerfile - -This first Docker exploration might motivate some more experimented folks to move on this ? At least I hope this could help go a bit forward. I will continue my explorations. \ No newline at end of file diff --git a/Docker/program-y/Centos/remote-git-y-bot-flask-rest/README.md b/Docker/program-y/Centos/remote-git-y-bot-flask-rest/README.md index 7dad0549d..a838f7ce8 100644 --- a/Docker/program-y/Centos/remote-git-y-bot-flask-rest/README.md +++ b/Docker/program-y/Centos/remote-git-y-bot-flask-rest/README.md @@ -12,4 +12,22 @@ docker run -t -i -p 80:80 ohoachuck/program-y-git-y-bot-webchat ``` to do so I did nothing complicated, and just wrote a simple Dockerfile -This first Docker exploration might motivate some more experimented folks to move on this ? At least I hope this could help go a bit forward. I will continue my explorations. \ No newline at end of file +This first Docker exploration might motivate some more experimented folks to move on this ? At least I hope this could help go a bit forward. I will continue my explorations. + +## Build your own image + +You can customise the provided simple Dockerfile and build your own image. To do so make sure you are in directory where Dockerfile is. And use docker basic command CLI: +```bash +docker build -t . +``` + +## Run your own container from image + +Once you have built your own imgage run your container for access through port 80 (http://localhost) like so: +```bash +docker run -t -i -p 8080:80 +``` +or alternatively you can choose to map same PORT as the container port 8080 (http://localhost:8080) like so: +```bash +docker run -t -i -p 8080:8080 +``` diff --git a/Docker/program-y/Centos/remote-git-y-bot-webchat/Dockerfile b/Docker/program-y/Centos/remote-git-y-bot-webchat/Dockerfile index f6afe7f7b..803c2d016 100644 --- a/Docker/program-y/Centos/remote-git-y-bot-webchat/Dockerfile +++ b/Docker/program-y/Centos/remote-git-y-bot-webchat/Dockerfile @@ -31,11 +31,8 @@ RUN su -c 'git clone https://github.com/keiffster/program-y.git /home/program-y/ # Get pip to download and install requirements: RUN pip3.6 install -r /home/program-y/program-y/requirements.txt -# Expose ports for webchat if launched as program-y user (access through http://localhost:8080) -# EXPOSE 8080 - -# Expose ports for webchat if launched as root user (access through http://localhost:80) -EXPOSE 80 +# Expose ports for webchat if launched as program-y user +EXPOSE 8080 # Copy the launch script inside the container # launch.sh is : su -c 'cd /home/program-y/program-y/bots/y-bot/ && /home/program-y/program-y/bots/y-bot/y-bot-webchat.sh' - program-y diff --git a/Docker/program-y/Centos/remote-git-y-bot-webchat/README.md b/Docker/program-y/Centos/remote-git-y-bot-webchat/README.md index 7dad0549d..a838f7ce8 100644 --- a/Docker/program-y/Centos/remote-git-y-bot-webchat/README.md +++ b/Docker/program-y/Centos/remote-git-y-bot-webchat/README.md @@ -12,4 +12,22 @@ docker run -t -i -p 80:80 ohoachuck/program-y-git-y-bot-webchat ``` to do so I did nothing complicated, and just wrote a simple Dockerfile -This first Docker exploration might motivate some more experimented folks to move on this ? At least I hope this could help go a bit forward. I will continue my explorations. \ No newline at end of file +This first Docker exploration might motivate some more experimented folks to move on this ? At least I hope this could help go a bit forward. I will continue my explorations. + +## Build your own image + +You can customise the provided simple Dockerfile and build your own image. To do so make sure you are in directory where Dockerfile is. And use docker basic command CLI: +```bash +docker build -t . +``` + +## Run your own container from image + +Once you have built your own imgage run your container for access through port 80 (http://localhost) like so: +```bash +docker run -t -i -p 8080:80 +``` +or alternatively you can choose to map same PORT as the container port 8080 (http://localhost:8080) like so: +```bash +docker run -t -i -p 8080:8080 +``` diff --git a/Docker/program-y/Centos/remote-git-y-bot-webchat/launch.sh b/Docker/program-y/Centos/remote-git-y-bot-webchat/launch.sh index 7fd7b666f..2a79c00e6 100755 --- a/Docker/program-y/Centos/remote-git-y-bot-webchat/launch.sh +++ b/Docker/program-y/Centos/remote-git-y-bot-webchat/launch.sh @@ -1,7 +1,4 @@ #!/bin/bash # Run python sever as program-y user (not root) -#`su -c 'cd /home/program-y/program-y/bots/y-bot/ && /home/program-y/program-y/bots/y-bot/y-bot-webchat.sh' - program-y` - -# Launch Program-y as root, unless default config.yaml file state webchat port is greater than 1024 (ex. 8080) -`cd /home/program-y/program-y/bots/y-bot/ && /home/program-y/program-y/bots/y-bot/y-bot-webchat.sh` \ No newline at end of file +`su -c 'cd /home/program-y/program-y/bots/y-bot/ && /home/program-y/program-y/bots/y-bot/y-bot-webchat.sh' - program-y`