summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Dockerfile92
-rw-r--r--config/config_docker.json83
-rwxr-xr-xdocker-entry.sh114
3 files changed, 289 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..2e2ad002d
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,92 @@
+FROM ubuntu:14.04
+
+# Install Dependancies
+RUN apt-get update && apt-get install -y build-essential
+RUN apt-get install -y curl
+RUN curl -sL https://deb.nodesource.com/setup | bash -
+RUN apt-get install -y nodejs
+RUN apt-get install -y ruby-full
+RUN gem install compass
+
+#
+# Install GO
+#
+
+RUN apt-get update && apt-get install -y \
+ gcc libc6-dev make git mercurial \
+ --no-install-recommends \
+ && rm -rf /var/lib/apt/lists/*
+
+ENV GOLANG_VERSION 1.4.2
+
+RUN curl -sSL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz \
+ | tar -v -C /usr/src -xz
+
+RUN cd /usr/src/go/src && ./make.bash --no-clean 2>&1
+
+ENV PATH /usr/src/go/bin:$PATH
+
+RUN mkdir -p /go/src /go/bin && chmod -R 777 /go
+ENV GOPATH /go
+ENV PATH /go/bin:$PATH
+WORKDIR /go
+
+# ---------------------------------------------------------------------------------------------------------------------
+
+#
+# Install SQL
+#
+
+ENV MYSQL_ROOT_PASSWORD=mostest
+ENV MYSQL_USER=mmuser
+ENV MYSQL_PASSWORD=mostest
+ENV MYSQL_DATABASE=mattermost_test
+
+RUN groupadd -r mysql && useradd -r -g mysql mysql
+
+RUN apt-get update && apt-get install -y perl --no-install-recommends && rm -rf /var/lib/apt/lists/*
+
+RUN apt-key adv --keyserver pool.sks-keyservers.net --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5
+
+ENV MYSQL_MAJOR 5.6
+ENV MYSQL_VERSION 5.6.25
+
+RUN echo "deb http://repo.mysql.com/apt/debian/ wheezy mysql-${MYSQL_MAJOR}" > /etc/apt/sources.list.d/mysql.list
+
+RUN apt-get update \
+ && export DEBIAN_FRONTEND=noninteractive \
+ && apt-get -y install mysql-server \
+ && rm -rf /var/lib/apt/lists/* \
+ && rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql
+
+RUN sed -Ei 's/^(bind-address|log)/#&/' /etc/mysql/my.cnf
+
+VOLUME /var/lib/mysql
+# ---------------------------------------------------------------------------------------------------------------------
+
+#
+# Install Redis
+#
+
+RUN apt-get update && apt-get install -y wget
+RUN wget http://download.redis.io/redis-stable.tar.gz; \
+ tar xvzf redis-stable.tar.gz; \
+ cd redis-stable; \
+ make install
+
+# ---------------------------------------------------------------------------------------------------------------------
+
+# Copy over files
+ADD . /go/src/github.com/mattermost/platform
+
+
+RUN go get github.com/tools/godep
+RUN cd /go/src/github.com/mattermost/platform; godep restore
+RUN go install github.com/mattermost/platform
+RUN cd /go/src/github.com/mattermost/platform/web/react; npm install
+
+RUN chmod +x /go/src/github.com/mattermost/platform/docker-entry.sh
+ENTRYPOINT /go/src/github.com/mattermost/platform/docker-entry.sh
+
+# Ports
+EXPOSE 8065
diff --git a/config/config_docker.json b/config/config_docker.json
new file mode 100644
index 000000000..470c41bb5
--- /dev/null
+++ b/config/config_docker.json
@@ -0,0 +1,83 @@
+{
+ "LogSettings": {
+ "ConsoleEnable": true,
+ "ConsoleLevel": "DEBUG",
+ "FileEnable": true,
+ "FileLevel": "INFO",
+ "FileFormat": "",
+ "FileLocation": ""
+ },
+ "ServiceSettings": {
+ "SiteName": "",
+ "Domain": "",
+ "Mode" : "dev",
+ "AllowTesting" : false,
+ "UseSSL": false,
+ "Port": "80",
+ "Version": "developer",
+ "Shards": {
+ },
+ "InviteSalt": "4nAN4CuEJQ4G73RPA9DJrcVkbrGIE9SX",
+ "PublicLinkSalt": "zBXCZvnXQ5aRfzqPHgrK5G6wunsPzimE",
+ "ResetSalt": "GcloaPC5tjGCzwXApNJ23oSLUoP8LXQ4",
+ "AnalyticsUrl": ""
+ },
+ "SqlSettings": {
+ "DriverName": "mysql",
+ "DataSource": "mmuser:mostest@tcp(localhost:3306)/mattermost_test",
+ "DataSourceReplicas": ["mmuser:mostest@tcp(localhost:3306)/mattermost_test"],
+ "MaxIdleConns": 10,
+ "MaxOpenConns": 10,
+ "Trace": false,
+ "AtRestEncryptKey": "4Uuoy2t1S204JUKXHGfALJL2J5q3jlEH"
+ },
+ "RedisSettings": {
+ "DataSource": "localhost:6379",
+ "MaxOpenConns": 100
+ },
+ "AWSSettings": {
+ "S3AccessKeyId": "",
+ "S3SecretAccessKey": "",
+ "S3Bucket": "",
+ "S3Region": "",
+ "Route53AccessKeyId": "",
+ "Route53SecretAccessKey": "",
+ "Route53ZoneId": "",
+ "Route53Region": ""
+ },
+ "ImageSettings": {
+ "ThumbnailWidth": 200,
+ "ThumbnailHeight": 0,
+ "PreviewWidth": 1024,
+ "PreviewHeight": 0,
+ "ProfileWidth": 128,
+ "ProfileHeight": 128
+ },
+ "EmailSettings": {
+ "SMTPUsername": "",
+ "SMTPPassword": "",
+ "SMTPServer": "",
+ "FeedbackEmail": "feedback@mattermost.com",
+ "FeedbackName": "",
+ "ApplePushServer": "",
+ "ApplePushCertPublic": "",
+ "ApplePushCertPrivate":""
+ },
+ "PrivacySettings": {
+ "ShowEmailAddress": false,
+ "ShowPhoneNumber": false,
+ "ShowSkypeId": false,
+ "ShowFullName": false
+ },
+ "TeamSettings": {
+ "MaxUsersPerTeam": 150,
+ "AllowPublicLink": true,
+ "TermsLink": "/static/help/configure_links.html",
+ "PrivacyLink": "/static/help/configure_links.html",
+ "AboutLink": "/static/help/configure_links.html",
+ "HelpLink": "/static/help/configure_links.html",
+ "ReportProblemLink": "/static/help/configure_links.html",
+ "TourLink": "/static/help/configure_links.html",
+ "DefaultThemeColor": "#2389D7"
+ }
+}
diff --git a/docker-entry.sh b/docker-entry.sh
new file mode 100755
index 000000000..10809fc1d
--- /dev/null
+++ b/docker-entry.sh
@@ -0,0 +1,114 @@
+#!/bin/bash
+
+mkdir -p web/static/js
+
+echo configuring mysql
+
+# SQL!!!
+set -e
+
+get_option () {
+ local section=$1
+ local option=$2
+ local default=$3
+ ret=$(my_print_defaults $section | grep '^--'${option}'=' | cut -d= -f2-)
+ [ -z $ret ] && ret=$default
+ echo $ret
+}
+
+
+# Get config
+DATADIR="$("mysqld" --verbose --help 2>/dev/null | awk '$1 == "datadir" { print $2; exit }')"
+SOCKET=$(get_option mysqld socket "$DATADIR/mysql.sock")
+PIDFILE=$(get_option mysqld pid-file "/var/run/mysqld/mysqld.pid")
+
+if [ ! -d "$DATADIR/mysql" ]; then
+ if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" ]; then
+ echo >&2 'error: database is uninitialized and MYSQL_ROOT_PASSWORD not set'
+ echo >&2 ' Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?'
+ exit 1
+ fi
+
+ mkdir -p "$DATADIR"
+ chown -R mysql:mysql "$DATADIR"
+
+ echo 'Running mysql_install_db'
+ mysql_install_db --user=mysql --datadir="$DATADIR" --rpm --keep-my-cnf
+ echo 'Finished mysql_install_db'
+
+ mysqld --user=mysql --datadir="$DATADIR" --skip-networking &
+ for i in $(seq 30 -1 0); do
+ [ -S "$SOCKET" ] && break
+ echo 'MySQL init process in progress...'
+ sleep 1
+ done
+ if [ $i = 0 ]; then
+ echo >&2 'MySQL init process failed.'
+ exit 1
+ fi
+
+ # These statements _must_ be on individual lines, and _must_ end with
+ # semicolons (no line breaks or comments are permitted).
+ # TODO proper SQL escaping on ALL the things D:
+
+ tempSqlFile=$(mktemp /tmp/mysql-first-time.XXXXXX.sql)
+ cat > "$tempSqlFile" <<-EOSQL
+ -- What's done in this file shouldn't be replicated
+ -- or products like mysql-fabric won't work
+ SET @@SESSION.SQL_LOG_BIN=0;
+
+ DELETE FROM mysql.user ;
+ CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
+ GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ;
+ DROP DATABASE IF EXISTS test ;
+ EOSQL
+
+ if [ "$MYSQL_DATABASE" ]; then
+ echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` ;" >> "$tempSqlFile"
+ fi
+
+ if [ "$MYSQL_USER" -a "$MYSQL_PASSWORD" ]; then
+ echo "CREATE USER '"$MYSQL_USER"'@'%' IDENTIFIED BY '"$MYSQL_PASSWORD"' ;" >> "$tempSqlFile"
+
+ if [ "$MYSQL_DATABASE" ]; then
+ echo "GRANT ALL ON \`"$MYSQL_DATABASE"\`.* TO '"$MYSQL_USER"'@'%' ;" >> "$tempSqlFile"
+ fi
+ fi
+
+ echo 'FLUSH PRIVILEGES ;' >> "$tempSqlFile"
+
+ mysql -uroot < "$tempSqlFile"
+
+ rm -f "$tempSqlFile"
+ kill $(cat $PIDFILE)
+ for i in $(seq 30 -1 0); do
+ [ -f "$PIDFILE" ] || break
+ echo 'MySQL init process in progress...'
+ sleep 1
+ done
+ if [ $i = 0 ]; then
+ echo >&2 'MySQL hangs during init process.'
+ exit 1
+ fi
+ echo 'MySQL init process done. Ready for start up.'
+fi
+
+chown -R mysql:mysql "$DATADIR"
+
+mysqld &
+
+sleep 5
+
+# ------------------------
+
+echo starting redis
+redis-server &
+
+echo starting react processor
+cd /go/src/github.com/mattermost/platform/web/react && npm start &
+
+echo starting go web server
+cd /go/src/github.com/mattermost/platform/; go run mattermost.go -config=config_docker.json &
+
+echo starting compass watch
+cd /go/src/github.com/mattermost/platform/web/sass-files && compass watch