Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
69 changes: 69 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
FROM ubuntu:jammy
LABEL org.opencontainers.image.authors="Bohdan Klymonchuk" \
org.opencontainers.image.title="znuny" \
org.opencontainers.image.description="Based on https://doc.znuny.org/"

# Znuny version and environment
ARG ZNUNY_VERSION=7.1.7
ARG ZNUNY_USER=znuny
ENV ZNUNY_HOME=/opt/znuny-${ZNUNY_VERSION} \
PATH=$PATH:/opt/znuny-${ZNUNY_VERSION}/bin

# Install all system packages and Perl modules, then clean caches
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
wget apache2 mariadb-client cpanminus cron vim \
libdbd-odbc-perl libapache2-mod-perl2 \
libdbd-mysql-perl libtimedate-perl libnet-dns-perl libnet-ldap-perl \
libio-socket-ssl-perl libpdf-api2-perl libsoap-lite-perl \
libtext-csv-xs-perl libjson-xs-perl libapache-dbi-perl \
libxml-libxml-perl libxml-libxslt-perl libyaml-perl \
libarchive-zip-perl libcrypt-eksblowfish-perl libencode-hanextra-perl \
libmail-imapclient-perl libtemplate-perl libdatetime-perl libmoo-perl \
bash-completion libyaml-libyaml-perl libjavascript-minifier-xs-perl \
libcss-minifier-xs-perl libauthen-sasl-perl libauthen-ntlm-perl \
libdbd-pg-perl libcrypt-jwt-perl libcrypt-openssl-x509-perl \
libhash-merge-perl libical-parser-perl libspreadsheet-xlsx-perl \
nullmailer uuid-dev build-essential && \
echo "smtp.unibas.ch" > /etc/nullmailer/remotes && \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN cpanm --notest --force Jq Data::UUID && \
apt-get purge -y uuid-dev build-essential && \
apt-get autoremove -y && \
apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR ${ZNUNY_HOME}
COPY . .

# Create ZNUNY user, configure and set permissions
RUN useradd -d ${ZNUNY_HOME} -c "Znuny user" \
-g www-data -s /bin/bash -M -N ${ZNUNY_USER} && \
cp Kernel/Config.pm.dist Kernel/Config.pm && \
sed -i "s/\$Self->{DatabaseHost} = '127\.0\.0\.1';/\$Self->{DatabaseHost} = 'znuny_db';/" Kernel/Config.pm && \
bin/znuny.SetPermissions.pl --znuny-user ${ZNUNY_USER}

# Rename default cron jobs
RUN su - znuny -c "cd ${ZNUNY_HOME}/var/cron && for f in *.dist; do cp \$f \$(basename \$f .dist); done "

# Configure Apache for Znuny
RUN a2dismod mpm_event && \
a2enmod mpm_prefork perl headers deflate filter cgi rewrite && \
ln -s ${ZNUNY_HOME}/scripts/apache2-httpd.include.conf /etc/apache2/conf-available/zzz_znuny.conf && \
a2enconf zzz_znuny && \
echo "RedirectMatch ^/$ /znuny/index.pl" >> /etc/apache2/apache2.conf

# Fix file permissions
RUN find ${ZNUNY_HOME}/var/httpd -type d -exec chmod 775 {} \; && \
find ${ZNUNY_HOME}/var/httpd -type f -exec chmod 664 {} \; && \
chown -R ${ZNUNY_USER}:www-data /tmp

RUN ln -s ${ZNUNY_HOME} /opt/znuny && \
ln -s ${ZNUNY_HOME} /opt/otrs && \
mv ${ZNUNY_HOME}/Kernel/System/Ticket/CustomExample.pm ${ZNUNY_HOME}/Kernel/System/Ticket/Custom.pm
Comment thread
stackdone marked this conversation as resolved.

EXPOSE 80

# Start services and launch Apache in foreground
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["service nullmailer start && service cron start && source /etc/apache2/envvars && apache2 -DFOREGROUND"]
51 changes: 51 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
networks:
znuny-net:
driver: bridge

volumes:
znuny_db_data:
znuny_httpd_data:

services:
znuny:
build:
context: .
dockerfile: Dockerfile
image: znuny:${ZNUNY_VERSION:-7.1.7}
container_name: znuny_httpd
mem_limit: ${ZNUNY_MEMLIMIT:-2048m}
privileged: true
depends_on:
- mariadb
volumes:
- znuny_httpd_data:/opt/znuny
restart: ${RESTART:-unless-stopped}
ports:
- "${HTTP_PORT:-8080}:80"
networks:
- znuny-net
labels:
org.label-schema.group: "znuny"

mariadb:
image: mariadb:${MARIADB_VERSION:-11.4.7}
container_name: znuny_db
mem_limit: ${ZNUNY_DB_MEMLIMIT:-2048m}
environment:
MYSQL_ROOT_PASSWORD: ${ROOT_PASS:-root-pass}
MYSQL_DATABASE: ${DATA_BASE_NAME:-znuny}
MYSQL_USER: ${DB_USER:-znuny}
MYSQL_PASSWORD: ${DB_USER_PASS:-some-pass}
volumes:
- znuny_db_data:/var/lib/mysql
restart: ${RESTART:-unless-stopped}
ports:
- "${DB_PORT:-3306}:3306"
networks:
- znuny-net
command: [
"--max_allowed_packet=256M",
"--innodb_log_file_size=512M"
]
labels:
org.label-schema.group: "znuny"