Files
mattermost/Dockerfile
2026-04-15 16:33:15 -07:00

46 lines
1.7 KiB
Docker

# Use RHEL 9 UBI as the base
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
# Define Mattermost version and architecture
ARG MM_VERSION=11.4.0
ARG MM_PACKAGE=mattermost-${MM_VERSION}-linux-amd64.tar.gz
# Set environment variables
# We include the bin in the PATH and explicitly set the working dir
ENV PATH="/opt/mattermost/bin:${PATH}"
ENV MM_INSTALL_TYPE=docker
# 1. Install necessary dependencies
# 2. Create mattermost user/group
# 3. Create the target directory FIRST
# 4. Download, extract, and move
RUN microdnf update -y && \
microdnf install -y tar gzip shadow-utils ca-certificates findutils && \
groupadd -g 2000 mattermost && \
useradd -u 2000 -g mattermost -m -s /sbin/nologin mattermost && \
# Create the directory before moving things into it
mkdir -p /opt/mattermost && \
curl -L https://releases.mattermost.com/${MM_VERSION}/${MM_PACKAGE} | tar -xz && \
# Move extracted contents into /opt/mattermost
mv mattermost/* /opt/mattermost/ && \
rm -rf mattermost && \
# Create required subdirectories
mkdir -p /opt/mattermost/config /opt/mattermost/data /opt/mattermost/logs \
/opt/mattermost/plugins /opt/mattermost/client/plugins /opt/mattermost/bleve-indexes && \
# Fix permissions
chown -R mattermost:mattermost /opt/mattermost && \
microdnf clean all
# Set the working directory - Mattermost looks for config/ relative to this path
WORKDIR /opt/mattermost
# Mattermost uses these ports
EXPOSE 8065 8067
# Switch to non-root user
USER mattermost
# Start the Mattermost server
# Explicitly point to the config file to avoid the "Permission Denied" on /mattermost
CMD ["mattermost", "--config", "/opt/mattermost/config/config.json"]