github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/acceptance/testdata/Dockerfile (about)

     1  FROM ubuntu:18.04
     2  
     3  # This Dockerfile bundles several language runtimes and test frameworks into one
     4  # container for our acceptance tests.
     5  #
     6  # Here are some tips for keeping this file maintainable.
     7  #
     8  #   - When possible, keep commands that are slow to rebuild towards the top of
     9  #     the file and keep commands that change frequently towards the bottom of
    10  #     the file. Changing a command invalidates the build cache for all following
    11  #     commands.
    12  #
    13  #   - Group logical stages into one RUN command, but not when it groups a slow
    14  #     step that's unlikely to change with a step that's likely to change
    15  #     frequently.
    16  #
    17  #   - Follow the visual indentation scheme.
    18  #
    19  #   - Don't cargo cult installation instructions from the web. There are many
    20  #     ways to add a new APT repository, for example; we should only use one.
    21  #     There are many ways to invoke curl and tar; we should be consistent.
    22  #
    23  #   - Store artifacts in /opt rather than cluttering the root directory.
    24  #
    25  #   - Prefer packages from APT to packages from each language's package
    26  #     managers.
    27  
    28  RUN apt-get update \
    29   && apt-get install --yes --no-install-recommends ca-certificates curl
    30  
    31  # The forward reference version is the oldest version from which we support
    32  # upgrading. The bidirectional reference version is the oldest version that we
    33  # support upgrading from and downgrading to.
    34  ENV FORWARD_REFERENCE_VERSION="v2.0.0"
    35  ENV BIDIRECTIONAL_REFERENCE_VERSION="v2.0.0"
    36  RUN mkdir /opt/forward-reference-version /opt/bidirectional-reference-version \
    37   && curl -fsSL https://binaries.cockroachdb.com/cockroach-${FORWARD_REFERENCE_VERSION}.linux-amd64.tgz \
    38      | tar xz -C /opt/forward-reference-version --strip-components=1 \
    39   && curl -fsSL https://binaries.cockroachdb.com/cockroach-${BIDIRECTIONAL_REFERENCE_VERSION}.linux-amd64.tgz \
    40      | tar xz -C /opt/bidirectional-reference-version --strip-components=1
    41  
    42  RUN apt-get install --yes --no-install-recommends openjdk-8-jdk \
    43   && curl -fsSL https://github.com/cockroachdb/finagle-postgres/archive/94b1325270.tar.gz | tar xz \
    44   && cd finagle-postgres-* \
    45   && ./sbt assembly \
    46   && mv target/scala-2.11/finagle-postgres-tests.jar /opt/finagle-postgres-tests.jar \
    47   && rm -rf /finagle-postgres-* ~/.ivy2
    48  
    49  RUN curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg > /etc/apt/trusted.gpg.d/yarn.asc \
    50   && echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
    51   && curl -fsSL https://packages.microsoft.com/keys/microsoft.asc > /etc/apt/trusted.gpg.d/microsoft.asc \
    52   && echo "deb https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod/ bionic main" > /etc/apt/sources.list.d/microsoft.list \
    53   && apt-get install --yes --no-install-recommends gnupg \
    54   && curl https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb > erlang-solutions_2.0_all.deb && dpkg -i erlang-solutions_2.0_all.deb \
    55   && apt-get update \
    56   && apt-get install --yes --no-install-recommends \
    57      dotnet-sdk-2.1 \
    58      dotnet-runtime-2.1 \
    59      expect \
    60      elixir \
    61      esl-erlang \
    62      libc6-dev \
    63      libcurl4 \
    64      libpq-dev \
    65      libpqtypes-dev \
    66      make \
    67      maven \
    68      nodejs \
    69      gcc \
    70      golang \
    71      php-cli \
    72      php-pgsql \
    73      postgresql-client \
    74      python \
    75      python-psycopg2 \
    76      ruby \
    77      ruby-pg \
    78      xmlstarlet \
    79      yarn
    80  
    81  RUN curl -fsSL https://github.com/benesch/autouseradd/releases/download/1.0.0/autouseradd-1.0.0-amd64.tar.gz \
    82      | tar xz -C /usr --strip-components 1
    83  
    84  # When system packages are not available for a language's PostgreSQL driver,
    85  # fall back to using that language's package manager. The high-level process
    86  # looks like this:
    87  #
    88  #   1. Configure the package manager to install dependencies into a system-wide
    89  #      location (/var/lib/...) instead of a user-specific location (/root/...).
    90  #      /root is not world-readable, and we want the packages to be available to
    91  #      non-root users.
    92  #
    93  #   2. Instruct the package manager to install the dependencies by reading
    94  #      whatever language-specific package manifest exists in testdata/LANG.
    95  #
    96  #   3. Either remove the package manager entirely, if it's not used to drive
    97  #      tests, or put it into offline mode. This ensures that future dependencies
    98  #      get baked into the container, lest we accidentally introduce a CI-time
    99  #      dependency on the remote package repository.
   100  
   101  COPY . /testdata
   102  
   103  # Handle C# dependencies using the NuGet package manager.
   104  ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 NUGET_PACKAGES=/var/lib/nuget/packages
   105  RUN (cd /testdata/csharp && dotnet restore --no-cache) \
   106   && xmlstarlet ed --inplace \
   107      --subnode /configuration --type elem --name packageRestore \
   108      --subnode '$prev' --type elem --name add \
   109      --insert '$prev' --type attr --name key --value enabled \
   110      --insert '$prev' --type attr --name value --value false \
   111      --delete /configuration/packageSources \
   112      ~/.nuget/NuGet/NuGet.Config
   113  
   114  # Handle Java dependencies using the Maven package manager.
   115  RUN xmlstarlet ed --inplace \
   116      --subnode /_:settings --type elem --name localRepository --value /var/lib/maven/repository \
   117      /usr/share/maven/conf/settings.xml \
   118   && (cd /testdata/java && mvn -Dtest=NoopTest dependency:go-offline package) \
   119   && xmlstarlet ed --inplace \
   120      --subnode /_:settings --type elem --name offline --value true \
   121      /usr/share/maven/conf/settings.xml
   122  
   123  # Handle Node dependencies using the Yarn package manager.
   124  RUN (cd /testdata/node && yarn install && mv node_modules /usr/lib/node) \
   125   && apt-get purge --yes yarn
   126  
   127  RUN apt-get purge --yes \
   128      curl \
   129      xmlstarlet \
   130   && rm -rf /tmp/* /var/lib/apt/lists/* /testdata