diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000000..f3f103e770 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,47 @@ +FROM alpine:3.10 + +# Some ENV variables +ENV PATH="/mattermost/bin:${PATH}" +ARG PUID=2000 +ARG PGID=2000 +ARG MM_PACKAGE="https://releases.mattermost.com/5.12.4/mattermost-5.12.4-linux-amd64.tar.gz" + + +# Install some needed packages +RUN apk add --no-cache \ + ca-certificates \ + curl \ + libc6-compat \ + libffi-dev \ + linux-headers \ + mailcap \ + netcat-openbsd \ + xmlsec-dev \ + tzdata \ + && rm -rf /tmp/* + +# Get Mattermost +RUN mkdir -p /mattermost/data /mattermost/plugins /mattermost/client/plugins \ + && if [ ! -z "$MM_PACKAGE" ]; then curl $MM_PACKAGE | tar -xvz ; \ + else echo "please set the MM_PACKAGE" ; fi \ + && addgroup -g ${PGID} mattermost \ + && adduser -D -u ${PUID} -G mattermost -h /mattermost -D mattermost \ + && chown -R mattermost:mattermost /mattermost /mattermost/plugins /mattermost/client/plugins + +USER mattermost + +#Healthcheck to make sure container is ready +HEALTHCHECK --interval=5m --timeout=3s \ + CMD curl -f http://localhost:8065/api/v4/system/ping || exit 1 + + +# Configure entrypoint and command +COPY entrypoint.sh / +ENTRYPOINT ["/entrypoint.sh"] +WORKDIR /mattermost +CMD ["mattermost"] + +EXPOSE 8065 8067 8074 8075 + +# Declare volumes for mount point directories +VOLUME ["/mattermost/data", "/mattermost/logs", "/mattermost/config", "/mattermost/plugins", "/mattermost/client/plugins"] diff --git a/build/Jenkinsfile.branch b/build/Jenkinsfile.branch index 52b4369f2e..8e96cedb17 100644 --- a/build/Jenkinsfile.branch +++ b/build/Jenkinsfile.branch @@ -117,10 +117,16 @@ pipeline { stage ('Build Docker mattermost-enterprise-edition') { steps { - script { - platformStages.platformCheckoutDockerRepo('master') - def MMBINARYPATH="https://releases.mattermost.com/mattermost-platform/" + env.BRANCH_NAME + "/mattermost-enterprise-linux-amd64.tar.gz" - platformStages.platformBuildDockerImage(MMBINARYPATH, env.BRANCH_NAME + '.' + env.BUILD_NUMBER + '.' + SERVER_GIT_COMMIT) + dir('src/github.com/mattermost/mattermost-server') { + withCredentials([usernamePassword(credentialsId: 'matterbuild-docker-hub', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) { + sh 'docker login --username ${DOCKER_USER} --password ${DOCKER_PASS}' + sh """ + export TAG='${env.BRANCH_NAME}.${env.BUILD_NUMBER}.${SERVER_GIT_COMMIT}' + docker build --no-cache --build-arg MM_PACKAGE=https://releases.mattermost.com/mattermost-platform/${env.BRANCH_NAME}/mattermost-enterprise-linux-amd64.tar.gz -t mattermost/mattermost-enterprise-edition:\${TAG} build + docker push mattermost/mattermost-enterprise-edition:${GIT_COMMIT_SHORT} + docker logout + """ + } } } } diff --git a/build/Jenkinsfile.pr b/build/Jenkinsfile.pr index fc6c61f5a6..76d65af55d 100644 --- a/build/Jenkinsfile.pr +++ b/build/Jenkinsfile.pr @@ -259,18 +259,27 @@ pipeline { } } - stage('Trigger docker image') { + stage('Build Docker Image') { environment { GIT_COMMIT_SHORT = sh( - script: "cd /tmp/mattermost-server && printf \$(git rev-parse --short HEAD)", - returnStdout: true + script: "cd /tmp/mattermost-server && printf \$(git rev-parse --short HEAD)", + returnStdout: true ) } when { expression { env.CHANGE_ID != null } } steps { - build job: '../../mk/mattermost-enterprise-edition-release', parameters: [string(name: 'RELEASE', value: "${CHANGE_ID}"), booleanParam(name: 'FROM_PR', value: true),string(name: 'PR_TAG', value: "${GIT_COMMIT_SHORT}")], propagate: false, wait: false + dir('src/github.com/mattermost/mattermost-server') { + withCredentials([usernamePassword(credentialsId: 'matterbuild-docker-hub', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) { + sh 'docker login --username ${DOCKER_USER} --password ${DOCKER_PASS}' + sh """ + docker build --no-cache --build-arg MM_PACKAGE=https://releases.mattermost.com/mattermost-platform-pr/${CHANGE_ID}/mattermost-enterprise-linux-amd64.tar.gz -t mattermost/mattermost-enterprise-edition:${GIT_COMMIT_SHORT} build + docker push mattermost/mattermost-enterprise-edition:${GIT_COMMIT_SHORT} + docker logout + """ + } + } } } } diff --git a/build/entrypoint.sh b/build/entrypoint.sh new file mode 100755 index 0000000000..2177b9e87e --- /dev/null +++ b/build/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ "${1:0:1}" = '-' ]; then + set -- mattermost "$@" +fi + +exec "$@"