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

Re work #5

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
103 changes: 57 additions & 46 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,70 +12,81 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

FROM ubuntu:16.04
MAINTAINER Alessandro Tanasi <[email protected]>

FROM ubuntu:16.04
LABEL Maintainer="Jonathan Batteas <[email protected]>"
ARG TZ
ENV DEBIAN_FRONTEND noninteractive
ENV TIMEZONE Europe/Rome
ENV TIMEZONE ${TZ}
ENV GHIRO_PASSWORD ghiromanager
ENV GHIRO_USER ghiro

ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_PID_FILE /var/run/apache2/apache2.pid
ENV APACHE_RUN_DIR /var/run/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_LOG_DIR /var/log/apache2
ENV LOGS /logs
# Copy requirements files.
COPY files/*.txt /tmp/

# Update repositories.
RUN apt-get update

# Setup basic deps.
RUN apt-get update
RUN xargs apt-get install -y < /tmp/deb-packages.txt
RUN rm /tmp/deb-packages.txt
RUN pip install --upgrade -r /tmp/pypi-packages.txt
RUN rm /tmp/pypi-packages.txt

# Configure timezone and locale
RUN echo "$TIMEZONE" > /etc/timezone && \
dpkg-reconfigure -f noninteractive tzdata
RUN export LANGUAGE=en_US.UTF-8 && \
export LANG=en_US.UTF-8 && \
export LC_ALL=en_US.UTF-8 && \
locale-gen en_US.UTF-8 && \
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales

# Configure wkhtmltopdf
RUN printf '#!/bin/bash\nxvfb-run --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf $*' > /usr/bin/wkhtmltopdf.sh
RUN chmod a+x /usr/bin/wkhtmltopdf.sh
RUN ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf
RUN apt-get update \
&& xargs apt-get install -y < /tmp/deb-packages.txt \
&& rm /tmp/deb-packages.txt \
&& pip install --upgrade pip \
&& pip install --upgrade -r /tmp/pypi-packages.txt \
&& rm /tmp/pypi-packages.txt \
&& git clone https://github.com/GrahamDumpleton/mod_wsgi.git /mod_wsgi \
&& cd /mod_wsgi && ./configure \
--with-python=/usr/bin/python \
&& make && make install && make clean \
&& echo 'LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so' > /etc/apache2/mods-available/wsgi.load \
&& a2enmod wsgi \
# && echo 'LoadModule wsgi_module modules/mod_wsgi.so' >> /etc/apache2/apache2.conf \
&& echo 'WSGIApplicationGroup %{GLOBAL}' >> /etc/apache2/apache2.conf \
&& echo 'ServerName localhost' >> /etc/apache2/apache2.conf \
&& echo "$TIMEZONE" > /etc/timezone \
&& dpkg-reconfigure -f noninteractive tzdata \
&& export LANGUAGE=en_US.UTF-8 \
&& export LANG=en_US.UTF-8 \
&& export LC_ALL=en_US.UTF-8 \
&& locale-gen en_US.UTF-8 \
&& DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales \
&& printf '#!/bin/bash\nxvfb-run --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf $*' > /usr/bin/wkhtmltopdf.sh \
&& chmod a+x /usr/bin/wkhtmltopdf.sh \
&& ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& mkdir -p $LOGS && mkdir -p $APACHE_RUN_DIR && mkdir -p $APACHE_LOCK_DIR && mkdir -p $APACHE_LOG_DIR

# Checkout ghiro from git.
RUN git clone https://github.com/Ghirensics/ghiro.git /var/www/ghiro

# Setup python requirements using pypi.
RUN pip install -r /var/www/ghiro/requirements.txt
RUN git clone https://github.com/Ghirensics/ghiro.git /var/www/ghiro \
&& pip install -r /var/www/ghiro/requirements.txt

# Configure ghiro.
ADD local_settings.py /var/www/ghiro/ghiro/local_settings.py
COPY local_settings.py /var/www/ghiro/ghiro/local_settings.py

# Ghiro setup.
RUN cd /var/www/ghiro && python manage.py syncdb --noinput
RUN mkdir /var/www/ghiro/uploads

# Create super user.
RUN cd /var/www/ghiro && echo "from users.models import Profile; Profile.objects.create_superuser('$GHIRO_USER', '[email protected]', '$GHIRO_PASSWORD')" | python manage.py shell
VOLUME ["/var/www/ghiro/uploads"]

# Add virtualhost
ADD ./ghiro.conf /etc/apache2/sites-available/
COPY ./ghiro.conf /etc/apache2/sites-available/ghiro.conf

# Remove default virtualhost.
RUN a2dissite 000-default
RUN a2dissite 000-default \
&& a2ensite ghiro \
&& chown -R www-data:www-data /var/www/ghiro/

# Enable ghiro virtualhost.
RUN a2ensite ghiro
EXPOSE 80

# Clean-up
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

EXPOSE 80

ADD start.sh /start.sh
COPY start.sh /start.sh
RUN chmod 0755 /start.sh
CMD ["bash", "start.sh"]

COPY wait-for-it.sh /wait-for-it.sh
RUN chmod 0755 wait-for-it.sh


COPY install.sh /install.sh
RUN chmod 0755 /install.sh
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
To install Ghiro using Docker, from the root of this project run

```
docker-compose -f docker-compose.yml -f docker-compose-install.yml up -d
```

This will perform the migrations, and functions that must be run only once.

To use Ghiro after the installation run:

```
docker-compose up -d
```

Ghiro will then be available in your browser at [http://localhost:9991/](http://localhost:9991/)

Default username: **ghiro**

Default password: **ghiromanager**

To upload images, place the images you want to import into the `images/` folder. In the interface, add folder `uploads/{your folder}`. To begin processing your images, `docker exec --rm -it {container_name} /usr/bin/python /var/www/ghiro/manage.py process`
9 changes: 9 additions & 0 deletions docker-compose-install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3.4' # requires docker-compose >= 1.17.0
services:
ghiro:
build:
context: .
args:
- "TZ=America/New_York"
image: ghiro/ghiro:latest
command: ['./wait-for-it.sh', 'mongo:27017', 'pg:5432', '--', "./install.sh"]
64 changes: 37 additions & 27 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
ghiro-pg:
image: postgres:9.5
container_name: ghiro-pg
net: "host"
environment:
- POSTGRES_USER=ghiro
- POSTGRES_DB=ghiro
- POSTGRES_PASSWORD==ghiromanager
ports:
- "5432:5432"

ghiro-mongo:
image: mongo:3.2
container_name: ghiro-mongo
net: "host"
ports:
- "27017:27017"

ghiro:
# Set build to "." to build the project in the local directory.
build: .
container_name: ghiro
links:
- "ghiro-pg"
ports:
- "80:80"
net: "host"
version: '3.4' # requires docker-compose >= 1.17.0
services:
pg:
image: postgres:9.5
container_name: ghiro-pg
volumes:
- 'ghiro-pg:/var/lib/postgresql/data'
environment:
- POSTGRES_USER=ghiro
- POSTGRES_DB=ghiro
- POSTGRES_PASSWORD=ghiromanager
ports:
- "5432:5432"
mongo:
image: tutum/mongodb
container_name: ghiro-mongo
volumes:
- 'ghiro-mongo:/data/db'
ports:
- 27017:27017
environment:
- AUTH="no"
ghiro:
image: ghiro/ghiro:latest
container_name: ghiro
volumes:
- './images:/var/www/ghiro/uploads'
links:
- "pg"
- "mongo"
ports:
- "9991:80"
volumes:
ghiro-mongo:
driver: local
ghiro-pg:
driver: local
2 changes: 1 addition & 1 deletion files/deb-packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tcl8.5-dev
tk8.5-dev
python-tk
apache2
libapache2-mod-wsgi
apache2-dev
wkhtmltopdf
xvfb
python-setuptools
Expand Down
2 changes: 1 addition & 1 deletion files/pypi-packages.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
psycopg2
psycopg2-binary
4 changes: 2 additions & 2 deletions ghiro.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<VirtualHost *:80>
ServerAdmin webmaster@localhost
WSGIProcessGroup ghiro
WSGIDaemonProcess ghiro processes=5 threads=10 user=nobody group=nogroup python-path=/var/www/ghiro/ home=/var/www/ghiro/ display-name=local
WSGIDaemonProcess ghiro processes=5 threads=10 user=www-data group=www-data python-path=/var/www/ghiro/ home=/var/www/ghiro/ display-name=local
WSGIScriptAlias / /var/www/ghiro/ghiro/wsgi.py
Alias /static/ /var/www/ghiro/static/
<Location "/static/">
Expand All @@ -10,6 +10,6 @@
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
LogLevel debug
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
5 changes: 5 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

python /var/www/ghiro/manage.py makemigrations && python /var/www/ghiro/manage.py migrate --noinput
echo "from users.models import Profile; Profile.objects.create_superuser('$GHIRO_USER', '[email protected]', '$GHIRO_PASSWORD')" | python /var/www/ghiro/manage.py shell
echo "ghiro has been installed."
19 changes: 15 additions & 4 deletions local_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
# Database name or path to database file if using sqlite3.
'NAME': 'ghiro',
# Credntials. The following settings are not used with sqlite3.
'USER': 'root',
'USER': 'ghiro',
'PASSWORD': 'ghiromanager',
# Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
'HOST': '',
'HOST': 'pg',
# Set to empty string for default port.
'PORT': '',
# Set timeout (avoids SQLite "database is locked" errors).
Expand All @@ -22,7 +22,7 @@
"init_command": "SET storage_engine=INNODB",
}
# Mongo database settings
MONGO_URI = "mongodb://localhost/"
MONGO_URI = "mongodb://mongo/"
MONGO_DB = "ghirodb"
# Max uploaded image size (in bytes).
# Default is 150MB.
Expand All @@ -34,6 +34,7 @@
'image/x-olympus-orf', 'image/x-photoshop', 'image/x-fuji-raf',
'image/x-panasonic-raw2', 'image/x-tga', 'image/tiff', 'image/pjpeg',
'image/x-x3f', 'image/x-portable-pixmap']
AUTO_UPLOAD_DIR = "/var/www/ghiro/uploads"
# Override default secret key stored in secret_key.py
# Make this unique, and don't share it with anybody.
# SECRET_KEY = "YOUR_RANDOM_KEY"
Expand All @@ -56,4 +57,14 @@
ALLOWED_HOSTS = ["*"]
# Automatically checks once a day for updates.
# Set it to False to disable update check.
UPDATE_CHECK = True
UPDATE_CHECK = True
# these values were missing
AUDITING_ENABLED = True
JSON_EXPORT = True
LOG_DIR = 'logs'
LOG_PROCESSING_NAME = 'ghiro_log'
LOG_PROCESSING_SIZE = 1e+8
LOG_PROCESSING_NUM = 5
LOG_AUDIT_NAME = 'ghiro_audit'
LOG_AUDIT_SIZE = 1e+8
LOG_AUDIT_NUM = 5
4 changes: 2 additions & 2 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

# Start mongo.
mongod &
# mongod &
# Start mysql.
mysqld_safe &
# mysqld_safe &
# Start apache
/usr/sbin/apache2 -D FOREGROUND
sleep 5
Expand Down
Loading