Compare commits

..

9 Commits

Author SHA1 Message Date
Carlos Panato
11f5d3d7b4
bump to 5.9.8 2020-01-13 13:54:44 +01:00
Carlos Panato
e9b95bafd2
bump to 5.9.7 2019-12-19 14:24:15 +01:00
Carlos Panato
788336f03c
bump to 5.9.6 2019-10-30 07:32:45 +01:00
Carlos Panato
3bd16d1827
skipping circleci 2019-10-14 14:14:01 +02:00
Carlos Panato
b29eebc215
bump to 5.9.5 2019-10-14 14:11:11 +02:00
Carlos Panato
ce9a1a1ad3
bump alpine version and mm 2019-08-22 09:16:24 +02:00
Carlos Panato
504cff3a31
bump to 5.9.3 2019-07-19 15:35:25 +02:00
Carlos Panato
623c125ed0
bump to 5.9.2 2019-06-21 10:24:54 +02:00
Carlos Panato
4330bd4c14
update to 5.9.1 2019-04-24 11:09:16 +02:00
19 changed files with 98 additions and 172 deletions

View File

@ -1,3 +1,5 @@
sudo: required
services: services:
- docker - docker

View File

@ -1,5 +0,0 @@
# Code Contribution Guidelines
Thank you for your interest in contributing! Please see the [Mattermost Contribution Guide](https://developers.mattermost.com/contribute/getting-started/) which describes the process for making code contributions across Mattermost projects and [join our "Contributors" community channel](https://community.mattermost.com/core/channels/tickets) to ask questions from community members and the Mattermost core team.
When you submit a pull request, it goes through a [code review process outlined here](https://developers.mattermost.com/contribute/getting-started/code-review/).

View File

@ -18,9 +18,10 @@ The following people help to maintain this open source project:
| Current Maintainer(s) | Start Date | | Current Maintainer(s) | Start Date |
|:--------------------------------------|:--------------| |:--------------------------------------|:--------------|
| Kyâne Pichou - @pichouk | Jun 01 2017 |
| Carlos Tadeu Panato Junior - @cpanato | Feb 18 2018 | | Carlos Tadeu Panato Junior - @cpanato | Feb 18 2018 |
In case something happens where no maintainers are able to complete their responsibilities, the following sponsoring organization can help find a new maintainer: In case something happens where no maintainers are able to complete their responsibilies, the following sponsoring organization can help find a new maintainer:
| Sponsoring Organization | Start Date | | Sponsoring Organization | Start Date |
|:-------------------------------|:--------------| |:-------------------------------|:--------------|
@ -55,11 +56,10 @@ Maintainer(s) should periodically review pull requests and issues submitted to p
PREVIOUS MAINTAINERS PREVIOUS MAINTAINERS
| Maintainer | Start Date | End Date | | Maintainer | Start Date | End Date |
|:------------------------|:--------------|:------------| |:-----------------------|:--------------|:------------|
| Yi EungJun - @npcode | Nov 26 2015 | Nov 30 2016 | | Yi EungJun - @npcode | Nov 26 2015 | Nov 30 2016 |
| Pan Luo - @xcompass | Nov 30 2015 | Feb 21 2019 | | Pan Luo - @xcompass | Nov 30 2015 | Feb 21 2019 |
| Kyâne Pichou - @pichouk | Jun 01 2017 | Aug 15 2019 |
CREATOR CREATOR

View File

@ -1,12 +1,6 @@
# Production Docker deployment for Mattermost # Production Docker deployment for Mattermost
## WARNING: This project enables deployment of a Mattermost server in a multi-node production configuration using Docker.
The current state of this repository doesn't work out-of-the box since Mattermost server v5.31+ requires PostgreSQL versions of 10 or higher.
We're actively working on a fix to this repository. Until then, please refer to these upgrade instructions: https://github.com/mattermost/mattermost-docker/issues/489#issuecomment-790277661
This project enables a deployment of a Mattermost server in a multi-node production configuration using Docker.
[![Build Status](https://travis-ci.org/mattermost/mattermost-docker.svg?branch=master)](https://travis-ci.org/mattermost/mattermost-docker) [![Build Status](https://travis-ci.org/mattermost/mattermost-docker.svg?branch=master)](https://travis-ci.org/mattermost/mattermost-docker)
@ -29,13 +23,10 @@ The following instructions deploy Mattermost in a production configuration using
If you want to install Enterprise Edition, you can skip this section. If you want to install Enterprise Edition, you can skip this section.
To install the team edition, change `build: app` to `build:` and uncomment out these lines in `app:` services block to make it look like below in docker-compose.yaml file: To install the team edition, comment out the two following lines in docker-compose.yaml file:
```yaml ```yaml
app: args:
build: - edition=team
context: app
args:
- edition=team
``` ```
The `app` Dockerfile will read the `edition` build argument to install Team (`edition = 'team'`) or Enterprise (`edition != team`) edition. The `app` Dockerfile will read the `edition` build argument to install Team (`edition = 'team'`) or Enterprise (`edition != team`) edition.
@ -73,13 +64,6 @@ If your database use some custom host and port, it is also possible to configure
* `DB_HOST`: database host address * `DB_HOST`: database host address
* `DB_PORT_NUMBER`: database port * `DB_PORT_NUMBER`: database port
Use this optional variable if your PostgreSQL connection requires encryption (you may need a certificate authority file and/or a certificate revocation list - check the documentation for your database provider). See the [PostgreSQL notes on encrypted connections](https://www.postgresql.org/docs/current/libpq-ssl.html) for recommendations on what values to use when encryption is needed.
* `DB_SSLMODE`: defaults to `disable`, indicating no encryption
PostgreSQL allows two other variables `sslrootcert` and `sslcrl` for connection strings. However these are not broadly supported when the connection string is specified as a URI. If you need these parameters, use the PostgreSQL-specified environment variables
* `PGSSLROOTCERT` specifies the location of CA file
* `PGSSLCRL` specifies the location of a certificate revocation list file
If you use a Mattermost configuration file on a different location than the default one (`/mattermost/config/config.json`) : If you use a Mattermost configuration file on a different location than the default one (`/mattermost/config/config.json`) :
* `MM_CONFIG`: configuration file location inside the container. * `MM_CONFIG`: configuration file location inside the container.
@ -121,14 +105,6 @@ Put your SSL certificate as `./volumes/web/cert/cert.pem` and the private key th
no password as `./volumes/web/cert/key-no-password.pem`. If you don't have no password as `./volumes/web/cert/key-no-password.pem`. If you don't have
them you may generate a self-signed SSL certificate. them you may generate a self-signed SSL certificate.
#### Configure SSO with GitLab
If you are looking for SSO with GitLab and you use self signed certificate you have to add the PKI chain of your authority in app because Alpine doesn't know him. This is required to avoid **Token request failed: certificate signed by unknown authority**
For that uncomment this line and replace with the correct path of your PKI chain:
```
# - <path_to_your_gitlab_pki>/pki_chain.pem:/etc/ssl/certs/pki_chain.pem:ro
```
### Starting/Stopping Docker ### Starting/Stopping Docker
#### Start #### Start
@ -202,7 +178,7 @@ docker-compose build app
docker-compose run app -upgrade_db_30 docker-compose run app -upgrade_db_30
docker-compose up -d docker-compose up -d
``` ```
See the [official Upgrade Guide](http://docs.mattermost.com/administration/upgrade.html) for more details. See the [offical Upgrade Guide](http://docs.mattermost.com/administration/upgrade.html) for more details.
## Installation using Docker Swarm Mode ## Installation using Docker Swarm Mode

View File

@ -2,14 +2,13 @@ FROM alpine:3.10
# Some ENV variables # Some ENV variables
ENV PATH="/mattermost/bin:${PATH}" ENV PATH="/mattermost/bin:${PATH}"
ENV MM_INSTALL_TYPE=docker ENV MM_VERSION=5.9.8
# Build argument to set Mattermost edition # Build argument to set Mattermost edition
ARG edition=enterprise ARG edition=enterprise
ARG PUID=2000 ARG PUID=2000
ARG PGID=2000 ARG PGID=2000
ARG MM_BINARY= ARG MM_BINARY=
ARG MM_VERSION=5.31.0
# Install some needed packages # Install some needed packages
@ -19,25 +18,22 @@ RUN apk add --no-cache \
jq \ jq \
libc6-compat \ libc6-compat \
libffi-dev \ libffi-dev \
libcap \
linux-headers \ linux-headers \
mailcap \ mailcap \
netcat-openbsd \ netcat-openbsd \
xmlsec-dev \ xmlsec-dev \
tzdata \
&& rm -rf /tmp/* && rm -rf /tmp/*
# Get Mattermost # Get Mattermost
RUN mkdir -p /mattermost/data /mattermost/plugins /mattermost/client/plugins \ RUN mkdir -p /mattermost/data /mattermost/plugins /mattermost/client/plugins \
&& if [ ! -z "$MM_BINARY" ]; then curl $MM_BINARY | tar -xvz ; \ && if [ ! -z "$MM_BINARY" ]; then curl $MM_BINARY | tar -xvz ; \
elif [ "$edition" = "team" ] ; then curl https://releases.mattermost.com/$MM_VERSION/mattermost-team-$MM_VERSION-linux-amd64.tar.gz?src=docker-app | tar -xvz ; \ elif [ "$edition" = "team" ] ; then curl https://releases.mattermost.com/$MM_VERSION/mattermost-team-$MM_VERSION-linux-amd64.tar.gz | tar -xvz ; \
else curl https://releases.mattermost.com/$MM_VERSION/mattermost-$MM_VERSION-linux-amd64.tar.gz?src=docker-app | tar -xvz ; fi \ else curl https://releases.mattermost.com/$MM_VERSION/mattermost-$MM_VERSION-linux-amd64.tar.gz | tar -xvz ; fi \
&& cp /mattermost/config/config.json /config.json.save \ && cp /mattermost/config/config.json /config.json.save \
&& rm -rf /mattermost/config/config.json \ && rm -rf /mattermost/config/config.json \
&& addgroup -g ${PGID} mattermost \ && addgroup -g ${PGID} mattermost \
&& adduser -D -u ${PUID} -G mattermost -h /mattermost -D mattermost \ && adduser -D -u ${PUID} -G mattermost -h /mattermost -D mattermost \
&& chown -R mattermost:mattermost /mattermost /config.json.save /mattermost/plugins /mattermost/client/plugins \ && chown -R mattermost:mattermost /mattermost /config.json.save /mattermost/plugins /mattermost/client/plugins
&& setcap cap_net_bind_service=+ep /mattermost/bin/mattermost
USER mattermost USER mattermost

View File

@ -2,72 +2,65 @@
# Function to generate a random salt # Function to generate a random salt
generate_salt() { generate_salt() {
tr -dc 'a-zA-Z0-9' </dev/urandom | fold -w 48 | head -n 1 tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 48 | head -n 1
} }
# Read environment variables or set default values # Read environment variables or set default values
DB_HOST=${DB_HOST:-db} DB_HOST=${DB_HOST:-db}
DB_PORT_NUMBER=${DB_PORT_NUMBER:-5432} DB_PORT_NUMBER=${DB_PORT_NUMBER:-5432}
# see https://www.postgresql.org/docs/current/libpq-ssl.html
# for usage when database connection requires encryption
# filenames should be escaped if they contain spaces
# i.e. $(printf %s ${MY_ENV_VAR:-''} | jq -s -R -r @uri)
# the location of the CA file can be set using environment var PGSSLROOTCERT
# the location of the CRL file can be set using PGSSLCRL
# The URL syntax for connection string does not support the parameters
# sslrootcert and sslcrl reliably, so use these PostgreSQL-specified variables
# to set names if using a location other than default
DB_USE_SSL=${DB_USE_SSL:-disable}
MM_DBNAME=${MM_DBNAME:-mattermost} MM_DBNAME=${MM_DBNAME:-mattermost}
MM_CONFIG=${MM_CONFIG:-/mattermost/config/config.json} MM_CONFIG=${MM_CONFIG:-/mattermost/config/config.json}
_1=$(echo "$1" | awk '{ s=substr($0, 0, 1); print s; }') if [ "${1:0:1}" = '-' ]; then
if [ "$_1" = '-' ]; then set -- mattermost "$@"
set -- mattermost "$@"
fi fi
if [ "$1" = 'mattermost' ]; then if [ "$1" = 'mattermost' ]; then
# Check CLI args for a -config option # Check CLI args for a -config option
for ARG in "$@"; do for ARG in $@;
case "$ARG" in do
-config=*) MM_CONFIG=${ARG#*=} ;; case "$ARG" in
esac -config=*)
MM_CONFIG=${ARG#*=};;
esac
done done
if [ ! -f "$MM_CONFIG" ]; then if [ ! -f $MM_CONFIG ]
then
# If there is no configuration file, create it with some default values # If there is no configuration file, create it with some default values
echo "No configuration file $MM_CONFIG" echo "No configuration file" $MM_CONFIG
echo "Creating a new one" echo "Creating a new one"
# Copy default configuration file # Copy default configuration file
cp /config.json.save "$MM_CONFIG" cp /config.json.save $MM_CONFIG
# Substitute some parameters with jq # Substitue some parameters with jq
jq '.ServiceSettings.ListenAddress = ":8000"' "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.ServiceSettings.ListenAddress = ":8000"' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq '.LogSettings.EnableConsole = true' "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.LogSettings.EnableConsole = true' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq '.LogSettings.ConsoleLevel = "ERROR"' "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.LogSettings.ConsoleLevel = "ERROR"' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq '.FileSettings.Directory = "/mattermost/data/"' "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.FileSettings.Directory = "/mattermost/data/"' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq '.FileSettings.EnablePublicLink = true' "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.FileSettings.EnablePublicLink = true' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq ".FileSettings.PublicLinkSalt = \"$(generate_salt)\"" "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.FileSettings.PublicLinkSalt = "'$(generate_salt)'"' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq '.EmailSettings.SendEmailNotifications = false' "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.EmailSettings.SendEmailNotifications = false' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq '.EmailSettings.FeedbackEmail = ""' "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.EmailSettings.FeedbackEmail = ""' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq '.EmailSettings.SMTPServer = ""' "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.EmailSettings.SMTPServer = ""' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq '.EmailSettings.SMTPPort = ""' "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.EmailSettings.SMTPPort = ""' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq ".EmailSettings.InviteSalt = \"$(generate_salt)\"" "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.EmailSettings.InviteSalt = "'$(generate_salt)'"' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq ".EmailSettings.PasswordResetSalt = \"$(generate_salt)\"" "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.EmailSettings.PasswordResetSalt = "'$(generate_salt)'"' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq '.RateLimitSettings.Enable = true' "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.RateLimitSettings.Enable = true' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq '.SqlSettings.DriverName = "postgres"' "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.SqlSettings.DriverName = "postgres"' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq ".SqlSettings.AtRestEncryptKey = \"$(generate_salt)\"" "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.SqlSettings.AtRestEncryptKey = "'$(generate_salt)'"' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
jq '.PluginSettings.Directory = "/mattermost/plugins/"' "$MM_CONFIG" >"$MM_CONFIG.tmp" && mv "$MM_CONFIG.tmp" "$MM_CONFIG" jq '.PluginSettings.Directory = "/mattermost/plugins/"' $MM_CONFIG > $MM_CONFIG.tmp && mv $MM_CONFIG.tmp $MM_CONFIG
else else
echo "Using existing config file $MM_CONFIG" echo "Using existing config file" $MM_CONFIG
fi fi
# Configure database access # Configure database access
if [ -z "$MM_SQLSETTINGS_DATASOURCE" ] && [ -n "$MM_USERNAME" ] && [ -n "$MM_PASSWORD" ]; then if [[ -z "$MM_SQLSETTINGS_DATASOURCE" && ! -z "$MM_USERNAME" && ! -z "$MM_PASSWORD" ]]
echo "Configure database connection..." then
echo -ne "Configure database connection..."
# URLEncode the password, allowing for special characters # URLEncode the password, allowing for special characters
ENCODED_PASSWORD=$(printf %s "$MM_PASSWORD" | jq -s -R -r @uri) ENCODED_PASSWORD=$(printf %s $MM_PASSWORD | jq -s -R -r @uri)
export MM_SQLSETTINGS_DATASOURCE="postgres://$MM_USERNAME:$ENCODED_PASSWORD@$DB_HOST:$DB_PORT_NUMBER/$MM_DBNAME?sslmode=$DB_USE_SSL&connect_timeout=10" export MM_SQLSETTINGS_DATASOURCE="postgres://$MM_USERNAME:$ENCODED_PASSWORD@$DB_HOST:$DB_PORT_NUMBER/$MM_DBNAME?sslmode=disable&connect_timeout=10"
echo "OK" echo OK
else else
echo "Using existing database connection" echo "Using existing database connection"
fi fi

View File

@ -76,7 +76,7 @@ Type: NodePort
IP: 10.0.0.194 IP: 10.0.0.194
Port: http 80/TCP Port: http 80/TCP
NodePort: http 32283/TCP NodePort: http 32283/TCP
Endpoints: 172.17.0.4:8000 Endpoints: 172.17.0.4:80
Session Affinity: None Session Affinity: None
No events. No events.
``` ```
@ -90,7 +90,7 @@ curl -L http://192.168.99.100:32283
### Optional steps ### Optional steps
* If you want your data to be persistent you will need to make persistent volumes for Mattermost and Postgres. This requires adding a [securityContext](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#discussion) to the deployment to set `runAsUser: 2000`, `runAsGroup: 2000` and `fsGroup: 2000`. * If you want your data to be persistent you will need to make persistent volumes for Mattermost and Postgres.
* If you want to change advanced settings for the mattermost container you can make a [configMap](http://blog.kubernetes.io/2016/04/configuration-management-with-containers.html) for the /mattermost/config/config.json file * If you want to change advanced settings for the mattermost container you can make a [configMap](http://blog.kubernetes.io/2016/04/configuration-management-with-containers.html) for the /mattermost/config/config.json file
* If you want the application exposed on port 80 you can either specify the port in the service manifest or use an [ingress controller](http://kubernetes.io/docs/user-guide/ingress/#ingress-controllers) and an ingress map for the mattermost service. A sample ingress map would be * If you want the application exposed on port 80 you can either specify the port in the service manifest or use an [ingress controller](http://kubernetes.io/docs/user-guide/ingress/#ingress-controllers) and an ingress map for the mattermost service. A sample ingress map would be
``` ```

View File

@ -17,14 +17,14 @@ spec:
spec: spec:
containers: containers:
- name: mattermost-app - name: mattermost-app
image: "mattermost/mattermost-prod-app:5.14.1" image: "mattermost/mattermost-prod-app:5.9.0"
env: env:
- name: DB_HOST - name: DB_HOST
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
name: mattermost.env name: mattermost.env
key: db-host key: db-host
- name: DB_PORT_NUMBER - name: DB_PORT
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
name: mattermost.env name: mattermost.env

View File

@ -7,7 +7,7 @@ spec:
type: NodePort type: NodePort
ports: ports:
- port: 80 - port: 80
targetPort: 8000 targetPort: 80
protocol: TCP protocol: TCP
name: http name: http
selector: selector:

View File

@ -59,7 +59,7 @@ services:
condition: on-failure condition: on-failure
app: app:
# use official mattermost prod-app image # use official mattermost prod-app image
image: mattermost/mattermost-prod-app:5.13.0 image: mattermost/mattermost-prod-app:5.9.0
networks: networks:
- mm-in - mm-in
- mm-out - mm-out

View File

@ -58,7 +58,7 @@ services:
condition: on-failure condition: on-failure
app: app:
# use official mattermost prod-app image # use official mattermost prod-app image
image: mattermost/mattermost-prod-app:5.13.0 image: mattermost/mattermost-prod-app:5.9.0
networks: networks:
- mm-in - mm-in
- mm-out - mm-out

View File

@ -3,7 +3,6 @@ FROM postgres:9.4-alpine
ENV DEFAULT_TIMEZONE UTC ENV DEFAULT_TIMEZONE UTC
# Install some packages to use WAL # Install some packages to use WAL
RUN echo "azure<5.0.0" > pip-constraints.txt
RUN apk add --no-cache \ RUN apk add --no-cache \
build-base \ build-base \
curl \ curl \
@ -13,10 +12,7 @@ RUN apk add --no-cache \
python-dev \ python-dev \
py-pip \ py-pip \
py-cryptography \ py-cryptography \
pv \ && pip --no-cache-dir install 'wal-e<1.0.0' envdir \
libressl-dev \
&& pip install --upgrade pip \
&& pip --no-cache-dir install -c pip-constraints.txt 'wal-e<1.0.0' envdir \
&& rm -rf /var/cache/apk/* /tmp/* /var/tmp/* && rm -rf /var/cache/apk/* /tmp/* /var/tmp/*
# Add wale script # Add wale script

View File

@ -5,7 +5,7 @@ export WAL_LEVEL=${WAL_LEVEL:-minimal}
export ARCHIVE_MODE=${ARCHIVE_MODE:-off} export ARCHIVE_MODE=${ARCHIVE_MODE:-off}
export ARCHIVE_TIMEOUT=${ARCHIVE_TIMEOUT:-60} export ARCHIVE_TIMEOUT=${ARCHIVE_TIMEOUT:-60}
function update_conf() { function update_conf () {
wal=$1 wal=$1
# PGDATA is defined in upstream postgres dockerfile # PGDATA is defined in upstream postgres dockerfile
config_file=$PGDATA/postgresql.conf config_file=$PGDATA/postgresql.conf
@ -23,11 +23,11 @@ function update_conf() {
sed -i "s/archive_command =.*$//g" $config_file sed -i "s/archive_command =.*$//g" $config_file
# Configure wal-e # Configure wal-e
if [ "$wal" = true ]; then if [ "$wal" = true ] ; then
/docker-entrypoint-initdb.d/setup-wale.sh /docker-entrypoint-initdb.d/setup-wale.sh
fi fi
echo "log_timezone = $DEFAULT_TIMEZONE" >>$config_file echo "log_timezone = $DEFAULT_TIMEZONE" >> $config_file
echo "timezone = $DEFAULT_TIMEZONE" >>$config_file echo "timezone = $DEFAULT_TIMEZONE" >> $config_file
} }
if [ "${1:0:1}" = '-' ]; then if [ "${1:0:1}" = '-' ]; then
@ -46,7 +46,7 @@ if [ "$1" = 'postgres' ]; then
done done
# Setup wal-e env variables # Setup wal-e env variables
if [ "$wal_enable" = true ]; then if [ "$wal_enable" = true ] ; then
for v in ${VARS[@]}; do for v in ${VARS[@]}; do
export $v="${!v}" export $v="${!v}"
done done
@ -58,5 +58,5 @@ if [ "$1" = 'postgres' ]; then
update_conf $wal_enable update_conf $wal_enable
# Run the postgresql entrypoint # Run the postgresql entrypoint
docker-entrypoint.sh postgres . /docker-entrypoint.sh
fi fi

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# wal-e specific configuration # wal-e specific configuration
echo "wal_level = $WAL_LEVEL" >>$PGDATA/postgresql.conf echo "wal_level = $WAL_LEVEL" >> $PGDATA/postgresql.conf
echo "archive_mode = $ARCHIVE_MODE" >>$PGDATA/postgresql.conf echo "archive_mode = $ARCHIVE_MODE" >> $PGDATA/postgresql.conf
echo "archive_command = '/usr/bin/wal-e wal-push %p'" >>$PGDATA/postgresql.conf echo "archive_command = '/usr/bin/wal-e wal-push %p'" >> $PGDATA/postgresql.conf
echo "archive_timeout = $ARCHIVE_TIMEOUT" >>$PGDATA/postgresql.conf echo "archive_timeout = $ARCHIVE_TIMEOUT" >> $PGDATA/postgresql.conf

20
docker-compose.yml Executable file → Normal file
View File

@ -1,4 +1,4 @@
version: "3" version: "2"
services: services:
@ -27,7 +27,6 @@ services:
# - edition=team # - edition=team
# - PUID=1000 # - PUID=1000
# - PGID=1000 # - PGID=1000
# - MM_VERSION=5.31
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ./volumes/app/mattermost/config:/mattermost/config:rw - ./volumes/app/mattermost/config:/mattermost/config:rw
@ -36,32 +35,25 @@ services:
- ./volumes/app/mattermost/plugins:/mattermost/plugins:rw - ./volumes/app/mattermost/plugins:/mattermost/plugins:rw
- ./volumes/app/mattermost/client-plugins:/mattermost/client/plugins:rw - ./volumes/app/mattermost/client-plugins:/mattermost/client/plugins:rw
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
# When you want to use SSO with GitLab, you have to add the cert pki chain of GitLab inside Alpine
# to avoid Token request failed: certificate signed by unknown authority (link: https://github.com/mattermost/mattermost-server/issues/13059)
# - <path_to_your_gitlab_pki>/pki_chain.pem:/etc/ssl/certs/pki_chain.pem:ro
environment: environment:
# set same as db credentials and dbname # set same as db credentials and dbname
- MM_USERNAME=mmuser - MM_USERNAME=mmuser
- MM_PASSWORD=mmuser_password - MM_PASSWORD=mmuser_password
- MM_DBNAME=mattermost - MM_DBNAME=mattermost
# use the credentials you've set above, in the format:
# MM_SQLSETTINGS_DATASOURCE=postgres://${MM_USERNAME}:${MM_PASSWORD}@db:5432/${MM_DBNAME}?sslmode=disable&connect_timeout=10
- MM_SQLSETTINGS_DATASOURCE=postgres://mmuser:mmuser_password@db:5432/mattermost?sslmode=disable&connect_timeout=10
# in case your config is not in default location # in case your config is not in default location
#- MM_CONFIG=/mattermost/config/config.json #- MM_CONFIG=/mattermost/config/config.json
web: web:
build: web build: web
ports: ports:
- "80:8080" - "80:80"
- "443:8443" - "443:443"
read_only: true read_only: true
restart: unless-stopped restart: unless-stopped
volumes: volumes:
# This directory must have cert files if you want to enable SSL # This directory must have cert files if you want to enable SSL
- ./volumes/web/cert:/cert:ro - ./volumes/web/cert:/cert:ro
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
cap_drop: # Uncomment for SSL
- ALL # environment:
# - MATTERMOST_ENABLE_SSL=true

View File

@ -1,38 +1,17 @@
FROM nginxinc/nginx-unprivileged:mainline-alpine FROM nginx:mainline-alpine
USER root
# Remove default configuration and add our custom Nginx configuration files # Remove default configuration and add our custom Nginx configuration files
RUN rm /etc/nginx/conf.d/default.conf \ RUN rm /etc/nginx/conf.d/default.conf \
&& apk add --no-cache curl && apk add --no-cache curl
COPY ["./mattermost", "./mattermost-ssl", "/etc/nginx/sites-available/"] COPY ["./mattermost", "./mattermost-ssl", "/etc/nginx/sites-available/"]
COPY ./security.conf /etc/nginx/conf.d/
# Add and setup entrypoint # Add and setup entrypoint
COPY entrypoint.sh / COPY entrypoint.sh /
RUN chown -R nginx:nginx /etc/nginx/sites-available && \
chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /var/log/nginx && \
chown -R nginx:nginx /etc/nginx/conf.d && \
chown nginx:nginx entrypoint.sh
RUN touch /var/run/nginx.pid && \
chown -R nginx:nginx /var/run/nginx.pid
COPY ./security.conf /etc/nginx/conf.d/
RUN chown -R nginx:nginx /etc/nginx/conf.d/security.conf
RUN chmod u+x /entrypoint.sh
RUN sed -i "/^http {/a \ proxy_buffering off;\n" /etc/nginx/nginx.conf
RUN sed -i '/temp_path/d' /etc/nginx/nginx.conf \
&& sed -i 's!/tmp/nginx.pid!/var/run/nginx.pid!g' /etc/nginx/nginx.conf
USER nginx
#Healthcheck to make sure container is ready #Healthcheck to make sure container is ready
HEALTHCHECK CMD curl --fail http://localhost:8080 || exit 1 HEALTHCHECK CMD curl --fail http://localhost:80 || exit 1
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]

View File

@ -11,10 +11,8 @@ if [ -f "/cert/cert.pem" -a -f "/cert/key-no-password.pem" ]; then
else else
echo "linking plain config" echo "linking plain config"
fi fi
# Ensure that the configuration file is not present before linking.
test -w /etc/nginx/conf.d/mattermost.conf && rm /etc/nginx/conf.d/mattermost.conf
# Linking Nginx configuration file # Linking Nginx configuration file
ln -s -f /etc/nginx/sites-available/mattermost$ssl /etc/nginx/conf.d/mattermost.conf ln -s /etc/nginx/sites-available/mattermost$ssl /etc/nginx/conf.d/mattermost.conf
# Setup app host and port on configuration file # Setup app host and port on configuration file
sed -i "s/{%APP_HOST%}/${APP_HOST}/g" /etc/nginx/conf.d/mattermost.conf sed -i "s/{%APP_HOST%}/${APP_HOST}/g" /etc/nginx/conf.d/mattermost.conf

View File

@ -4,7 +4,7 @@ map $http_x_forwarded_proto $proxy_x_forwarded_proto {
} }
server { server {
listen 8080; listen 80;
location ~ /api/v[0-9]+/(users/)?websocket$ { location ~ /api/v[0-9]+/(users/)?websocket$ {
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;

21
web/mattermost-ssl Executable file → Normal file
View File

@ -1,7 +1,7 @@
server { server {
listen 8080 default_server; listen 80 default_server;
server_name _; server_name _;
return 301 https://$host$request_uri; return 301 https://$host$request_uri;
} }
map $http_x_forwarded_proto $proxy_x_forwarded_proto { map $http_x_forwarded_proto $proxy_x_forwarded_proto {
@ -10,16 +10,15 @@ map $http_x_forwarded_proto $proxy_x_forwarded_proto {
} }
server { server {
listen 8443 ssl http2; listen 443 ssl http2;
ssl on;
ssl_certificate /cert/cert.pem; ssl_certificate /cert/cert.pem;
ssl_certificate_key /cert/key-no-password.pem; ssl_certificate_key /cert/key-no-password.pem;
ssl_session_timeout 5m; ssl_session_timeout 5m;
ssl_protocols TLSv1.2 TLSv1.3; ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# Please update the ciphers in this file every 6 months. ssl_ciphers HIGH:MEDIUM:!SSLv2:!PSK:!SRP:!ADH:!AECDH;
# https://ssl-config.mozilla.org/ ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
location ~ /api/v[0-9]+/(users/)?websocket$ { location ~ /api/v[0-9]+/(users/)?websocket$ {
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
@ -35,7 +34,7 @@ server {
proxy_buffers 256 16k; proxy_buffers 256 16k;
proxy_buffer_size 16k; proxy_buffer_size 16k;
proxy_read_timeout 600s; proxy_read_timeout 600s;
proxy_pass http://{%APP_HOST%}:{%APP_PORT%}; proxy_pass http://{%APP_HOST%}:{%APP_PORT%};
} }
location / { location / {
@ -52,7 +51,7 @@ server {
proxy_buffers 256 16k; proxy_buffers 256 16k;
proxy_buffer_size 16k; proxy_buffer_size 16k;
proxy_read_timeout 600s; proxy_read_timeout 600s;
proxy_pass http://{%APP_HOST%}:{%APP_PORT%}; proxy_pass http://{%APP_HOST%}:{%APP_PORT%};
} }
} }