Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history


* 'master' of https://github.com/mattermost/mattermost-docker:
  bump to 5.6.1
  bump to version 5.6.0
  Allow to properly shutdown web container
  bump to 5.5.1
  renamed the vars to be better inline with the readme (mattermost#341)
  Bump to 5.5.0
  downgrade alpine to 3.7 due xmlsec1 issues (mattermost#334)
  Improve app to db connection setup (mattermost#332)
  fix S3 wal-e support (mattermost#324)
  fix uuoc and typo (mattermost#333)
  fix permission in plugin folder (mattermost#331)
  Fix database HEALTHCHECK with correct user/db name (mattermost#330)
  Upgrade to 5.4.0 (mattermost#327)
  Fix typo (mattermost#323)
  Add warning about read_only (mattermost#321)
  Fix database healthcheck (mattermost#318)
  Remove DB check in the app/entrypoint (mattermost#316)
  if all config was set in the config.json bypass the checks (mattermost#315)
  add ability to build your own mm binary (mattermost#314)
  • Loading branch information
nickygerritsen committed Dec 21, 2018
2 parents 27b6154 + c58467c commit 484f7ed
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ install:

env:
- BUILD="mkdir -p ./volumes/app/mattermost/{data,logs,config,plugins} && docker-compose up -d"
- BUILD="docker run -d --name db -e POSTGRES_USER=mmuser -e POSTGRES_PASSWORD=mmuser_password -e POSTGRES_DB=mattermost mattermost-prod-db && sleep 5 && docker run -d --link db -p 80:8000 --name app mattermost-prod-app"
- BUILD="docker run -d --name db -e POSTGRES_USER=mmuser -e POSTGRES_PASSWORD=mmuser_password -e POSTGRES_DB=mattermost mattermost-prod-db && sleep 5 && docker run -d --link db -p 80:8000 --name app -e MM_USERNAME=mmuser -e MM_PASSWORD=mmuser_password mattermost-prod-app"

script:
- curl -sSf http://localhost > /dev/null
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To install the team edition, comment out the two following lines in docker-compo
args:
- edition=team
```
The `app` Dockerfile will read the `edition` build argument to install Team (`edition = 'team'`) or Entreprise (`edition != team`) edition.
The `app` Dockerfile will read the `edition` build argument to install Team (`edition = 'team'`) or Enterprise (`edition != team`) edition.

### Database container
This repository offer a Docker image for the Mattermost database. It is a customized PostgreSQL image that you should configure with following environment variables :
Expand All @@ -48,9 +48,9 @@ If deploying to AWS, you could also set following variables to enable [Wal-E](ht
All four environment variables are required. It will enable completed WAL segments sent to archive storage (S3). The base backup and clean up can be done through the following command:
```bash
# Base backup
docker exec mattermost-db su - postgres sh -c "/usr/bin/envdir /etc/wal-e.d/env /usr/local/bin/wal-e backup-push /var/lib/postgresql/data"
docker exec mattermost-db su - postgres sh -c "/usr/bin/envdir /etc/wal-e.d/env /usr/bin/wal-e backup-push /var/lib/postgresql/data"
# Keep the most recent 7 base backups and remove the old ones
docker exec mattermost-db su - postgres sh -c "/usr/bin/envdir /etc/wal-e.d/env /usr/local/bin/wal-e delete --confirm retain 7"
docker exec mattermost-db su - postgres sh -c "/usr/bin/envdir /etc/wal-e.d/env /usr/bin/wal-e delete --confirm retain 7"
```
Those tasks can be executed through a cron job or systemd timer.

Expand Down Expand Up @@ -98,6 +98,8 @@ This image is optional, you should **not** use it when you have your own reverse
* `APP_HOST`: application host address
* `APP_PORT_NUMBER`: application HTTP port

If you plan to upload large files to your Mattermost instance, Nginx will need to write some temporary files. In that case, the `read_only: true` option on the `web` container should be removed from your `docker-compose.yml` file.

#### Install with SSL certificate
Put your SSL certificate as `./volumes/web/cert/cert.pem` and the private key that has
no password as `./volumes/web/cert/key-no-password.pem`. If you don't have
Expand Down
12 changes: 7 additions & 5 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FROM alpine:3.8
FROM alpine:3.7

# Some ENV variables
ENV PATH="/mattermost/bin:${PATH}"
ENV MM_VERSION=5.3.1
ENV MM_VERSION=5.6.1

# Build argument to set Mattermost edition
ARG edition=enterprise
ARG PUID=2000
ARG PGID=2000
ARG MM_BINARY=


# Install some needed packages
Expand All @@ -24,14 +25,15 @@ RUN apk add --no-cache \
&& rm -rf /tmp/*

# Get Mattermost
RUN mkdir -p /mattermost/data \
&& if [ "$edition" = "team" ] ; then curl https://releases.mattermost.com/$MM_VERSION/mattermost-team-$MM_VERSION-linux-amd64.tar.gz | tar -xvz ; \
RUN mkdir -p /mattermost/data /mattermost/plugins /mattermost/client/plugins \
&& 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 | tar -xvz ; \
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 \
&& rm -rf /mattermost/config/config.json \
&& addgroup -g ${PGID} mattermost \
&& adduser -D -u ${PUID} -G mattermost -h /mattermost -D mattermost \
&& chown -R mattermost:mattermost /mattermost /config.json.save
&& chown -R mattermost:mattermost /mattermost /config.json.save /mattermost/plugins /mattermost/client/plugins

USER mattermost

Expand Down
13 changes: 2 additions & 11 deletions app/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

# Function to generate a random salt
generate_salt() {
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | 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
DB_HOST=${DB_HOST:-db}
DB_PORT_NUMBER=${DB_PORT_NUMBER:-5432}
MM_USERNAME=${MM_USERNAME:-mmuser}
MM_PASSWORD=${MM_PASSWORD:-mmuser_password}
MM_DBNAME=${MM_DBNAME:-mattermost}
MM_CONFIG=${MM_CONFIG:-/mattermost/config/config.json}

Expand Down Expand Up @@ -56,7 +54,7 @@ if [ "$1" = 'mattermost' ]; then
fi

# Configure database access
if [ -z "$MM_SQLSETTINGS_DATASOURCE" ]
if [[ -z "$MM_SQLSETTINGS_DATASOURCE" && ! -z "$MM_USERNAME" && ! -z "$MM_PASSWORD" ]]
then
echo -ne "Configure database connection..."
# URLEncode the password, allowing for special characters
Expand All @@ -67,13 +65,6 @@ if [ "$1" = 'mattermost' ]; then
echo "Using existing database connection"
fi

# Wait for database to be reachable
echo "Wait until database $DB_HOST:$DB_PORT_NUMBER is ready..."
until nc -z $DB_HOST $DB_PORT_NUMBER
do
sleep 1
done

# Wait another second for the database to be properly started.
# Necessary to avoid "panic: Failed to open sql connection pq: the database system is starting up"
sleep 1
Expand Down
6 changes: 3 additions & 3 deletions contrib/kubernetes/mattermost.deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: mattermost-app
image: "mattermost/mattermost-prod-app:5.3.1"
image: "mattermost/mattermost-prod-app:5.6.1"
env:
- name: DB_HOST
valueFrom:
Expand Down Expand Up @@ -45,14 +45,14 @@ spec:
name: mattermost.env
key: mm-dbname
volumeMounts:
# optional persistant storage
# optional persistent storage
#- name: appdata
#mountPath: /mattermost/data
- name: etclocaltime
mountPath: /etc/localtime
readOnly: true
volumes:
# optional persistant storage
# optional persistent storage
#- name: appdata
#persistentVolumeClaim:
# claimName: mattermost-app
Expand Down
6 changes: 3 additions & 3 deletions contrib/swarm/docker-stack-traefik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
# Simply run:
#
# `docker stack up [STACK NAME] -c docker-stack-traefik.yml`
#
#
# In this case `mm` is going to be stack name, so the command will be:
#
# `docker stack up mm -c docker-stack-traefik.yml`
#
# From now on all the services that belong to this stack will be prefixed with `mm_`
# this file defines 3 services, these are going to be mm_db, mm_app and mm_web,
# each of these names is the service's hostname as well, they can communicate
# each of these names is the service's hostname as well, they can communicate
# with each other easily by using the hostname instead of the ip or exposing ports to the host.
#
# As a side note, images tagged as latest are pulled by default,
# As a side note, images tagged as latest are pulled by default,
# that means there's no need to use `image:latest`
#
# use latest compose v3.3 file format for optimal compatibility with latest docker release and swarm features.
Expand Down
20 changes: 10 additions & 10 deletions contrib/swarm/docker-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
# Simply run:
#
# `docker stack up [STACK NAME] -c docker-stack.yml`
#
# In this case `mm` is going to be stack name, so the command will be:
#
# `docker stack up mm -c docker-stack.yml`
# In this case `mattermost` is going to be stack name, so the command will be:
#
# From now on all the services that belong to this stack will be prefixed with `mm_`
# this file defines 3 services, these are going to be mm_db, mm_app and mm_web,
# each of these names is the service's hostname as well, they can communicate
# `docker stack up mattermost -c docker-stack.yml`
#
# From now on all the services that belong to this stack will be prefixed with `mattermost_`
# this file defines 3 services, these are going to be mattermost_db, mattermost_app and mattermost_web,
# each of these names is the service's hostname as well, they can communicate
# with each other easily by using the hostname instead of the ip or exposing ports to the host.
#
# As a side note, images tagged as latest are pulled by default,
# As a side note, images tagged as latest are pulled by default,
# that means there's no need to use `image:latest`
#
# use latest compose v3.3 file format for optimal compatibility with latest docker release and swarm features.
Expand Down Expand Up @@ -70,7 +70,7 @@ services:
- /etc/localtime:/etc/localtime:ro
environment:
# use service's hostname
- DB_HOST=mm_db
- DB_HOST=db
# talk to the port within the overlay network
# without (over)exposing ports
- DB_PORT_NUMBER=5432
Expand Down Expand Up @@ -99,10 +99,10 @@ services:
- /etc/localtime:/etc/localtime:ro
environment:
# use app service's hostname
- APP_HOST=mm_app
- APP_HOST=app
# talk to the port within the overlay network
# without (over)exposing ports
- APP_PORT_NUMBER=80
deploy:
restart_policy:
condition: on-failure
condition: on-failure
4 changes: 2 additions & 2 deletions db/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ RUN apk add --no-cache \
COPY setup-wale.sh /docker-entrypoint-initdb.d/

#Healthcheck to make sure container is ready
HEALTHCHECK CMD pg_isready -U postgres || exit 1
HEALTHCHECK CMD pg_isready -U $POSTGRES_USER -d $POSTGRES_DB || exit 1

# Add and configure entrypoint and command
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["postgres"]

VOLUME ["/var/run/postgresql", "/usr/share/postgresql/", "/var/lib/postgresql/data", "/tmp"]
VOLUME ["/var/run/postgresql", "/usr/share/postgresql/", "/var/lib/postgresql/data", "/tmp", "/etc/wal-e.d/env"]
2 changes: 1 addition & 1 deletion web/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ sed -i "s/{%APP_HOST%}/${APP_HOST}/g" /etc/nginx/conf.d/mattermost.conf
sed -i "s/{%APP_PORT%}/${APP_PORT_NUMBER}/g" /etc/nginx/conf.d/mattermost.conf

# Run Nginx
nginx -g 'daemon off;'
exec nginx -g 'daemon off;'

0 comments on commit 484f7ed

Please sign in to comment.