Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates from Olaf #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
# booktype_with_docker
A [booktype](https://www.sourcefabric.org/en/booktype/) in a docker container. It is using sqlite as backent.

# quick start #

Clone my repo
```
Git clone https://github.com/OlafRadicke/booktype_with_docker.git
```
Let run the ansible roll out script. It's create the docker container on your local machine. Before install ansible,
when it not exit.
```
cd ./booktype_with_docker/ansible
su -c 'ansible-playbook booktype_with_docker'
```
Check is all container running now:
```
[root@oradicke-localdomain ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
89ddb07ce27d olafradicke/booktype "/bin/bash start.sh" About an hour ago Up About an hour 8000/tcp, 0.0.0.0:49108->8080/tcp booktype
301e57e02bf4 redis "/entrypoint.sh redis" 2 hours ago Up 2 hours 6379/tcp booktyperedis
f60f86fb056c postgres "/docker-entrypoint.s" 2 hours ago Up 2 hours 5432/tcp booktypepostgres
```
For trouble shutting go in the container and start the service manual
```
[root@oradicke-localdomain ~]# docker exec -it booktype /bin/bash
root@89ddb07ce27d:/# /bin/bash start.sh

```

# Biuild images #

```
Expand Down
2 changes: 1 addition & 1 deletion ansible/files/booktyperedis.service
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Requires=docker.service
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill booktyperedis
ExecStartPre=-/usr/bin/docker rm booktyperedis
ExecStartPre=/usr/bin/docker pull postgres
ExecStartPre=/usr/bin/docker pull redis
ExecStart=/usr/bin/docker run --name=booktyperedis \
redis

Expand Down
2 changes: 1 addition & 1 deletion ansible/run_booktype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
volume: "/srv/docker/booktype/data"

tasks:
- name: "create a volume data directory for xwiki"
- name: "create a volume data directory for postgres and booktype data"
file:
path: "{{ item }}"
state: "directory"
Expand Down
22 changes: 19 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ ENV booktypeversion 2.0
#env DJANGO_SETTINGS_MODULE ${instancename}.settings
ENV HTTP_HOST localhost
ENV SITE_NAME Documentation
ENV DATA_ROOT /srv/booktype/data/
ENV DJANGO_SETTINGS_MODULE settings.prod
ENV PYTHONPATH $PYTHONPATH://:/${instancename}/lib/:/Booktype/lib:/${instancename}
ENV PYTHONPATH $PYTHONPATH:/:/${instancename}/lib/:/Booktype/lib:/${instancename}:/${instancename}/settings
ENV BOOKTYPE_USER booktype
ENV BOOKTYPE_PASS booktype
ENV BOOKTYPE_DB booktype
ENV PG_HOST booktyppostgres
ENV PG_PORT '5432'
ENV REDIS_HOST 'booktyperedis'

EXPOSE 8000
EXPOSE 8080
VOLUME /${instancename}/data/
VOLUME ${DATA_ROOT}

RUN apt-get update && apt-get -y upgrade

Expand Down Expand Up @@ -49,6 +49,7 @@ RUN rm /${booktypeversion}.zip
RUN pip install -r /Booktype/requirements/prod.txt

# Create Booktype project
# RUN #!/bin/bash echo 'yes\n' | /Booktype/scripts/createbooktype --database postgresql ${instancename}
RUN /Booktype/scripts/createbooktype --database postgresql ${instancename}

#RUN cp -R /${instancename}/docker_book_site/settings /${instancename}/settings
Expand All @@ -60,4 +61,19 @@ COPY ./base.py /${instancename}/settings/base.py
#RUN cat /${instancename}/settings/prod.py


RUN echo "DJANGO_SETTINGS_MODULE:"
RUN echo $DJANGO_SETTINGS_MODULE
RUN echo "PYTHONPATH"
RUN echo $PYTHONPATH

# Initialise Booktype
RUN cd /${instancename}/
RUN ls -lah
RUN #!/bin/bash source ${instancename}/booktype.env
RUN django-admin.py syncdb --noinput
RUN django-admin.py migrate
RUN django-admin.py createsuperuser
#django-admin.py createsuperuser --username='sysadmin' --email='sysadmin@okfn.org' --noinput


CMD ["/bin/bash", "start.sh"]
3 changes: 2 additions & 1 deletion docker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
)

# data
DATA_ROOT = BOOKTYPE_ROOT.child('data')
#DATA_ROOT = BOOKTYPE_ROOT.child('data')
DATA_ROOT = os.environ['DATA_ROOT']
DATA_URL = '{}/data/'.format(BOOKTYPE_URL)

# profile images
Expand Down
15 changes: 3 additions & 12 deletions docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
echo "DJANGO_SETTINGS_MODULE:"
echo $DJANGO_SETTINGS_MODULE

# Initialise Booktype
source ${instancename}/booktype.env
django-admin.py syncdb --noinput
django-admin.py migrate
django-admin.py createsuperuser
#django-admin.py createsuperuser --username='sysadmin' --email='sysadmin@okfn.org' --noinput

# This has to be done every time you want to start a server
#cd /docker_booktype
source /docker_booktype/bin/activate
source ${instancename}/booktype.env
django-admin.py runserver 0.0.0.0:8080
cd /${instancename}/
/${instancename}/manage.py
runserver 0.0.0.0:8080