#9 Add docker support
Merged a year ago by firstyear. Opened a year ago by firstyear.
firstyear/389-ds-portal 3-docker  into  master

file added
+26
@@ -0,0 +1,26 @@ 

+ #!BuildTag: 389-ds-portal

+ FROM opensuse/leap:15.1

+ MAINTAINER wbrown@suse.de

+ 

+ EXPOSE 8080

+ 

+ RUN zypper ar http://download.opensuse.org/update/leap/15.1/oss/ u && \

+     zypper ar http://download.opensuse.org/distribution/leap/15.1/repo/oss/ m && \

+     zypper ar http://download.opensuse.org/repositories/network:ldap/openSUSE_Leap_15.1/ "network:ldap" && \

+     zypper mr -p 97 "network:ldap" && \

+     zypper --gpg-auto-import-keys ref

+ 

+ RUN zypper in -y python3-Flask python3-cryptography python3-ldap python3-lib389 python3-pip python3-devel apache2 apache2-devel gcc && \

+ 	pip3 install mod_wsgi

+ 

+ ADD ./ /home/flask

+ WORKDIR /home/flask

+ 

+ VOLUME /data

+ 

+ # HEALTHCHECK

+ 

+ #  How do we avoid user/group?

+ CMD mod_wsgi-express start-server --user wwwrun --group wwwrun --port 8080 --url-alias /static /home/flask/static entry.wsgi

+ 

+ 

file modified
+23 -2
@@ -48,11 +48,11 @@ 

  

  The easiest way to setup a 389 server to test with this is in a docker container:

  

-     docker run -v 389data:/data -i -t 389ds/dirsrv:latest

+     docker run --name=389-ds -v 389data:/data -i -t 389ds/dirsrv:latest

  

  You can then run this project in a container such as:

  

-     docker run -v 389data:/data -i -t opensuse/tumbleweed:latest /bin/sh

+     docker run --name=389-ds-portal -v 389data:/data -p 8080 -i -t opensuse/tumbleweed:latest /bin/sh

  

  To run this you will require python3, python3-Flask and temporarily python3-cryptography.

  
@@ -68,3 +68,24 @@ 

  

      py.test ./test.py

  

+ Docker

+ ------

+ 

+ To build the image run:

+ 

+     docker build -t 389-ds-portal:devel .

+ 

+ Then to run it with an instance:

+ 

+     docker run --name=389-ds -v 389data:/data -i -t 389ds/dirsrv:latest

+     docker run --name=389-ds-portal -v 389data:/data -p 8080:8080 -i -t 389-ds-portal:devel

+ 

+ You may need to add some users to the container such as:

+ 

+     docker exec -i -t 389-ds /usr/sbin/dsconf localhost backend create --be-name userRoot --suffix dc=example,dc=com

+     docker exec -i -t 389-ds /usr/sbin/dsidm -b dc=example,dc=com localhost initialise

+     docker exec -i -t 389-ds /usr/sbin/dsidm -b dc=example,dc=com localhost user create --uid william --cn william --displayName william --uidNumber 1000 --gidNumber 1000 --homeDirectory /home/william

+     docker exec -i -t 389-ds /usr/sbin/dsidm -b dc=example,dc=com localhost account reset_password uid=william,ou=People,dc=example,dc=com

+ 

+ Now you should be able to use the portal as a test.

+ 

file added
+1
@@ -0,0 +1,1 @@ 

+ from server import app as application

file modified
+1
@@ -17,6 +17,7 @@ 

  

  # Set the secret key to some random bytes. Keep this really secret!

  app.secret_key = os.urandom(16)

+ # app.secret_key = b'\xb5\x97\x93~!t\x97\r\x1e\xfd\xea\xf8\xe9\xd5\x91\xb0'

  

  # url_for('static', filename='css/bootstrap.min.css')

  # url_for('static', filename='js/bootstrap.min.js')

This adds a dockerfile and support for docker to the 389-ds-portal. This may not work for others yet due to:

- docker run -i -t -p 8080 -v testdata:/data 389-ds-portal:test
+ docker run -i -t --name=389-ds-portal -p 8080:8080 -v testdata:/data 389-ds-portal:devel
- docker run -i -t -v testdata:/data 389ds/dirsrv:latest
+ docker run -i -t --name=389-ds -v testdata:/data 389ds/dirsrv:latest

Here and below then replace relaxed_yonath with 389-ds. All that for a mere convenience.

Other than the comments above this seems to work just fine, me only being unable to actually log in most likely due to issues described in the description.

These are all great comments @mhonek, thanks so much! I'll apply them now :)

1 new commit added

  • Update based on mhonek feedback
a year ago

I'm not sure I get this change. Especially the use of the Tumbleweed container instead of the actual 389-ds-portal we just built. I still think this should actually read the following:

    docker run -i -t -p 8080:8080 -v 389data:/data -i -t 389-ds-portal:devel

BTW, I use here the 8080:8080 so that it does not just bind to a random port, but always 8080 instead.

I probably just blindly copy pasted like an idiot ... I'll cehck to see what I messed up :)

1 new commit added

  • One line fix to docs
a year ago

That should fix it, sorry I'm a bit silly.

rebased onto 6f27c35

a year ago

rebased onto c1354b3

a year ago

Pull-Request has been merged by firstyear

a year ago