Skip to content
Merged
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
23 changes: 8 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,10 @@ RUN export GOSU_VERSION=1.10 && \
yum clean all && \
unset GOSU_VERSION

# Add uwsgi user to the image
ARG UWSGI_UID=1000
ARG UWSGI_GID=1000
# Set env vars from these args, as there is no utility in forcing the user to set them twice in dev.
ENV UID=${UWSGI_UID}
ENV GID=${UWSGI_GID}
ENV UWSGI_UID=1000
ENV UWSGI_GID=1000

RUN groupadd -g $GID uwsgi && \
useradd -d "/home/uwsgi" -u "$UID" -g "$GID" -m -s /bin/bash "uwsgi"

WORKDIR /home/uwsgi
WORKDIR /opt

# Install core dependencies
RUN yum -y update && \
Expand All @@ -39,19 +32,19 @@ RUN yum -y update && \
yum -y install python-devel python2-pip && \
yum -y install openldap-devel MySQL-python

ADD requirements.txt /home/uwsgi/
ADD requirements.txt /opt/
RUN pip2 install --upgrade pip && \
pip2 install -r requirements.txt && \
pip2 install -e git://github.com/ResearchComputing/django-ldapdb.git@v0.5.1#egg=django-ldapdb

# Add uwsgi conf
COPY --chown=uwsgi:uwsgi uwsgi.ini /home/uwsgi/uwsgi.ini
COPY uwsgi.ini /opt/uwsgi.ini

# Add codebase to container
COPY --chown=uwsgi:uwsgi rcamp /home/uwsgi/rcamp
COPY rcamp /opt/rcamp

WORKDIR /home/uwsgi/rcamp
WORKDIR /opt/rcamp
# Set gosu entrypoint and default command
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["sh","/usr/local/bin/docker-entrypoint.sh"]
CMD ["/usr/bin/uwsgi","/home/uwsgi/uwsgi.ini"]
CMD ["/usr/bin/uwsgi","/opt/uwsgi.ini"]
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ services:
env_file:
- dev-environment.env
volumes:
- ./rcamp:/home/uwsgi/rcamp
- ./ldapdb:/home/uwsgi/ldapdb
- static-content:/home/uwsgi/static
- media-uploads:/home/uwsgi/media
- rcamp-logs:/home/uwsgi/logs
- ./rcamp:/opt/rcamp
- ./ldapdb:/opt/ldapdb
- static-content:/opt/static
- media-uploads:/opt/media
- rcamp-logs:/opt/logs
ports:
- "8000:8000"
depends_on:
Expand Down
14 changes: 11 additions & 3 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
#!/bin/bash

STATIC_DIR=/home/uwsgi/static
MEDIA_DIR=/home/uwsgi/media
LOG_DIR=/home/uwsgi/logs
STATIC_DIR=/opt/static
MEDIA_DIR=/opt/media
LOG_DIR=/opt/logs
RCAMP_DIR=/opt/rcamp
UWSGI_CONFIG=/opt/uwsgi.ini

# Add uwsgi user and group
groupadd -g $UWSGI_GID uwsgi
useradd -d "/home/uwsgi" -u "$UWSGI_UID" -g "$UWSGI_GID" -m -s /bin/bash "uwsgi"

# Collect static, and set permissions of shared volumes.
RCAMP_DEBUG=True bash -c 'python manage.py collectstatic --noinput'
chown -R uwsgi:uwsgi $STATIC_DIR
chown -R uwsgi:uwsgi $MEDIA_DIR
chown -R uwsgi:uwsgi $LOG_DIR
chown -R uwsgi:uwsgi $RCAMP_DIR
chown uwsgi:uwsgi $UWSGI_CONFIG

exec gosu uwsgi "$@"
2 changes: 1 addition & 1 deletion rcamp/rcamp/settings/databases.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from .toggles import *

BASE_DIR = '/home/uwsgi/rcamp'
BASE_DIR = '/opt/rcamp'

DATABASES = {
'default': {
Expand Down
2 changes: 1 addition & 1 deletion rcamp/rcamp/settings/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'file': {
'level': 'WARN',
'class': 'logging.FileHandler',
'filename': '/home/uwsgi/logs/rcamp.log',
'filename': '/opt/logs/rcamp.log',
},
},
'loggers': {
Expand Down
4 changes: 2 additions & 2 deletions rcamp/rcamp/settings/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
from .toggles import *

HOME_DIR = '/home/uwsgi'
BASE_DIR = '/home/uwsgi/rcamp'
HOME_DIR = '/opt'
BASE_DIR = '/opt/rcamp'


SECRET_KEY = os.environ.get('RCAMP_SECRET_KEY')
Expand Down
2 changes: 1 addition & 1 deletion uwsgi.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[uwsgi]
socket = :8000
chdir = /home/uwsgi/rcamp/
chdir = /opt/rcamp/
wsgi-file = rcamp/wsgi.py
enable-threads = true
processes = 2
Expand Down