Cleaner entrypoint

This commit is contained in:
nemunaire 2015-01-14 10:47:17 +01:00 committed by Nemunaire
parent 1001cdf87a
commit 64219a693d
3 changed files with 26 additions and 14 deletions

View File

@ -1,5 +1,3 @@
# DOCKER-VERSION 1.1.0
# /!\ WARNING: the container generated through this Dockerfile is made only for development purpose; it is NOT SAFE or production ready.
FROM debian:wheezy
@ -31,7 +29,7 @@ RUN useradd -d /var/www/fic-server -M -N -g www-data synchro
WORKDIR /var/www/fic-server
ADD . /var/www/fic-server/
COPY . /var/www/fic-server/
# Configure softwares #################################################
@ -44,7 +42,6 @@ RUN dpkg -i /var/www/fic-server/libmcrypt-perl*.deb || \
# Configure site ######################################################
RUN ln -sf /var/www/fic-server/onyx/config/sample.root.xml /var/www/fic-server/onyx/config/root.xml && \
sed -i "s/1386827772/`date -d 'now + 4 hours' +%s`/" /var/www/fic-server/onyx/config/root.xml && \
sed -i "s/challenge-public//" /var/www/fic-server/onyx/config/root.xml && \
chmod 777 /var/www/fic-server/onyx/cache/ /var/www/fic-server/onyx/cache/templates/cache/ /var/www/fic-server/onyx/cache/templates/compile/
@ -57,5 +54,6 @@ ENTRYPOINT ["/var/www/fic-server/entrypoint.sh"]
CMD service nginx start && \
service php5-fpm start && \
./nginx_gen_team.sh > ./shared/nginx-teams.conf && \
(./launch_local.sh &); \
/bin/bash

View File

@ -7,6 +7,8 @@ fi
# Username of the unpriviledge user that runs scripts
SYNCHRO_USER="synchro"
BASEDIR="/var/www/fic-server"
# Directory where backup should be made
if [ -z "$TO_BCKP" ]
then

View File

@ -1,11 +1,19 @@
#!/bin/bash
mkdir -p /var/www/fic-server/logs; \
chown -R www-data:www-data /var/www/fic-server/shared /var/www/fic-server/PKI; \
chown -R synchro:www-data /var/www/fic-server/submission /var/www/fic-server/logs /var/www/fic-server/out; \
chmod 770 /var/www/fic-server/submission; \
./nginx_gen_team.sh > ./shared/nginx-teams.conf &&
cat <<EOF > /var/www/fic-server/onyx/db/docker.profile.php &&
# Docker entrypoint
cd `dirname "$0"`
. ./config.sh
# Creating directory and set permissions
mkdir -p ${BASEDIR}/logs
chown -R www-data:www-data ${BASEDIR}/shared ${BASEDIR}/PKI
chown -R ${SYNCHRO_USER}:www-data ${BASEDIR}/submission ${BASEDIR}/logs ${BASEDIR}/out
chmod 770 ${BASEDIR}/submission
# Update database profile
cat <<EOF > ${BASEDIR}/onyx/db/docker.profile.php &&
<?php
if(!defined('ONYX')) exit;
@ -15,7 +23,11 @@ if(!defined('ONYX')) exit;
\$___profile['user'] = '$DB_ENV_MYSQL_USER';
\$___profile['pass'] = '$DB_ENV_MYSQL_PASSWORD';
EOF
sed -i 's/"profile">sample</"profile">docker</' /var/www/fic-server/onyx/config/root.xml &&
# echo 'Copying files...' &&
# ./gen_hash_link_files.sh --copy ./files-in ./files &&
exec "$@"
sed -i 's/"profile">sample</"profile">docker</' ${BASEDIR}/onyx/config/root.xml
# Generate hashed path for files
echo 'Copying files...'
${BASEDIR}/gen_hash_link_files.sh --copy ${BASEDIR}/files-in ${BASEDIR}/files
# Continue execution
exec "$@"