# Docker Guide

## Introduction

Openfire can be deployed as part of a container architecture. This document covers how the official images are built, how to deploy them, and how you can build your own.

Topics that are covered in this document:

## Builds

You can build the container image locally as you might any other, using:

    docker build . -t openfire:mytag

Note that Openfire is a large application in a monorepo with a sizeable number of dependencies, and as such doesn't use a multi-stage build for Docker. Instead it builds an image from an already compiled repository. For more repeatable builds, try:

    build/docker/buildWithDocker.sh

## Usage

You can run a simple container with:

    docker run --rm -d -p 5222:5222 -p 5269:5269 -p 7070:7070 -p 7443:7443 -p 9090:9090 igniterealtime/openfire:sometag

and configure for the internal database. You can add volumes to achieve persistence between restarts and upgrades.

For more complex or productionised setups, you could use docker-compose.

Example docker configuration

    openfire:
        image: "igniterealtime/openfire:sometag"
        ports:
          - "5222:5222"
          - "5269:5269"
          - "7070:7070"
          - "7443:7443"
          - "9090:9090"
        depends_on:
          - "postgres_service"
        volumes:
          - ./data/conf:/var/lib/openfire/conf
          - ./wait-for-it.sh:/wait-for-it.sh
        command: ["/wait-for-it.sh", "postgres_service:5432", "--", "/sbin/entrypoint.sh"]

In this example, we've used wait-for-it to allow a postgres database service (not shown) to finish launching prior to starting Openfire. This allows us to have premade files in /data/conf with which to launch Openfire.