diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d8fe4fa70f618843e9ab2df67167b49565c71f25 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.project diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e5b2d8cd97f2321d519ce0414c9d3ed02b58100e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +FROM faas/faas-shib:1.0-SNAPSHOT + +ARG FAAS_REGISTRY_IMAGE +ARG FAAS_REGISTRY_NAME +ARG FAAS_REGISTRY_VERSION + +RUN echo $FAAS_REGISTRY_IMAGE > /faas-docker-image +RUN echo $FAAS_REGISTRY_NAME > /faas-docker-name +RUN echo $FAAS_REGISTRY_VERSION > /faas-docker-version + +RUN apt-get -q update && \ + apt-get install -y memcached apache2 composer git mc wget && \ + apt-get install -y php-mysql php-curl php-memcached php-apcu php-cli php-bcmath php-xml libapache2-mod-php && \ + apt-get -y autoremove && \ + apt-get -y clean + +RUN a2enmod rewrite + +RUN git clone https://github.com/Edugate/Jagger /opt/rr3 && cd /opt/rr3 && git checkout v1.8.0 +RUN git clone https://github.com/bcit-ci/CodeIgniter.git /opt/codeigniter && cd /opt/codeigniter && git checkout 3.1.11 + +RUN cd /opt/rr3 && bash install.sh && \ + cd /opt/rr3/application/config && \ + cp config-default.php config.php && \ + cp config_rr-default.php config_rr.php && \ + cp database-default.php database.php && \ + cp email-default.php email.php && \ + cp memcached-default.php memcached.php + +RUN cp /opt/codeigniter/index.php /opt/rr3/index.php && \ + sed -i 's#$system_path = \x27system\x27;#$system_path = \x27/opt/codeigniter/system\x27;#' /opt/rr3/index.php && \ + cd /opt/rr3/application && \ + composer install + +EXPOSE 80 + +COPY ./conf/etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available +COPY ./conf/etc/entrypoint /etc/entrypoint + +ENTRYPOINT ["/etc/entrypoint"] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..3324a438525da16a6fd06942d10e6f0049cc16e8 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +# import config file +config ?= conf/faas-registry.cnf +include $(config) +export $(shell sed 's/=.*//' $(config)) + + +.DEFAULT_GOAL := help + +build: # build container + docker build -t ${FAAS_REGISTRY_IMAGE} --build-arg FAAS_REGISTRY_NAME=${FAAS_REGISTRY_NAME} --build-arg FAAS_REGISTRY_IMAGE=${FAAS_REGISTRY_IMAGE} --build-arg FAAS_REGISTRY_VERSION=${FAAS_REGISTRY_VERSION} . + +build-nc: # build container without caching + docker build --no-cache -t ${FAAS_REGISTRY_IMAGE} --build-arg FAAS_REGISTRY_NAME=${FAAS_REGISTRY_NAME} --build-arg FAAS_REGISTRY_IMAGE=${FAAS_REGISTRY_IMAGE} --build-arg FAAS_REGISTRY_VERSION=${FAAS_REGISTRY_VERSION} . + +run: # run container + docker run -i -t --detach --rm --env-file=$(config) -p=${FAAS_REGISTRY_PORT}:80 --name="${FAAS_REGISTRY_NAME}" ${FAAS_REGISTRY_IMAGE} + +run-nd: # run container in no-deamon mode + docker run -i -t --rm --env-file=$(config) -p=${FAAS_REGISTRY_PORT}:80 --name="${FAAS_REGISTRY_NAME}" ${FAAS_REGISTRY_IMAGE} + +up: build run # build and run container + +logs: # print docker logs + docker logs ${FAAS_REGISTRY_NAME} + +stop: # stop container + docker stop ${FAAS_REGISTRY_NAME} + +version: # print current component version + @echo ${FAAS_REGISTRY_VERSION} + +help: # this help + @awk 'BEGIN {FS = ":.*?# "} /^[a-zA-Z_-]+:.*?# / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) diff --git a/README.md b/README.md index 5c26222d0a8af30f251e685a429500be353cdf61..ce6b3eb52f427e7fe875c9fe11cc1cc656eb0c65 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,31 @@ # FaaS-Registry +Build docker image with debian (10.7) and Jagger +## structure +`_conf/`_ - directory with configuration files + + +## build image +To build `faas-registry` docker image +` +make build +` + + +## run image +To run `faas-registry` docker image +` +make run +` + +## additional commands +``` +build build container +build-nc build container without caching +run run container +run-nd run container in no-deamon mode +up build and run container +logs print docker logs +stop stop container +version print current component version +``` diff --git a/conf/etc/apache2/sites-available/000-default.conf b/conf/etc/apache2/sites-available/000-default.conf new file mode 100644 index 0000000000000000000000000000000000000000..0e64b399608357ec4a66bff4cd61467dbb8fa701 --- /dev/null +++ b/conf/etc/apache2/sites-available/000-default.conf @@ -0,0 +1,39 @@ +<VirtualHost *:80> + # The ServerName directive sets the request scheme, hostname and port that + # the server uses to identify itself. This is used when creating + # redirection URLs. In the context of virtual hosts, the ServerName + # specifies what hostname must appear in the request's Host: header to + # match this virtual host. For the default virtual host (this file) this + # value is not decisive as it is used as a last resort host regardless. + # However, you must set it for any further virtual host explicitly. + #ServerName www.example.com + + ServerAdmin webmaster@localhost + DocumentRoot /opt/rr3 + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + Alias /rr3 /opt/rr3 + <Directory /opt/rr3> + Require all granted + + RewriteEngine On + RewriteBase /rr3 + RewriteCond $1 !^(Shibboleth\.sso|index\.php|logos|signedmetadata|flags|images|app|schemas|fonts|styles|images|js|robots\.txt|pub|includes) + RewriteRule ^(.*)$ /rr3/index.php?/$1 [L] + </Directory> + + <Directory /opt/rr3/application> + Require all granted + </Directory> + + # For most configuration files from conf-available/, which are + # enabled or disabled at a global level, it is possible to + # include a line for only one particular virtual host. For example the + # following line enables the CGI configuration for this host only + # after it has been globally disabled with "a2disconf". + #Include conf-available/serve-cgi-bin.conf +</VirtualHost> + + diff --git a/conf/etc/entrypoint b/conf/etc/entrypoint new file mode 100755 index 0000000000000000000000000000000000000000..e55bf3a0e09d6afff8d877014abc82359edc4270 --- /dev/null +++ b/conf/etc/entrypoint @@ -0,0 +1,11 @@ +#! /bin/bash + +sed -i '/imklog/s/^/#/' /etc/rsyslog.conf + +sed -E -i -e 's/max_execution_time = 30/max_execution_time = 60/' /etc/php/7.4/apache2/php.ini +sed -E -i -e 's/memory_limit = 128M/memory_limit = 256M/' /etc/php/7.4/apache2/php.ini + + +sed -i 's#$config\[\x27base_url\x27\]\s=\s\x27\x27#$config\[\x27base_url\x27\] = \x27'${FAAS_REGISTRY_BASE_URL}'\x27#g' /opt/rr3/application/config/config.php + +exec supervisord -c /etc/supervisord.conf diff --git a/conf/faas-registry.cnf b/conf/faas-registry.cnf new file mode 100644 index 0000000000000000000000000000000000000000..529e3880a7f90bf61823256a8d6f96ecad6f2284 --- /dev/null +++ b/conf/faas-registry.cnf @@ -0,0 +1,8 @@ +FAAS_REGISTRY_REPO=faas +FAAS_REGISTRY_NAME=faas-registry +FAAS_REGISTRY_VERSION=1.0-SNAPSHOT +FAAS_REGISTRY_IMAGE=${FAAS_REGISTRY_REPO}/${FAAS_REGISTRY_NAME}:${FAAS_REGISTRY_VERSION} + +FAAS_REGISTRY_PORT=9080 +FAAS_REGISTRY_BASE_URL=http://localhost:9080/rr3/ +FAAS_REGISTRY_TIMEZONE=Europe/Warsaw