From efed80a90c8c83ca115df3208059645a5a046e19 Mon Sep 17 00:00:00 2001 From: Akis Maziotis <36594156+phoinixgrr@users.noreply.github.com> Date: Sat, 13 Aug 2022 01:44:32 +0300 Subject: [PATCH] [CLD-3942] Container Image used for e2e testing, migration from Alpine to Debian Linux (#20807) * [fix] Dockerfile using Debian instead of Alpine We are switching to building docker container for Matermmost-server & enterprise from Alpine Linux(unsupported) to Debian(supported) This image is used for e2e testing. Rationalle: Alpine is actually unsupported distro for Mattermost-server. https://docs.mattermost.com/install/software-hardware-requirements.html#mattermost-server-operating-system On top of that, Alpine linux uses musl libc vs glibc, which can cause several issues when testing Finally We got to a point of being unable to run Alpine based mattermost instances with: `Error relocating ./mattermost: fcntl64: symbol not found` Details @ https://github.com/mattermost/mattermost-server/pull/20735 Specifically the following changes are introduced: - switching to using Debian Buster as being a supported linux flavor for Mattermost - pinning the Debian base image with SHA hash - defining Shell as bash, and enabling pipefail - pinning additional packages installed using apt - removing unused cache - improving MM_PACKAGE variable checking logic introducing non zero exit code (127) when failing - migrating adduser and addgroup command, to debian compatible - removing unused chown dirs Signed-off-by: Akis Maziotis * [fix] Using bash as a more capable shell * [fix] Installing optional packages needed for tests These packages are needed to perform succesfull end to end testing. Relevant documentation: https://docs.mattermost.com/configure/file-storage-configuration-settings.html#enable-document-search-by-content Signed-off-by: Akis Maziotis --- build/Dockerfile | 47 ++++++++++++++++++++++----------------------- build/entrypoint.sh | 2 +- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index e1931e8261..cd365fd6c2 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,4 +1,7 @@ -FROM alpine:3.14.6@sha256:06b5d462c92fc39303e6363c65e074559f8d6b1363250027ed5053557e3398c5 +FROM debian:buster-slim@sha256:5b0b1a9a54651bbe9d4d3ee96bbda2b2a1da3d2fa198ddebbced46dfdca7f216 + +# Setting bash as our shell, and enabling pipefail option +SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Some ENV variables ENV PATH="/mattermost/bin:${PATH}" @@ -6,38 +9,33 @@ ARG PUID=2000 ARG PGID=2000 ARG MM_PACKAGE="https://releases.mattermost.com/7.1.2/mattermost-7.1.2-linux-amd64.tar.gz?src=docker" +# # Install needed packages +RUN apt-get update \ + && apt-get install --no-install-recommends -y \ + ca-certificates=20200601~deb10u2 \ + curl=7.64.0-4+deb10u2 \ + mime-support=3.62 \ + unrtf=0.21.10-clean-1 \ + wv=1.2.9-4.2+b2 \ + poppler-utils=0.71.0-5 \ + tidy=2:5.6.0-10 \ + && rm -rf /var/lib/apt/lists/* -# Install some needed packages -RUN apk add --no-cache \ - ca-certificates \ - curl \ - libc6-compat \ - libffi-dev \ - linux-headers \ - mailcap \ - netcat-openbsd \ - xmlsec-dev \ - tzdata \ - wv \ - poppler-utils \ - tidyhtml \ - && rm -rf /tmp/* - -# Get Mattermost +# Set mattermost group/user and download 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 + && addgroup -gid ${PGID} mattermost \ + && adduser -q --disabled-password --uid ${PUID} --gid ${PGID} --gecos "" --home /mattermost mattermost \ + && if [ -n "$MM_PACKAGE" ]; then curl $MM_PACKAGE | tar -xvz ; \ + else echo "please set the MM_PACKAGE" ; exit 127 ; fi \ + && chown -R mattermost:mattermost /mattermost /mattermost/data /mattermost/plugins /mattermost/client/plugins +# We should refrain from running as privileged user USER mattermost #Healthcheck to make sure container is ready HEALTHCHECK --interval=30s --timeout=10s \ CMD curl -f http://localhost:8065/api/v4/system/ping || exit 1 - # Configure entrypoint and command COPY entrypoint.sh / ENTRYPOINT ["/entrypoint.sh"] @@ -48,3 +46,4 @@ 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/entrypoint.sh b/build/entrypoint.sh index 2177b9e87e..3d152519ef 100755 --- a/build/entrypoint.sh +++ b/build/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash if [ "${1:0:1}" = '-' ]; then set -- mattermost "$@"