Commit b11e62a2 by Christophe Angeli

Increase restyaboard version to v0.4.2

parent af45c7cc
FROM debian:wheezy-backports FROM debian:stretch
ARG TERM=linux ENV RESTYABOARD_VERSION=v0.4.2 \
ARG DEBIAN_FRONTEND=noninteractive ROOT_DIR=/usr/share/nginx/html \
CONF_FILE=/etc/nginx/conf.d/restyaboard.conf \
# restyaboard version SMTP_DOMAIN=localhost \
ENV restyaboard_version=v0.2.1 SMTP_USERNAME=root \
SMTP_PASSWORD=root \
SMTP_SERVER=localhost \
SMTP_PORT=465
# update & install package # update & install package
RUN apt-get update --yes RUN apt-get update && \
RUN apt-get install --yes zip curl cron postgresql nginx echo "postfix postfix/mailname string localhost" | debconf-set-selections && \
RUN apt-get install --yes php5 php5-fpm php5-curl php5-pgsql php5-imagick libapache2-mod-php5 echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections && \
RUN echo "postfix postfix/mailname string example.com" | debconf-set-selections \ TERM=linux DEBIAN_FRONTEND=noninteractive apt-get install -y \
&& echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections \ cron \
&& apt-get install -y postfix curl \
imagemagick \
jq \
libpq5 \
nginx \
php7.0 \
php7.0-cli \
php7.0-common \
php7.0-curl \
php7.0-fpm \
php7.0-imagick \
php7.0-imap \
php7.0-ldap \
php7.0-mbstring \
php7.0-pgsql \
php7.0-xml \
postfix \
postgresql-client \
unzip
# deploy app # deploy app
RUN curl -L -o /tmp/restyaboard.zip https://github.com/RestyaPlatform/board/releases/download/${restyaboard_version}/board-${restyaboard_version}.zip \ RUN curl -L -s -o /tmp/restyaboard.zip https://github.com/RestyaPlatform/board/releases/download/${RESTYABOARD_VERSION}/board-${RESTYABOARD_VERSION}.zip && \
&& unzip /tmp/restyaboard.zip -d /usr/share/nginx/html \ unzip /tmp/restyaboard.zip -d ${ROOT_DIR} && \
&& rm /tmp/restyaboard.zip rm /tmp/restyaboard.zip
# extensions
RUN curl -L -s -o /tmp/apps.json https://raw.githubusercontent.com/RestyaPlatform/board-apps/master/apps.json && \
chmod -R go+w /tmp/apps.json && \
mkdir -p "${ROOT_DIR}/client/apps" && \
for fid in $(jq -r '.[] | .id + "-v" + .version' /tmp/apps.json); \
do \
curl -L -s -G -o /tmp/$fid.zip https://github.com/RestyaPlatform/board-apps/releases/download/v1/$fid.zip; \
file /tmp/$fid.zip | grep Zip && unzip /tmp/$fid.zip -d "${ROOT_DIR}/client/apps"; \
rm /tmp/$fid.zip; \
done && \
rm /tmp/apps.json
# setting app # setting app
WORKDIR /usr/share/nginx/html WORKDIR ${ROOT_DIR}
RUN cp -R media /tmp/ \ RUN rm /etc/nginx/sites-enabled/default && \
&& cp restyaboard.conf /etc/nginx/conf.d \ cp restyaboard.conf ${CONF_FILE} && \
&& sed -i 's/^.*listen.mode = 0660$/listen.mode = 0660/' /etc/php5/fpm/pool.d/www.conf \ sed -i "s/server_name.*$/server_name \"localhost\";/" ${CONF_FILE} && \
&& sed -i 's|^.*fastcgi_pass.*$|fastcgi_pass unix:/var/run/php5-fpm.sock;|' /etc/nginx/conf.d/restyaboard.conf \ sed -i "s|listen 80.*$|listen 80;|" ${CONF_FILE} && \
&& sed -i -e "/fastcgi_pass/a fastcgi_param HTTPS 'off';" /etc/nginx/conf.d/restyaboard.conf sed -i "s|root.*html|root ${ROOT_DIR}|" ${CONF_FILE} && \
chown -R www-data:www-data . && \
chmod -R 777 media && \
chmod -R 777 client/img && \
chmod -R 777 tmp
# volume # cleanup
VOLUME /usr/share/nginx/html/media RUN apt-get autoremove -y --purge && \
apt-get clean
# entry point # entry point
COPY docker-entrypoint.sh / COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"] ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["start"] CMD ["start"]
# expose port
EXPOSE 80
...@@ -13,12 +13,21 @@ Build Restyaboard in Docker. ...@@ -13,12 +13,21 @@ Build Restyaboard in Docker.
Quick Start Quick Start
------------------------------ ------------------------------
Build image and Run container using docker-compose. Build image and Run containers using docker-compose.
``` bash ``` bash
git clone https://github.com/namikingsoft/docker-restyaboard.git git clone https://github.com/cangeli/docker-restyaboard.git
cd docker-restyaboard cd docker-restyaboard
```
Edit docker-compose.yml and modify the environment variables to suit your needs.
There are default values for the SMTP configuration,
so you can delete those SMTP_* variables if you don't need this feature.
Also, you can choose to delete the local backup service (based on https://hub.docker.com/r/prodrigestivill/postgres-backup-local/).
``` bash
docker-compose up -d docker-compose up -d
``` ```
...@@ -42,11 +51,11 @@ Password: restya ...@@ -42,11 +51,11 @@ Password: restya
Change Restyaboard Version Change Restyaboard Version
------------------------------ ------------------------------
Edit restyaboard/Dockerfile. Edit Dockerfile.
Available version is https://github.com/RestyaPlatform/board/releases Available version on https://github.com/RestyaPlatform/board/releases
``` ```
ENV restyaboard_version=REPLACE_ME ENV RESTYABOARD_VERSION=REPLACE_ME
``` ```
In case of upgrade version, rebuild image and recreate container. In case of upgrade version, rebuild image and recreate container.
...@@ -62,13 +71,14 @@ If you want to upgrade database, e.g. ...@@ -62,13 +71,14 @@ If you want to upgrade database, e.g.
```sh ```sh
docker-compose run --rm restyaboard bash docker-compose run --rm restyaboard bash
export PGHOST=$POSTGRES_PORT_5432_TCP_ADDR export PGHOST=${POSTGRES_HOST}
export PGPORT=$POSTGRES_PORT_5432_TCP_PORT export PGPORT=5432
export PGUSER=$POSTGRES_ENV_POSTGRES_USER export PGUSER=${POSTGRES_USER}
export PGPASSWORD=$POSTGRES_ENV_POSTGRES_PASSWORD export PGPASSWORD=${POSTGRES_PASSWORD}
export PGDATABASE=${POSTGRES_DB}
... ...
psql -d restyaboard -f sql/upgrade-0.1.3-0.1.4.sql psql -f sql/upgrade-0.4.2-0.4.3.sql
psql -d restyaboard -f sql/upgrade-0.1.4-0.1.5.sql psql -f sql/upgrade-0.4.3-0.4.4.sql
... ...
exit exit
``` ```
......
data: version: '2'
image: busybox
services:
restyaboard:
build: .
image: restyaboard:4.0.2
ports:
- 1234:80
volumes: volumes:
- /usr/share/elasticsearch/data - /var/opt/restya/media:/usr/share/nginx/html/media
- /var/lib/postgresql/data environment:
- /usr/share/nginx/html/media - POSTGRES_HOST=postgres
command: tail -f /dev/null - POSTGRES_USER=admin
- POSTGRES_PASSWORD=admin
- POSTGRES_DB=restyaboard
depends_on:
- postgres
networks:
- restya-net
restart: always restart: always
elasticsearch: postgres:
image: elasticsearch image: postgres:9.6
volumes_from: ports:
- data - "5432:5432"
environment:
- POSTGRES_HOST=postgres
- POSTGRES_USER=admin
- POSTGRES_PASSWORD=admin
- POSTGRES_DB=restyaboard
networks:
- restya-net
restart: always restart: always
postgres: backup:
image: postgres image: prodrigestivill/postgres-backup-local
volumes:
- /var/opt/restya/pgbackups:/backups
environment: environment:
POSTGRES_USER: postgres - POSTGRES_HOST=postgres
POSTGRES_PASSWORD: something - POSTGRES_USER=admin
volumes_from: - POSTGRES_PASSWORD=admin
- data - POSTGRES_DB=restyaboard
- POSTGRES_EXTRA_OPTS=-Z9 --schema=public --blobs
- SCHEDULE=@every 2h
- BACKUP_KEEP_DAYS=2
- BACKUP_KEEP_WEEKS=4
- BACKUP_KEEP_MONTHS=6
depends_on:
- postgres
networks:
- restya-net
restart: always restart: always
restyaboard: networks:
build: . restya-net:
links:
- elasticsearch:elasticsearch
- postgres:postgres
ports:
- 1234:80
volumes_from:
- data
restart: always
#!/bin/bash #!/bin/bash
set -e set -e
if [ "$1" = 'start' ]; then if [ "$1" = 'start' ]; then
# config # config
sed -i "s/^.*'R_DB_NAME'.*$/define('R_DB_NAME', 'restyaboard');/g" \ sed -i "s/^.*'R_DB_HOST'.*$/define('R_DB_HOST', '${POSTGRES_HOST}');/g" \
/usr/share/nginx/html/server/php/config.inc.php ${ROOT_DIR}/server/php/config.inc.php
sed -i "s/^.*'R_DB_USER'.*$/define('R_DB_USER', '${POSTGRES_ENV_POSTGRES_USER}');/g" \ sed -i "s/^.*'R_DB_PORT'.*$/define('R_DB_PORT', '5432');/g" \
/usr/share/nginx/html/server/php/config.inc.php ${ROOT_DIR}/server/php/config.inc.php
sed -i "s/^.*'R_DB_PASSWORD'.*$/define('R_DB_PASSWORD', '${POSTGRES_ENV_POSTGRES_PASSWORD}');/g" \ sed -i "s/^.*'R_DB_USER'.*$/define('R_DB_USER', '${POSTGRES_USER}');/g" \
/usr/share/nginx/html/server/php/config.inc.php ${ROOT_DIR}/server/php/config.inc.php
sed -i "s/^.*'R_DB_HOST'.*$/define('R_DB_HOST', '${POSTGRES_PORT_5432_TCP_ADDR}');/g" \ sed -i "s/^.*'R_DB_PASSWORD'.*$/define('R_DB_PASSWORD', '${POSTGRES_PASSWORD}');/g" \
/usr/share/nginx/html/server/php/config.inc.php ${ROOT_DIR}/server/php/config.inc.php
sed -i "s/^.*'R_DB_PORT'.*$/define('R_DB_PORT', '${POSTGRES_PORT_5432_TCP_PORT}');/g" \ sed -i "s/^.*'R_DB_NAME'.*$/define('R_DB_NAME', '${POSTGRES_DB}');/g" \
/usr/share/nginx/html/server/php/config.inc.php ${ROOT_DIR}/server/php/config.inc.php
# cron shell # postfix
chmod +x /usr/share/nginx/html/server/php/shell/*.sh echo "[${SMTP_SERVER}]:${SMTP_PORT} ${SMTP_USERNAME}:${SMTP_PASSWORD}" > /etc/postfix/sasl_passwd
echo '*/5 * * * * php /usr/share/nginx/htmlserver/php/shell/indexing_to_elasticsearch.sh' > /var/spool/cron/root postmap /etc/postfix/sasl_passwd
echo '*/5 * * * * php /usr/share/nginx/htmlserver/php/shell/instant_email_notification.sh' > /var/spool/cron/root echo "www-data@${SMTP_DOMAIN} ${SMTP_USERNAME}" > /etc/postfix/sender_canonical
echo '0 * * * * php /usr/share/nginx/htmlserver/php/shell/periodic_email_notification.sh' > /var/spool/cron/root postmap /etc/postfix/sender_canonical
echo '*/5 * * * * php /usr/share/nginx/htmlserver/php/shell/webhook.sh' > /var/spool/cron/root sed -i '/mydomain.*/d' /etc/postfix/main.cf
echo '*/5 * * * * php /usr/share/nginx/htmlserver/php/shell/card_due_notification.sh' > /var/spool/cron/root sed -i '/myhostname.*/d' /etc/postfix/main.cf
echo '*/5 * * * * php /usr/share/nginx/htmlserver/php/shell/imap.sh' > /var/spool/cron/root sed -i '/myorigin.*/d' /etc/postfix/main.cf
sed -i '/mydestination.*/d' /etc/postfix/main.cf
# media sed -i "$ a mydomain = ${SMTP_DOMAIN}" /etc/postfix/main.cf
cp -R /tmp/media /usr/share/nginx/html/ sed -i "$ a myhostname = localhost" /etc/postfix/main.cf
chmod -R go+w /usr/share/nginx/html/media sed -i '$ a myorigin = $mydomain' /etc/postfix/main.cf
chmod -R go+w /usr/share/nginx/html/client/img sed -i '$ a mydestination = localhost, $myhostname, localhost.$mydomain' /etc/postfix/main.cf
sed -i '$ a sender_canonical_maps = hash:/etc/postfix/sender_canonical' /etc/postfix/main.cf
sed -i "s/relayhost =.*$/relayhost = [${SMTP_SERVER}]:${SMTP_PORT}/" /etc/postfix/main.cf
sed -i '/smtp_.*/d' /etc/postfix/main.cf
sed -i '$ a smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache' /etc/postfix/main.cf
sed -i '$ a smtp_sasl_auth_enable = yes' /etc/postfix/main.cf
sed -i '$ a smtp_sasl_security_options = noanonymous' /etc/postfix/main.cf
sed -i '$ a smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd' /etc/postfix/main.cf
sed -i '$ a smtp_use_tls = yes' /etc/postfix/main.cf
sed -i '$ a smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt' /etc/postfix/main.cf
sed -i '$ a smtp_tls_wrappermode = yes' /etc/postfix/main.cf
sed -i '$ a smtp_tls_security_level = encrypt' /etc/postfix/main.cf
# init db # init db
export PGHOST=$POSTGRES_PORT_5432_TCP_ADDR export PGHOST=${POSTGRES_HOST}
export PGPORT=$POSTGRES_PORT_5432_TCP_PORT export PGPORT=5432
export PGUSER=$POSTGRES_ENV_POSTGRES_USER export PGUSER=${POSTGRES_USER}
export PGPASSWORD=$POSTGRES_ENV_POSTGRES_PASSWORD export PGPASSWORD=${POSTGRES_PASSWORD}
export PGDATABASE=${POSTGRES_DB}
set +e set +e
while : while :
do do
...@@ -43,15 +55,21 @@ if [ "$1" = 'start' ]; then ...@@ -43,15 +55,21 @@ if [ "$1" = 'start' ]; then
fi fi
sleep 1 sleep 1
done done
psql -c "CREATE DATABASE restyaboard ENCODING 'UTF8'" if [ "$(psql -c '\d')" = "No relations found." ]; then
if [ "$?" = 0 ]; then psql -f "${ROOT_DIR}/sql/restyaboard_with_empty_data.sql"
psql -d restyaboard -f /usr/share/nginx/html/sql/restyaboard_with_empty_data.sql
fi fi
set -e set -e
# cron shell
echo "*/5 * * * * ${ROOT_DIR}/server/php/shell/instant_email_notification.sh" >> /var/spool/cron/crontabs/root
echo "0 * * * * ${ROOT_DIR}/server/php/shell/periodic_email_notification.sh" >> /var/spool/cron/crontabs/root
echo "*/30 * * * * ${ROOT_DIR}/server/php/shell/imap.sh" >> /var/spool/cron/crontabs/root
echo "*/5 * * * * ${ROOT_DIR}/server/php/shell/webhook.sh" >> /var/spool/cron/crontabs/root
echo "*/5 * * * * ${ROOT_DIR}/server/php/shell/card_due_notification.sh" >> /var/spool/cron/crontabs/root
# service start # service start
service cron start service cron start
service php5-fpm start service php7.0-fpm start
service nginx start service nginx start
service postfix start service postfix start
...@@ -60,4 +78,3 @@ if [ "$1" = 'start' ]; then ...@@ -60,4 +78,3 @@ if [ "$1" = 'start' ]; then
fi fi
exec "$@" exec "$@"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment