Clean backend container

This commit is contained in:
nemunaire 2015-01-13 20:11:37 +01:00 committed by Nemunaire
parent 2ce348a7ed
commit a82ccb10ec
3 changed files with 44 additions and 10 deletions

View File

@ -36,6 +36,7 @@ ADD . /var/www/fic-server/
RUN dpkg -i /var/www/fic-server/libmcrypt-perl*.deb || \ RUN dpkg -i /var/www/fic-server/libmcrypt-perl*.deb || \
(echo "Please build perl-mcrypt first. Consult the given README!"; exit 1) && \ (echo "Please build perl-mcrypt first. Consult the given README!"; exit 1) && \
rm /var/www/fic-server/libmcrypt-perl*.deb && \
ln -sf /var/www/fic-server/nginx-server.conf /etc/nginx/sites-enabled/default && \ ln -sf /var/www/fic-server/nginx-server.conf /etc/nginx/sites-enabled/default && \
ln -sf /var/www/fic-server/php-fpm.conf /etc/php5/fpm/pool.d/www.conf ln -sf /var/www/fic-server/php-fpm.conf /etc/php5/fpm/pool.d/www.conf
@ -51,15 +52,9 @@ RUN ln -sf /var/www/fic-server/onyx/config/sample.root.xml /var/www/fic-server/o
EXPOSE 80/tcp 443/tcp EXPOSE 80/tcp 443/tcp
VOLUME ["/var/www/fic-server/out","/var/www/fic-server/files","/var/www/fic-server/submission","/var/www/fic-server/shared"] VOLUME ["/var/www/fic-server/out","/var/www/fic-server/files","/var/www/fic-server/submission","/var/www/fic-server/shared"]
CMD mkdir -p /var/www/fic-server/logs; \ ENTRYPOINT ["/var/www/fic-server/entrypoint.sh"]
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; \ CMD service nginx start && \
chmod 660 /var/www/fic-server/submission; \
service nginx start && \
service php5-fpm start && \ service php5-fpm start && \
service mysql start && \
./nginx_gen_team.sh > ./shared/nginx-teams.conf && \
echo 'Copying files...' && \
./gen_hash_link_files.sh --copy ./files-in ./files; \
(./launch_local.sh &); \ (./launch_local.sh &); \
/bin/bash /bin/bash

View File

@ -137,7 +137,7 @@ docker rm db_setup
3. Run the database container: 3. Run the database container:
``` ```
docker run -d --name db --volumes-from mysql_data mysql docker run -d --name db --volumes-from mysql_data -e MYSQL_USER=fic -e MYSQL_PASSWORD=anotherpassword -e MYSQL_DATABASE=fic mysql
``` ```
4. Setup the PKI storages: 4. Setup the PKI storages:
@ -168,6 +168,24 @@ docker run --rm -it --volumes-from pki_storage --volumes-from shared_storage pki
TODO next steps TODO next steps
``` ```
7. Build the perl `Mcrypt` debian package
```
docker build -t perl-mcrypt perl-mcrypt/
docker run --name mcrypt_builder perl-mcrypt
docker cp mcrypt_builder:$(docker diff mcrypt_builder | grep -oE '[^ ]+deb$') ./
docker rm mcrypt_builder
```
8. Build and run the backend:
```
docker build -t backend .
docker run --rm -it --link db:db --volumes-from pki_storage --volumes-from shared_storage -v /home/files:/var/www/fic-server/files-in backend
```
Where `/home/files` is your local directory containing all challenge files.
##### Requirements ##### Requirements

21
entrypoint.sh Executable file
View File

@ -0,0 +1,21 @@
#!/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 660 /var/www/fic-server/submission; \
./nginx_gen_team.sh > ./shared/nginx-teams.conf &&
cat <<EOF > /var/www/fic-server/onyx/db/docker.profile.php &&
<?php
if(!defined('ONYX')) exit;
\$___profile['db'] = '$DB_ENV_MYSQL_DATABASE';
\$___profile['host'] = '$DB_PORT_3306_TCP_ADDR';
\$___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 "$@"