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

add dockerfile #1602

Closed
wants to merge 5 commits into from
Closed
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 .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
image: docker:latest

services:
- docker:dind

before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY

master:
stage: build
script:
- docker build --pull
-t "$CI_REGISTRY_IMAGE" .
- docker push "${CI_REGISTRY_IMAGE}"
only:
- master

tags:
stage: build
script:
- docker build --pull
-t "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
only:
- master
only:
- tags
49 changes: 49 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM alpine:3.8

LABEL maintainer="Pascal A. <pascalito@gmail.com>" \
org.photo-frontend.url="https://github.com/photo/frontend/blob/master/README.md" \
org.photo-frontend.build-date=$BUILD_DATE \
org.photo-frontend.version=$CI_COMMIT_REF_NAME \
org.photo-frontend.vcs-url="https://github.com/photo/frontend.git" \
org.photo-frontend.vcs-ref=$VCS_REF \
org.photo-frontend.docker.dockerfile="/Dockerfile" \
org.photo-frontend.description="Trovebox frontend" \
org.photo-frontend.schema-version="1.0"

RUN apk --update --no-cache add \
nginx \
php7 \
php7-fpm \
php7-pdo_mysql \
php7-mysqli \
php7-curl \
php7-gd \
php7-json \
php7-oauth \
php7-session \
php7-ctype \
php7-exif \
php7-mcrypt \
php7-apcu \
php7-imagick \
s6

COPY src/configs/docker/ /
COPY src/ /var/www/src

RUN mkdir -p /var/www/src/userdata \
&& mkdir -p /var/www/src/html/photos \
&& mkdir -p /var/www/src/html/assets/cache \
&& chown nginx /var/www/src/userdata \
/var/www/src/html/photos \
/var/www/src/html/assets/cache

RUN ln -sf /dev/stderr /var/log/fpm-php.log \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log

VOLUME /var/www/src/html/photos
EXPOSE 80

ENTRYPOINT ["/bin/s6-svscan", "/etc/services.d"]
HEALTHCHECK CMD curl --fail http://localhost/ || exit 1
144 changes: 144 additions & 0 deletions documentation/guides/InstallationUbuntuXenialApache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/bin/bash
#######################################
# OpenPhoto Install
# Run with sudo for best results
#######################################
SECONDS=0
if [[ "$(/usr/bin/whoami)" != "root" ]]; then
echo "This script must be run as root or using sudo.Script aborted."
exit 1
fi

echo ""
echo ""
echo "===================================================="
echo "Updating Ubuntu and apt-get"
echo "===================================================="
echo ""
echo ""

apt update
apt upgrade

echo ""
echo ""
echo "===================================================="
echo "Installing needed packages and modules"
echo "===================================================="
echo ""
echo ""

apt install -y apache2 curl vim git-core build-essential exiftran mysql-server mysql-client php7.0 libapache2-mod-php7.0 php7.0-curl curl php7.0-gd php7.0-mcrypt php7.0-mysql php-pear php-apcu libpcre3-dev php7.0-dev php-imagick
a2enmod rewrite
a2enmod deflate
a2enmod expires
a2enmod headers

echo ""
echo ""
echo "===================================================="
echo "Installing oauth from pecl"
echo "===================================================="
echo ""
echo ""

pecl install oauth
echo "extension=oauth.so" >> /etc/php/7.0/apache2/conf.d/oauth.ini

echo ""
echo ""
echo "===================================================="
echo "Downloading OpenPhoto and unpacking"
echo "===================================================="
echo ""
echo ""

wget https://github.com/photo/frontend/tarball/master -O openphoto.tar.gz
tar -zxvf openphoto.tar.gz > /dev/null 2>&1
mv photo-frontend-* /var/www/openphoto
sudo rm openphoto.tar.gz

echo ""
echo ""
echo "===================================================="
echo "Setting permissions for Dev server"
echo "===================================================="
echo ""
echo ""

mkdir /var/www/openphoto/src/userdata
chown www-data:www-data /var/www/openphoto/src/userdata

mkdir /var/www/openphoto/src/html/assets/cache
chown www-data:www-data /var/www/openphoto/src/html/assets/cache

mkdir /var/www/openphoto/src/html/photos
chown www-data:www-data /var/www/openphoto/src/html/photos

echo ""
echo ""
echo "===================================================="
echo "Setting up Apache"
echo "===================================================="
echo ""
echo ""

cp /var/www/openphoto/src/configs/openphoto-vhost.conf /etc/apache2/sites-available/openphoto.conf
sed 's/\/path\/to\/openphoto\/html\/directory/\/var\/www\/openphoto\/src\/html/g' /var/www/openphoto/src/configs/openphoto-vhost.conf > /etc/apache2/sites-available/openphoto.conf
a2dissite 000-default
a2ensite openphoto

echo ""
echo ""
echo "===================================================="
echo "Adjusting PHP settings"
echo "===================================================="
echo ""
echo ""

sed -e 's/file_uploads.*/file_uploads = On/g' -e 's/upload_max_filesize.*/upload_max_filesize = 16M/g' -e 's/post_max_size.*/post_max_size = 16M/g' /etc/php/7.0/apache2/php.ini > /etc/php/7.0/apache2/php.ini.tmp
mv /etc/php/7.0/apache2/php.ini.tmp /etc/php/7.0/apache2/php.ini

echo ""
echo ""
echo "===================================================="
echo "Launching Your OpenPhoto site"
echo "===================================================="
echo ""
echo ""

service apache2 restart

# finding IP address and compensating for possible EC2 installation
EC2=`curl --silent --connect-timeout 1 http://169.254.169.254/latest/meta-data/public-hostname`
if [[ $EC2 != "" ]];
then
IP=`echo $EC2 | sed -rn 's/ec2-(.*?)\.compute.*/\1/p' | sed 's/-/./g'`
else
IP=`ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
fi

echo ""
echo ""
echo ""
echo "****************************************************"
echo "===================================================="
echo "CONGRATULATIONS!!!"
echo ""
echo "The photographic heavens are applauding your"
echo "brand new installation of OpenPhoto."
echo ""
echo ""
echo "Took $SECONDS seconds to install."
echo ""
echo ""
echo "Now you can test your installation by directing your"
echo "browser to $IP"
echo "===================================================="
echo "****************************************************"
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
81 changes: 81 additions & 0 deletions src/configs/docker/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
user nginx nginx;
daemon off;
worker_processes 4;
pid /var/run/nginx.pid;

events {
worker_connections 768;
}

http {
include mime.types;
default_type application/octet-stream;
keepalive_timeout 20;

client_max_body_size 10m;

index index.html index.php;

log_format main_ext '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$host" sn="$server_name" '
'rt=$request_time '
'ua="$upstream_addr" us="$upstream_status" '
'ut="$upstream_response_time" ul="$upstream_response_length" '
'cs=$upstream_cache_status' ;

server {
listen 80 default_server;
server_name _;
root /var/www/src/html;

index index.php;
client_max_body_size 25M;
default_type text/html;
charset utf-8;

if (!-e $request_filename) {
rewrite ^/([^?]*)(\?+([^?]*))*$ /index.php?__route__=/$1&$3 last;
}

location ~* \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_ignore_client_abort off;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location ~ /\. {
deny all;
access_log off;
log_not_found off;
}

location ~ \.ini$ {
deny all;
access_log off;
log_not_found off;
}

add_header Cache-Control "max-age=315360000";

location ~* ^.+\.(jpg|jpeg|gif|css|png|js|xml)$ {
expires 30d;
access_log off;
}
}
}
22 changes: 22 additions & 0 deletions src/configs/docker/etc/php7/php-fpm.d/php-fpm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[global]
daemonize = no

[frontend]
user = nginx
group = nginx
listen.owner = nginx
listen.group = nginx
clear_env = false
catch_workers_output = yes
listen = /var/run/php-fpm.sock

pm = dynamic
pm.max_children = 20
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 2048

php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/fpm-php.log
php_admin_flag[log_errors] = on
2 changes: 2 additions & 0 deletions src/configs/docker/etc/services.d/.s6-svscan/finish
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
/bin/true
2 changes: 2 additions & 0 deletions src/configs/docker/etc/services.d/nginx/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/execlineb -P
nginx
2 changes: 2 additions & 0 deletions src/configs/docker/etc/services.d/php-fpm/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/execlineb -P
php-fpm7 -F
8 changes: 4 additions & 4 deletions src/libraries/adapters/DatabaseMySql.php
Original file line number Diff line number Diff line change
Expand Up @@ -1091,8 +1091,8 @@ public function postAlbumAdd($albumId, $type, $elementIds)
$res = true;
foreach($elementIds as $elementId)
{
$tmpRes = $this->db->execute("REPLACE INTO `{$this->mySqlTablePrefix}elementAlbum`(`owner`,`type`,`element`,`album`) VALUES(:owner,:type,:elementId,:albumId)",
array(':owner' => $this->owner, ':type' => $type, ':elementId' => $elementId, ':albumId' => $albumId));
$tmpRes = $this->db->execute("REPLACE INTO `{$this->mySqlTablePrefix}elementAlbum`(`owner`,`type`,`element`,`album`, `actor`) VALUES(:owner,:type,:elementId,:albumId,:actor)",
array(':owner' => $this->owner, ':type' => $type, ':elementId' => $elementId, ':albumId' => $albumId, ':actor' => $this->getActor()));
$res = $res && $tmpRes !== 0;
}
return $res !== false;
Expand Down Expand Up @@ -2493,8 +2493,8 @@ private function postVersions($id, $versions)
{
// TODO this is gonna fail if we already have the version -- hfiguiere
// Possibly use REPLACE INTO? -- jmathai
$result = $this->db->execute("REPLACE INTO {$this->mySqlTablePrefix}photoVersion (`id`, `owner`, `key`, `path`) VALUES(:id, :owner, :key, :value)",
array(':id' => $id, ':owner' => $this->owner, ':key' => $key, ':value' => $value));
$result = $this->db->execute("REPLACE INTO {$this->mySqlTablePrefix}photoVersion (`id`, `owner`, `key`, `path`, `actor`) VALUES(:id, :owner, :key, :value, :actor)",
array(':id' => $id, ':owner' => $this->owner, ':key' => $key, ':value' => $value, ':actor' => $this->getActor()));
}
// TODO, what type of return value should we have here -- jmathai
return ($result != 1);
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/external/epi/EpiRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function load($file)
if(!file_exists($file))
{
EpiException::raise(new EpiException("Config file ({$file}) does not exist"));
break; // need to simulate same behavior if exceptions are turned off
return; // need to simulate same behavior if exceptions are turned off
}

$parsed_array = parse_ini_file($file, true);
Expand Down
1 change: 1 addition & 0 deletions src/libraries/models/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public function update($id, $params)
{
$params['owner'] = $this->owner;
$params['actor'] = $this->getActor();
$params['extra'] = '';
return $this->db->postTag($id, $params);
}

Expand Down