Skip to main content

Shenzhen, China

Provision OSticket with Docker (2023)

How to use the docker-osticket repository by Devin Solutions to build a Docker image for running OSTicket version 1.17.3 of osTicket. osTicket is being served by nginx using PHP-FPM with PHP 8.1. PHP mail function is configured to use msmtp to send out-going messages.

Build the OSTicket Image

Start by editing the Dockerfile:

  • Choose a base image, e.g. php:8.1-fpm-alpine3.16
  • Set the OSTicket Version, e.g. v1.17.3
    • Download the source code: wget https://github.com/osTicket/osTicket/releases/download/v1.17.3/osTicket-v1.17.3.zip
    • Check the SHA265 hash by running: sha256sum osTicket-v1.17.3.zip.
    • Add / remove languages and plugins you want to use.

Now you can edit the file accordingly by setting the base image:

FROM php:8.1-fpm-alpine3.16

and the OSTicket release version with hash:

ENV OSTICKET_VERSION=1.17.3 \
    OSTICKET_SHA256SUM=be3ade536a19b875e16fe0d9716e07f3897f5c0cdbd4efe4ff17ab262d98bed3

NGINX and PHP Configuration

As part of the follow image build the root folder will from the repository will be copied into your OSTicket image. This folder contains both the NGINX webproxy and PHP configuration files that you might want to edit:

I changed the NGINX server configuration to use the port 7777 for the web front:

server {
    listen 7777;
    server_name localhost;

The port you use here will be the port you have to open (see Docker-Compose below) to be able to access the frontend.

Execute the Dockerfile

You can now build the OSTicket image by creating a shell script (or just run the command directly):

build_osticket.sh

#!/bin/sh
# Build the osticket image
docker build -t mycompany/osticket .

Replace the mycompany/osticket tag here and further below with the image name you want to use.

Where . has to point to your Dockerfile:

FROM php:8.1-fpm-alpine3.16
RUN set -ex; \
    \
    export CFLAGS="-Os"; \
    export CPPFLAGS="${CFLAGS}"; \
    export LDFLAGS="-Wl,--strip-all"; \
    \
    # Runtime dependencies
    apk add --no-cache \
        c-client \
        icu \
        libintl \
        libpng \
        libzip \
        msmtp \
        nginx \
        openldap \
        runit \
    ; \
    \
    # Build dependencies
    apk add --no-cache --virtual .build-deps \
        ${PHPIZE_DEPS} \
        gettext-dev \
        icu-dev \
        imap-dev \
        libpng-dev \
        libzip-dev \
        openldap-dev \
    ; \
    \
    # Install PHP extensions
    docker-php-ext-configure imap --with-imap-ssl; \
    docker-php-ext-install -j "$(nproc)" \
        gd \
        gettext \
        imap \
        intl \
        ldap \
        mysqli \
        sockets \
        zip \
    ; \
    pecl install apcu; \
    docker-php-ext-enable \
        apcu \
        opcache \
    ; \
    \
    # Create msmtp log
    touch /var/log/msmtp.log; \
    chown www-data:www-data /var/log/msmtp.log; \
    \
    # Create data dir
    mkdir /var/lib/osticket; \
    \
    # Clean up
    apk del .build-deps; \
    rm -rf /tmp/pear /var/cache/apk/*
# DO NOT FORGET TO CHECK THE LANGUAGE PACK DOWNLOAD URL BELOW
ENV OSTICKET_VERSION=1.17.3 \
    OSTICKET_SHA256SUM=be3ade536a19b875e16fe0d9716e07f3897f5c0cdbd4efe4ff17ab262d98bed3
    # OSTICKET_VERSION=1.17.2 \
    # OSTICKET_SHA256SUM=53aa6349c0ee6367d4370cc663a8047d3038f5e0d3668f42b3f90f20534fb717
    # OSTICKET_VERSION=1.17.1 \
    # OSTICKET_SHA256SUM=0c83bade36906d31680ee47ed3c062052d2671bcdf9823bbeb78eeb33d30f801
    # OSTICKET_VERSION=1.17 \
    # OSTICKET_SHA256SUM=296d55cc50782411f0ba81101bc64fc4f6ac65a37772fd75bb5f4dc04d8b364d
RUN set -ex; \
    \
    wget -q -O osTicket.zip https://github.com/osTicket/osTicket/releases/download/\
v${OSTICKET_VERSION}/osTicket-v${OSTICKET_VERSION}.zip; \
    echo "${OSTICKET_SHA256SUM}  osTicket.zip" | sha256sum -c; \
    unzip osTicket.zip 'upload/*'; \
    rm osTicket.zip; \
    mkdir /usr/local/src; \
    mv upload /usr/local/src/osticket; \
    # Hard link the sources to the public directory
    cp -al /usr/local/src/osticket/. /var/www/html; \
    # Remove setup
    rm -r /var/www/html/setup; \
    \
    for lang in ar_EG ar_SA az bg bn bs ca cs da de el es_AR es_ES es_MX et eu fa fi fr gl he hi \
        hr hu id is it ja ka km ko lt lv mk mn ms nl no pl pt_BR pt_PT ro ru sk sl sq sr sr_CS \
        sv_SE sw th tr uk ur_IN ur_PK vi zh_CN zh_TW; do \
        # This URL is the same as what is used by the official osTicket Downloads page. This URL is
        # used even for minor versions >= 14.
        wget -q -O /var/www/html/include/i18n/${lang}.phar \
            https://s3.amazonaws.com/downloads.osticket.com/lang/1.14.x/${lang}.phar; \
    done
RUN set -ex; \
    \
    for plugin in audit auth-2fa auth-ldap auth-passthru auth-password-policy storage-fs; do \
        wget -q -O /var/www/html/include/plugins/${plugin}.phar \
            https://s3.amazonaws.com/downloads.osticket.com/plugin/${plugin}.phar; \
    done; \
    for plugin in auth-oauth2 storage-s3; do \
        wget -q -O /var/www/html/include/plugins/${plugin}.phar \
            https://s3.amazonaws.com/downloads.osticket.com/plugin/1.17.x/${plugin}.phar; \
    done
COPY root /
CMD ["start"]
STOPSIGNAL SIGTERM
EXPOSE 80
HEALTHCHECK CMD curl -fIsS http://localhost/ || exit 1

Verify that the image was build:

docker images
REPOSITORY         TAG                       IMAGE ID       CREATED          SIZE
mycompany/osticket    latest                    4d07786f7685   28 minutes ago   265MB
<none>             <none>                    c1a9187feeef   37 minutes ago   98.2MB
php                8.1-fpm-alpine3.16        8e60c32353e1   5 days ago       73.9MB

Test the OSTicket Image

Verify that the image you just build actually works with Docker-Compose. Create the following compose file and run:

docker-compose up

docker-compose.yml

version: '3.8'
services:

  osticket-app:
    image: mycompany/osticket:latest
    container_name: osticket
    environment:
      - CONTAINER_NAME=osticket
      - MYSQL_USER=osticket
      - MYSQL_HOST=maria-db
      - MYSQL_PASSWORD=mypassword
      - MYSQL_DATABASE=osticket
      - INSTALL_SECRET=verysecret
      - INSTALL_EMAIL=info@instar.de
      - INSTALL_URL=https://my.domain.com/
      - INSTALL_NAME=OSTicket
      - ADMIN_FIRSTNAME=Mike
      - ADMIN_LASTNAME=Polinowski
      - ADMIN_EMAIL=m.polinowski@my.smtp-server.com
      - CRON_INTERVAL=1
      - SMTP_HOST=my.smtp-server.com
      - SMTP_PORT=587
      - SMTP_FROM=info@my.smtp-server.com
      - SMTP_TLS=1
    ports:
      - 7777:7777
    depends_on:
      - osticket-db
    networks:
      - services
    links:
      - osticket-db
    restart: unless-stopped

  osticket-db:
    image: mariadb:latest
    container_name: maria-db
    environment:
      - MYSQL_ROOT_PASSWORD=myrootpassword
      - MYSQL_USER=osticket
      - MYSQL_PASSWORD=mypassword
      - MYSQL_DATABASE=osticket
      - CONTAINER_NAME=maria-db
    networks:
      - services
    restart: unless-stopped

networks:
  services:
    external: false

The web frontend will come up on localhost:7777:

Provision OSticket with Docker (2023)

And the agent panel on http://localhost:7777/scp/login.php - the default login is:

  • Username: ostadmin
  • Password: Admin1

Provision OSticket with Docker (2023)

Provision OSticket with Docker (2023)