From c5f58008144bfc3bbd7ebdffe8d94147cbf5e34f Mon Sep 17 00:00:00 2001 From: Antonis Stamatiou Date: Fri, 15 Dec 2023 12:28:02 +0200 Subject: [PATCH] feat: Migrate docker preview repo stuff in monorepo (#25698) * feat: Migrate docker preview repo stuff in monorepo * docs: Update docs [skip ci] * config: Update configuration to minimum [skip ci] --- server/build/docker-preview/Dockerfile | 39 +++++++++++++++++++ server/build/docker-preview/README.md | 19 +++++++++ .../build/docker-preview/config_docker.json | 29 ++++++++++++++ server/build/docker-preview/docker-entry.sh | 18 +++++++++ 4 files changed, 105 insertions(+) create mode 100644 server/build/docker-preview/Dockerfile create mode 100644 server/build/docker-preview/README.md create mode 100644 server/build/docker-preview/config_docker.json create mode 100644 server/build/docker-preview/docker-entry.sh diff --git a/server/build/docker-preview/Dockerfile b/server/build/docker-preview/Dockerfile new file mode 100644 index 0000000000..db295b7342 --- /dev/null +++ b/server/build/docker-preview/Dockerfile @@ -0,0 +1,39 @@ +# Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. +# See License.txt for license information. +FROM postgres:12 + +RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29 +RUN apt-get update && apt-get install -y ca-certificates + +ARG MATTERMOST_VERSION +# +# Configure PostgreSQL +# + +ENV POSTGRES_USER=mmuser +ENV POSTGRES_PASSWORD=mostest +ENV POSTGRES_DB=mattermost_test + +# +# Configure Mattermost +# +WORKDIR /mm + +# Copy over files +ADD https://releases.mattermost.com/${MATTERMOST_VERSION}/mattermost-team-${MATTERMOST_VERSION}-linux-amd64.tar.gz . +RUN tar -zxvf mattermost-team-${MATTERMOST_VERSION}-linux-amd64.tar.gz +ADD config_docker.json ./mattermost/config/config_docker.json +ADD docker-entry.sh . + +RUN chmod +x ./docker-entry.sh +ENTRYPOINT ./docker-entry.sh + +# Mattermost environment variables +ENV PATH="/mm/mattermost/bin:${PATH}" + +# Create default storage directory +RUN mkdir ./mattermost-data +VOLUME /mm/mattermost-data + +# Ports +EXPOSE 8065 diff --git a/server/build/docker-preview/README.md b/server/build/docker-preview/README.md new file mode 100644 index 0000000000..43e928a556 --- /dev/null +++ b/server/build/docker-preview/README.md @@ -0,0 +1,19 @@ +# Mattermost Docker Preview Image + +This is a Docker image to install Mattermost in *Preview Mode* for exploring product functionality on a single machine using Docker. + +Note: This configuration should not be used in production, as it’s using a known password string and contains other non-production configuration settings, and it does not support upgrade. If you’re looking for a production installation with Docker, please see the [Mattermost Production Docker Deployment Guide](https://docs.mattermost.com/install/install-docker.html#deploy-mattermost-on-docker-for-production-use). + +To contribute, please see [Contribution Guidelines](https://developers.mattermost.com/contribute/more-info/getting-started/). + +To file issues, [search for existing bugs and file a GitHub issue if your bug is new](https://developers.mattermost.com/contribute/why-contribute/#youve-found-a-bug). + +## Usage + +Please see [documentation for usage](http://docs.mattermost.com/install/docker-local-machine.html). + +If you have Docker already set up, you can run this image in one line: + +``` +docker run --name mattermost-preview -d --publish 8065:8065 --add-host dockerhost:127.0.0.1 mattermost/mattermost-preview +``` diff --git a/server/build/docker-preview/config_docker.json b/server/build/docker-preview/config_docker.json new file mode 100644 index 0000000000..3c7aa4b2d0 --- /dev/null +++ b/server/build/docker-preview/config_docker.json @@ -0,0 +1,29 @@ +{ + "ServiceSettings": { + "EnableOAuthServiceProvider": true, + "EnableDeveloper": false, + "EnableGifPicker": true + }, + "SqlSettings": { + "DriverName": "postgres", + "DataSource": "postgres://mmuser:mostest@localhost/mattermost_test?sslmode=disable\u0026connect_timeout=10\u0026binary_parameters=yes", + "AtRestEncryptKey": "" + }, + "FileSettings": { + "DriverName": "local", + "Directory": "/mm/mattermost-data", + "PublicLinkSalt": "" + }, + "EmailSettings": { + "SMTPServer": "", + "SMTPPort": "", + "PushNotificationContents": "generic" + }, + "ElasticsearchSettings": { + "ConnectionUrl": "" + }, + "PluginSettings": { + "EnableUploads": true, + "PluginStates": {} + } +} diff --git a/server/build/docker-preview/docker-entry.sh b/server/build/docker-preview/docker-entry.sh new file mode 100644 index 0000000000..7c02bc6622 --- /dev/null +++ b/server/build/docker-preview/docker-entry.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +# See License.txt for license information. + +echo "Starting PostgreSQL" +docker-entrypoint.sh -c 'shared_buffers=256MB' -c 'max_connections=300' & + +until pg_isready -hlocalhost -p 5432 -U "$POSTGRES_USER" &> /dev/null; do + echo "postgres still not ready, sleeping" + sleep 5 +done + +echo "Updating CA certificates" +update-ca-certificates --fresh >/dev/null + +echo "Starting platform" +cd mattermost +exec ./bin/mattermost --config=config/config_docker.json