Skip to content

Commit 88298c8

Browse files
committed
Cleanup onbuild docker file.
Fix issue with chmod not being able to run in onbuild - now using python to launch the main file Smart use of copy (requirements.txt* Dockerfile) to make sure we specific files in docker build process before copying all files. By using requirements.txt* Dockerfile we will make sure we always copy a file (Dockerfile) and the copy operation will not fail. Added more documentation on how to use onbuild.
1 parent edf58e6 commit 88298c8

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
FROM ubuntu:16.04
2-
MAINTAINER Rob Kooper <[email protected]>
32

43
# environment variables
54
ENV RABBITMQ_URI="" \

Dockerfile.onbuild

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
FROM clowder/pyclowder:2
22

3-
# copy all files
4-
ONBUILD ADD . /home/clowder/
5-
63
# install any packages
7-
#ONBUILD COPY packages.apt /home/clowder/
4+
ONBUILD COPY packages.* Dockerfile /home/clowder/
85
ONBUILD RUN if [ -e packages.apt ]; then \
96
apt-get -q -q update \
107
&& xargs apt-get -y install --no-install-recommends < packages.apt \
118
&& rm -rf /var/lib/apt/lists/*; \
129
fi
1310

1411
# install any python packages
15-
#ONBUILD COPY requirements.txt /home/clowder/
12+
ONBUILD COPY requirements.txt* Dockerfile /home/clowder/
1613
ONBUILD RUN if [ -e requirements.txt ]; then \
1714
pip install --no-cache-dir -r requirements.txt; \
1815
fi
1916

17+
# copy all files
18+
ONBUILD ADD . /home/clowder/
19+
2020
# switch to user clowder last minute
2121
ONBUILD USER clowder
2222

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,24 @@ an extractor or code that interacts with clowder. One of these functions is setu
202202
logging system for you. The logging function takes a single argument that can be None. The argument is either a pointer
203203
to a file that is read with the configuration options.
204204

205-
# files
205+
## files
206+
207+
# Dockerfile
208+
209+
We recommend using the pyclowder:onbuild to easily convert your extractor into a docker container. If you build the
210+
extractor as commented above, you will only need the following Dockerfile
211+
212+
```
213+
FROM clowder/pyclowder:onbuild
214+
215+
ENV MAIN_SCRIPT="wordcount.py"
216+
```
217+
218+
The main piece is the MAIN_SCRIPT which should point to the python file that holds your main function.
219+
220+
If you need additional packages installed, you will need a file called packages.apt with in this file a list of all
221+
packages that need to be installed. The docker build process will use this file to install those pacakges first in
222+
the docker container.
223+
224+
If you need any python packages installed you will need to create file called requiremenets.txt. If this file exists
225+
the docker build process will use `pip install -r requirements.txt` to install these packages.

entrypoint.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ if [ "$1" = 'extractor' ]; then
2121
echo "Main script specified does not exist."
2222
exit -1
2323
fi
24-
chmod 755 "${MAIN_SCRIPT}"
2524

2625
# check to make sure rabbitmq is up
2726
if [ "${RABBITMQ_PORT_5672_TCP_ADDR}" != "" ]; then
@@ -35,7 +34,7 @@ if [ "$1" = 'extractor' ]; then
3534
fi
3635

3736
# launch extractor and see what happens
38-
exec "./${MAIN_SCRIPT}"
37+
exec "python ./${MAIN_SCRIPT}"
3938
fi
4039

4140
exec "$@"
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
FROM clowder/pyclowder:onbuild
22

3-
ENV RABBITMQ_QUEUE="ncsa.wordcount" \
4-
MAIN_SCRIPT="wordcount.py"
3+
ENV MAIN_SCRIPT="wordcount.py"

0 commit comments

Comments
 (0)