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

Dockerize #1485

Open
wants to merge 4 commits into
base: develop
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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git

49 changes: 49 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM php:5.5-apache

ENV DOCKERIZE_VERSION v0.7.0
RUN cat > /etc/apt/sources.list <<EOF
deb http://archive.debian.org/debian/ jessie main contrib non-free
deb-src http://archive.debian.org/debian/ jessie main contrib non-free
EOF
RUN apt-get update --allow-unauthenticated && \
apt-get upgrade -y --allow-unauthenticated && \
apt-get install -y --allow-unauthenticated \
wget \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libmcrypt-dev \
libc-client2007e-dev \
libkrb5-dev \
libcurl4-openssl-dev \
libzip-dev \
gettext-base \
unzip \
rsync \
git \
bison \
netcat && \
docker-php-ext-install mcrypt bcmath pdo_mysql mysqli zip && \
docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \
docker-php-ext-install imap && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install gd && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN curl -L --output /tmp/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
tar -C /usr/local/bin -xzvf /tmp/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
rm /tmp/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

WORKDIR /var/www/html/
COPY ./ /var/www/html/
RUN chmod -R 777 application/config && \
chmod -R 777 application/cache && \
chmod -R 777 application/logs && \
chmod -R 777 media/uploads && \
chmod 644 .htaccess

COPY docker/entrypoint.sh /entrypoint.sh

ENTRYPOINT [ "/bin/bash", "/entrypoint.sh" ]
CMD [ "apache2-foreground" ]
2 changes: 1 addition & 1 deletion application/i18n
Submodule i18n updated from fc7889 to 95144f
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "2"
services:
mysql:
image: mysql:5.5
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ushahidi
MYSQL_USER: ushahidi
MYSQL_PASSWORD: ushahidi
ports:
- "33062:3306"
volumes:
- ./sql/ushahidi.sql:/docker-entrypoint-initdb.d/01-ushahidi.sql
platform:
build: .
environment:
DOCKERIZE_TIMEOUT: 180s
DOCKERIZE_WAIT_FOR_mysql: tcp://mysql:3306
DB_DATABASE: ushahidi
DB_HOST: mysql
DB_PORT: 3306
DB_USERNAME: ushahidi
DB_PASSWORD: ushahidi
SITE_DEFAULT_KEY: e(W87Gt(pix9)eFPurY)D
# command: start
ports:
- "80:80"
36 changes: 36 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

set -e

echo "Configuring Ushahidi_Web... "

cat application/config/auth.template.php \
> application/config/auth.php

cat application/config/config.template.php \
> application/config/config.php

# DB_USERNAME
# DB_PASSWORD
# DB_HOST
# DB_PORT
# DB_DATABASE

cat application/config/database.template.php \
| sed -E -e "s/('user' => )('username')/\\1'${DB_USERNAME}'/" \
| sed -E -e "s/('pass' => )('password')/\\1'${DB_PASSWORD}'/" \
| sed -E -e "s/('host' => )('localhost')/\\1'${DB_HOST}'/" \
| sed -E -e "s/('port' => )(FALSE)/\\1'${DB_PORT:-3306}'/" \
| sed -E -e "s/('database' => )('db')/\\1'${DB_DATABASE}'/" \
> application/config/database.php

# SITE_DEFAULT_KEY

cat application/config/encryption.template.php \
| sed -E -e "s/USHAHIDI-INSECURE/${SITE_DEFAULT_KEY:-USHAHIDI-INSECURE}/" \
> application/config/encryption.php


dockerize -wait tcp://${DB_HOST}:${DB_PORT:-3306} -timeout 60s

exec "$@"