Skip to content

Commit

Permalink
Merge pull request #68 from gwu-libraries/t37-fixtures
Browse files Browse the repository at this point in the history
refs #37. Added fixtures to dev and master docker containers.
  • Loading branch information
rajatvij committed Dec 2, 2015
2 parents ac79000 + b3725bd commit ea118ee
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 6 deletions.
3 changes: 3 additions & 0 deletions docker/app-dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ RUN pip install appdeps
RUN pip install django-finalware==0.1.0
#This will be copied over into the app by invoke.sh.
ADD wsgi.py /tmp/
#Adds fixtures.
ADD fixtures.json /opt/sfm-setup/
#Enable sfm site
ADD apache.conf /etc/apache2/sites-available/sfm.conf
RUN a2ensite sfm.conf
Expand All @@ -32,5 +34,6 @@ RUN a2dissite 000-default
ADD invoke.sh /opt/
RUN chmod +x /opt/invoke.sh
WORKDIR /opt/sfm-ui
ENV DJANGO_SETTINGS_MODULE=sfm.settings.docker_settings
CMD ["/opt/invoke.sh"]
EXPOSE 80
42 changes: 42 additions & 0 deletions docker/app-dev/fixtures.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"fields": {
"name": "testgroup",
"permissions": []
},
"model": "auth.group",
"pk": 1
},
{
"fields": {
"username": "testuser",
"first_name": "",
"last_name": "",
"is_active": true,
"local_id": "",
"is_superuser": false,
"is_staff": false,
"last_login": null,
"groups": [1],
"user_permissions": [],
"password": "pbkdf2_sha256$20000$7gZDb0TxSksC$HXFliz5Vqsd+S3a6+X+iwQuZ//uvfEpYb+0+0sMD7Vk=",
"email": "",
"date_joined": "2015-12-01T19:09:21Z"
},
"model": "ui.user",
"pk": 2
}, {
"fields": {
"is_visible": true,
"stats": "",
"name": "testcollection",
"date_updated": "2015-12-01T19:10:46.000Z",
"is_active": true,
"date_added": "2015-12-01T19:10:28Z",
"group": 1,
"description": "This is a test collection."
},
"model": "ui.collection",
"pk": 1
}
]
5 changes: 3 additions & 2 deletions docker/app-dev/invoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ fi
echo "Updating requirements"
pip install -r /opt/sfm-ui/requirements/requirements.txt --upgrade

export DJANGO_SETTINGS_MODULE=sfm.settings.docker_settings

echo "Copying config"
cp /tmp/wsgi.py /opt/sfm-ui/sfm/sfm/

Expand All @@ -23,6 +21,9 @@ echo "Migrating db"
echo "Collecting static files"
/opt/sfm-ui/sfm/manage.py collectstatic --noinput

echo "Loading fixtures"
/opt/sfm-ui/sfm/manage.py loaddata /opt/sfm-setup/fixtures.json

echo "Running server"
#Not entirely sure why this is necessary, but it works.
/etc/init.d/apache2 start
Expand Down
3 changes: 3 additions & 0 deletions docker/app-master/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ RUN pip install django-finalware==0.1.0
RUN pip install appdeps
#This will be copied over into the app by invoke.sh.
ADD wsgi.py /opt/sfm-ui/sfm/sfm/
#Adds fixtures.
ADD fixtures.json /opt/sfm-setup/
#Enable sfm site
ADD apache.conf /etc/apache2/sites-available/sfm.conf
RUN a2ensite sfm.conf
Expand All @@ -38,4 +40,5 @@ ADD invoke.sh /opt/
RUN chmod +x /opt/invoke.sh
WORKDIR /opt/sfm-ui
CMD ["/opt/invoke.sh"]
ENV DJANGO_SETTINGS_MODULE=sfm.settings.docker_settings
EXPOSE 80
42 changes: 42 additions & 0 deletions docker/app-master/fixtures.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"fields": {
"name": "testgroup",
"permissions": []
},
"model": "auth.group",
"pk": 1
},
{
"fields": {
"username": "testuser",
"first_name": "",
"last_name": "",
"is_active": true,
"local_id": "",
"is_superuser": false,
"is_staff": false,
"last_login": null,
"groups": [1],
"user_permissions": [],
"password": "pbkdf2_sha256$20000$7gZDb0TxSksC$HXFliz5Vqsd+S3a6+X+iwQuZ//uvfEpYb+0+0sMD7Vk=",
"email": "",
"date_joined": "2015-12-01T19:09:21Z"
},
"model": "ui.user",
"pk": 2
}, {
"fields": {
"is_visible": true,
"stats": "",
"name": "testcollection",
"date_updated": "2015-12-01T19:10:46.000Z",
"is_active": true,
"date_added": "2015-12-01T19:10:28Z",
"group": 1,
"description": "This is a test collection."
},
"model": "ui.collection",
"pk": 1
}
]
5 changes: 3 additions & 2 deletions docker/app-master/invoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ fi
echo "Copying config"
cp /tmp/wsgi.py /opt/sfm-ui/sfm/sfm/

export DJANGO_SETTINGS_MODULE=sfm.settings.docker_settings

echo "Syncing db"
/opt/sfm-ui/sfm/manage.py syncdb --noinput

Expand All @@ -20,6 +18,9 @@ echo "Migrating db"
echo "Collecting static files"
/opt/sfm-ui/sfm/manage.py collectstatic --noinput

echo "Loading fixtures"
/opt/sfm-ui/sfm/manage.py loaddata /opt/sfm-setup/fixtures.json

echo "Running server"
#Not entirely sure why this is necessary, but it works.
/etc/init.d/apache2 start
Expand Down
1 change: 1 addition & 0 deletions docker/app-prod/0.2.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ ADD invoke.sh /opt/
RUN chmod +x /opt/invoke.sh
WORKDIR /opt/sfm-ui
CMD ["/opt/invoke.sh"]
ENV DJANGO_SETTINGS_MODULE=sfm.settings.docker_settings
EXPOSE 80
2 changes: 0 additions & 2 deletions docker/app-prod/0.2.0/invoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ fi
echo "Copying config"
cp /tmp/wsgi.py /opt/sfm-ui/sfm/sfm/

export DJANGO_SETTINGS_MODULE=sfm.settings.docker_settings

echo "Syncing db"
/opt/sfm-ui/sfm/manage.py syncdb --noinput

Expand Down
6 changes: 6 additions & 0 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,9 @@ SFM UI runs behind Apache, which means Apache collects stdout and stderr in `/va
The contents of error.log can be viewed with::

docker exec <name of your container> cat /var/log/apache2/error.log

Initial data
^^^^^^^^^^^^
The development and master docker images for SFM UI contain some initial data. This includes a user ("testuser",
with password "password"). For the latest initial data, see `fixtures.json`. For more information on fixtures,
see the `Django docs <https://docs.djangoproject.com/en/1.8/howto/initial-data/>`_.

0 comments on commit ea118ee

Please sign in to comment.