diff --git a/README.md b/README.md index 2c96d4b..73f0113 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ Customization can be done through environment variables. * `MM_PASSWORD`: database password, must be the same as one in DB image * `MM_DBNAME`: database name, must be the same as one in DB image * `DB_HOST`: database host address -* `DB_PORT_5432_TCP_PORT`: database port +* `DB_PORT_NUMBER`: database port * `MM_CONFIG`: configuration file location. It can be used when config is mounted in a different location. ### Mattermost DB Image diff --git a/app/Dockerfile b/app/Dockerfile index 1962226..24d5584 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -1,18 +1,40 @@ FROM ubuntu:14.04 +# Some ENV variables ENV PATH="/mattermost/bin:${PATH}" - -RUN apt-get update && apt-get -y install curl netcat -RUN mkdir -p /mattermost/data - ENV MM_VERSION=3.9.0 -RUN curl https://releases.mattermost.com/$MM_VERSION/mattermost-team-$MM_VERSION-linux-amd64.tar.gz | tar -xvz +# Override default config +ENV MM_SERVICESETTINGS_LISTENADDRESS=":80" \ + MM_LOGSETTINGS_ENABLECONSOLE=false \ + MM_LOGSETTINGS_CONSOLELEVEL="INFO" \ + MM_FILESETTINGS_DIRECTORY="/mattermost/data/" \ + MM_FILESETTINGS_ENABLEPUBLICLINK=true \ + MM_FILESETTINGS_PUBLICLINKSALT="A705AklYF8MFDOfcwh3I488G8vtLlVip" \ + MM_EMAILSETTINGS_SENDEMAILNOTIFICATIONS=false \ + MM_EMAILSETTINGS_FEEDBACKEMAIL="" \ + MM_EMAILSETTINGS_SMTPSERVER="" \ + MM_EMAILSETTINGS_SMTPPORT="" \ + MM_EMAILSETTINGS_INVITESALT="bjlSR4QqkXFBr7TP4oDzlfZmcNuH9YoS" \ + MM_RATELIMITSETTINGS_ENABLE=true \ + MM_SQLSETTINGS_DRIVERNAME="postgres" -RUN rm /mattermost/config/config.json -COPY config.template.json / +# Install some needed packages +RUN apt-get update \ + && apt-get -y install \ + curl \ + netcat \ + && rm -rf /var/lib/apt/lists/* +# Prepare Mattermost +RUN mkdir -p /mattermost/data \ + && curl https://releases.mattermost.com/$MM_VERSION/mattermost-team-$MM_VERSION-linux-amd64.tar.gz | tar -xvz \ + && cp /mattermost/config/config.json /config.json.save \ + && rm -rf /mattermost/config/config.json + +# Configure entrypoint COPY docker-entry.sh / +# Set permission (TODO should be removed and replace by a chmod on the file in the repository ?) RUN chmod +x /docker-entry.sh ENTRYPOINT ["/docker-entry.sh"] diff --git a/app/Dockerfile-enterprise b/app/Dockerfile-enterprise index 06fe861..f998c60 100644 --- a/app/Dockerfile-enterprise +++ b/app/Dockerfile-enterprise @@ -1,18 +1,40 @@ FROM ubuntu:14.04 +# Some ENV variables ENV PATH="/mattermost/bin:${PATH}" - -RUN apt-get update && apt-get -y install curl netcat -RUN mkdir -p /mattermost/data - ENV MM_VERSION=3.9.0 -RUN curl https://releases.mattermost.com/$MM_VERSION/mattermost-$MM_VERSION-linux-amd64.tar.gz | tar -xvz +# Override default config +ENV MM_SERVICESETTINGS_LISTENADDRESS=":80" \ + MM_LOGSETTINGS_ENABLECONSOLE=false \ + MM_LOGSETTINGS_CONSOLELEVEL="INFO" \ + MM_FILESETTINGS_DIRECTORY="/mattermost/data/" \ + MM_FILESETTINGS_ENABLEPUBLICLINK=true \ + MM_FILESETTINGS_PUBLICLINKSALT="A705AklYF8MFDOfcwh3I488G8vtLlVip" \ + MM_EMAILSETTINGS_SENDEMAILNOTIFICATIONS=false \ + MM_EMAILSETTINGS_FEEDBACKEMAIL="" \ + MM_EMAILSETTINGS_SMTPSERVER="" \ + MM_EMAILSETTINGS_SMTPPORT="" \ + MM_EMAILSETTINGS_INVITESALT="bjlSR4QqkXFBr7TP4oDzlfZmcNuH9YoS" \ + MM_RATELIMITSETTINGS_ENABLE=true \ + MM_SQLSETTINGS_DRIVERNAME="postgres" -RUN rm /mattermost/config/config.json -COPY config.template.json / +# Install some needed packages +RUN apt-get update \ + && apt-get -y install \ + curl \ + netcat \ + && rm -rf /var/lib/apt/lists/* +# Prepare Mattermost +RUN mkdir -p /mattermost/data \ + && curl https://releases.mattermost.com/$MM_VERSION/mattermost-$MM_VERSION-linux-amd64.tar.gz | tar -xvz \ + && cp /mattermost/config/config.json /config.json.save \ + && rm -rf /mattermost/config/config.json + +# Configure entrypoint COPY docker-entry.sh / +# Set permission (TODO should be removed and replace by a chmod on the file in the repository ?) RUN chmod +x /docker-entry.sh ENTRYPOINT ["/docker-entry.sh"] diff --git a/app/config.template.json b/app/config.template.json deleted file mode 100644 index 70af3ec..0000000 --- a/app/config.template.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "ServiceSettings": { - "ListenAddress": ":80", - "MaximumLoginAttempts": 10, - "SegmentDeveloperKey": "", - "GoogleDeveloperKey": "", - "EnableOAuthServiceProvider": false, - "EnableIncomingWebhooks": false, - "EnableOutgoingWebhooks": false, - "EnablePostUsernameOverride": false, - "EnablePostIconOverride": false, - "EnableTesting": false, - "EnableSecurityFixAlert": true - }, - "TeamSettings": { - "SiteName": "Mattermost", - "MaxUsersPerTeam": 50, - "EnableTeamCreation": true, - "EnableUserCreation": true, - "RestrictCreationToDomains": "", - "RestrictTeamNames": true, - "EnableTeamListing": false - }, - "SqlSettings": { - "DriverName": "postgres", - "DataSource": "postgres://MM_USERNAME:MM_PASSWORD@DB_HOST:DB_PORT/MM_DBNAME?sslmode=disable&connect_timeout=10", - "DataSourceReplicas": [], - "MaxIdleConns": 10, - "MaxOpenConns": 10, - "Trace": false, - "AtRestEncryptKey": "7rAh6iwQCkV4cA1Gsg3fgGOXJAQ43QVg" - }, - "LogSettings": { - "EnableConsole": false, - "ConsoleLevel": "INFO", - "EnableFile": true, - "FileLevel": "INFO", - "FileFormat": "", - "FileLocation": "" - }, - "FileSettings": { - "DriverName": "local", - "Directory": "/mattermost/data/", - "EnablePublicLink": true, - "PublicLinkSalt": "A705AklYF8MFDOfcwh3I488G8vtLlVip", - "ThumbnailWidth": 120, - "ThumbnailHeight": 100, - "PreviewWidth": 1024, - "PreviewHeight": 0, - "ProfileWidth": 128, - "ProfileHeight": 128, - "InitialFont": "luximbi.ttf", - "AmazonS3AccessKeyId": "", - "AmazonS3SecretAccessKey": "", - "AmazonS3Bucket": "", - "AmazonS3Region": "" - }, - "EmailSettings": { - "EnableSignUpWithEmail": true, - "SendEmailNotifications": false, - "RequireEmailVerification": false, - "FeedbackName": "", - "FeedbackEmail": "", - "SMTPUsername": "", - "SMTPPassword": "", - "SMTPServer": "", - "SMTPPort": "", - "ConnectionSecurity": "", - "InviteSalt": "bjlSR4QqkXFBr7TP4oDzlfZmcNuH9YoS", - "PasswordResetSalt": "vZ4DcKyVVRlKHHJpexcuXzojkE5PZ5eL", - "ApplePushServer": "", - "ApplePushCertPublic": "", - "ApplePushCertPrivate": "" - }, - "RateLimitSettings": { - "EnableRateLimiter": true, - "PerSec": 10, - "MemoryStoreSize": 10000, - "VaryByRemoteAddr": true, - "VaryByHeader": "" - }, - "PrivacySettings": { - "ShowEmailAddress": true, - "ShowFullName": true - }, - "GitLabSettings": { - "Enable": false, - "Secret": "", - "Id": "", - "Scope": "", - "AuthEndpoint": "", - "TokenEndpoint": "", - "UserApiEndpoint": "" - } -} diff --git a/app/docker-entry.sh b/app/docker-entry.sh index 7a78314..6a92b4e 100644 --- a/app/docker-entry.sh +++ b/app/docker-entry.sh @@ -1,7 +1,7 @@ #!/bin/bash DB_HOST=${DB_HOST:-db} -DB_PORT_5432_TCP_PORT=${DB_PORT_5432_TCP_PORT:-5432} +DB_PORT_NUMBER=${DB_PORT_NUMBER:-5432} MM_USERNAME=${MM_USERNAME:-mmuser} MM_PASSWORD=${MM_PASSWORD:-mmuser_password} MM_DBNAME=${MM_DBNAME:-mattermost} @@ -21,23 +21,17 @@ if [ "$1" = 'platform' ]; then done echo "Using config file" $MM_CONFIG - - echo -ne "Configure database connection..." if [ ! -f $MM_CONFIG ] then - cp /config.template.json $MM_CONFIG - sed -Ei "s/DB_HOST/$DB_HOST/" $MM_CONFIG - sed -Ei "s/DB_PORT/$DB_PORT_5432_TCP_PORT/" $MM_CONFIG - sed -Ei "s/MM_USERNAME/$MM_USERNAME/" $MM_CONFIG - sed -Ei "s/MM_PASSWORD/$MM_PASSWORD/" $MM_CONFIG - sed -Ei "s/MM_DBNAME/$MM_DBNAME/" $MM_CONFIG - echo OK - else - echo SKIP + cp /config.json.save $MM_CONFIG fi - echo "Wait until database $DB_HOST:$DB_PORT_5432_TCP_PORT is ready..." - until nc -z $DB_HOST $DB_PORT_5432_TCP_PORT + echo -ne "Configure database connection..." + export MM_SQLSETTINGS_DATASOURCE="postgres://$MM_USERNAME:$MM_PASSWORD@$DB_HOST:$DB_PORT_NUMBER/$MM_DBNAME?sslmode=disable&connect_timeout=10" + echo OK + + echo "Wait until database $DB_HOST:$DB_PORT_NUMBER is ready..." + until nc -z $DB_HOST $DB_PORT_NUMBER do sleep 1 done