|
| 1 | +# -------------------------------------------------------------------- |
| 2 | +# |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 | +# contributor license agreements. See the NOTICE file distributed |
| 5 | +# with this work for additional information regarding copyright |
| 6 | +# ownership. The ASF licenses this file to You under the Apache |
| 7 | +# License, Version 2.0 (the "License"); you may not use this file |
| 8 | +# except in compliance with the License. You may obtain a copy of the |
| 9 | +# License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 16 | +# implied. See the License for the specific language governing |
| 17 | +# permissions and limitations under the License. |
| 18 | +# |
| 19 | +# -------------------------------------------------------------------- |
| 20 | +# |
| 21 | +# Apache Cloudberry (incubating) is an effort undergoing incubation at |
| 22 | +# the Apache Software Foundation (ASF), sponsored by the Apache |
| 23 | +# Incubator PMC. |
| 24 | +# |
| 25 | +# Incubation is required of all newly accepted projects until a |
| 26 | +# further review indicates that the infrastructure, communications, |
| 27 | +# and decision making process have stabilized in a manner consistent |
| 28 | +# with other successful ASF projects. |
| 29 | +# |
| 30 | +# While incubation status is not necessarily a reflection of the |
| 31 | +# completeness or stability of the code, it does indicate that the |
| 32 | +# project has yet to be fully endorsed by the ASF. |
| 33 | +# |
| 34 | +# -------------------------------------------------------------------- |
| 35 | +# Dockerfile for Apache Cloudberry Base Environment |
| 36 | +# -------------------------------------------------------------------- |
| 37 | +# This Dockerfile sets up a Ubuntu jammy 22.04 -based container to serve as |
| 38 | +# a base environment for evaluating the Apache Cloudberry. It installs |
| 39 | +# necessary system utilities, configures the environment for SSH access, |
| 40 | +# and sets up a 'gpadmin' user with sudo privileges. The Apache Cloudberry |
| 41 | +# DEB can be installed into this container for testing and |
| 42 | +# functional verification. |
| 43 | +# |
| 44 | +# Key Features: |
| 45 | +# - Locale setup for en_US.UTF-8 |
| 46 | +# - SSH daemon setup for remote access |
| 47 | +# - Essential system utilities installation |
| 48 | +# - Separate user creation and configuration steps |
| 49 | +# |
| 50 | +# Security Considerations: |
| 51 | +# - This Dockerfile prioritizes ease of use for functional testing and |
| 52 | +# evaluation. It includes configurations such as passwordless sudo access |
| 53 | +# for the 'gpadmin' user and SSH access with password authentication. |
| 54 | +# - These configurations are suitable for testing and development but |
| 55 | +# should NOT be used in a production environment due to potential security |
| 56 | +# risks. |
| 57 | +# |
| 58 | +# Usage: |
| 59 | +# docker build -t cloudberry-db-base-env . |
| 60 | +# docker run -h cdw -it cloudberry-db-base-env |
| 61 | +# -------------------------------------------------------------------- |
| 62 | + |
| 63 | +FROM ubuntu:22.04 |
| 64 | + |
| 65 | +# Argument for configuring the timezone |
| 66 | +ARG TIMEZONE_VAR="Europe/London" |
| 67 | + |
| 68 | +# Environment variables for locale and user |
| 69 | +ENV container=docker |
| 70 | +ENV LANG=en_US.UTF-8 |
| 71 | +ENV USER=gpadmin |
| 72 | +ENV TZ=${TIMEZONE_VAR} |
| 73 | +ENV DEBIAN_FRONTEND=noninteractive |
| 74 | + |
| 75 | +# -------------------------------------------------------------------- |
| 76 | +# Install Development Tools and Utilities |
| 77 | +# -------------------------------------------------------------------- |
| 78 | + |
| 79 | +RUN sed -i "s/archive.ubuntu.com/mirror.yandex.ru/g" /etc/apt/sources.list && \ |
| 80 | + apt-get update && \ |
| 81 | + apt-get install -y -qq \ |
| 82 | + htop \ |
| 83 | + bat \ |
| 84 | + silversearcher-ag \ |
| 85 | + vim \ |
| 86 | + wget && \ |
| 87 | + apt-get install -y -qq locales && \ |
| 88 | + locale-gen "en_US.UTF-8" && \ |
| 89 | + update-locale LANG="en_US.UTF-8" && \ |
| 90 | + apt-get install -y -qq \ |
| 91 | + bison \ |
| 92 | + build-essential \ |
| 93 | + cmake \ |
| 94 | + dpkg-dev \ |
| 95 | + fakeroot \ |
| 96 | + flex \ |
| 97 | + g++-11 \ |
| 98 | + gcc-11 \ |
| 99 | + git \ |
| 100 | + iproute2 \ |
| 101 | + iputils-ping \ |
| 102 | + libapr1-dev \ |
| 103 | + libbz2-dev \ |
| 104 | + libcurl4-gnutls-dev \ |
| 105 | + libevent-dev \ |
| 106 | + libipc-run-perl \ |
| 107 | + libkrb5-dev \ |
| 108 | + libldap-dev \ |
| 109 | + liblz4-dev \ |
| 110 | + libpam0g-dev \ |
| 111 | + libperl-dev \ |
| 112 | + libprotobuf-dev \ |
| 113 | + libreadline-dev \ |
| 114 | + libssl-dev \ |
| 115 | + libuv1-dev \ |
| 116 | + libxerces-c-dev \ |
| 117 | + libxml2-dev \ |
| 118 | + libyaml-dev \ |
| 119 | + libzstd-dev \ |
| 120 | + lsof \ |
| 121 | + make \ |
| 122 | + openssh-server \ |
| 123 | + pkg-config \ |
| 124 | + protobuf-compiler \ |
| 125 | + python3-distutils \ |
| 126 | + python3-pip \ |
| 127 | + python3-setuptools \ |
| 128 | + python3.10 \ |
| 129 | + python3.10-dev \ |
| 130 | + rsync \ |
| 131 | + sudo \ |
| 132 | + tzdata \ |
| 133 | + zlib1g-dev && \ |
| 134 | + apt-get clean && rm -rf /var/lib/apt/lists/* && \ |
| 135 | + cd && GO_VERSION="go1.23.4" && \ |
| 136 | + ARCH=$(uname -m) && \ |
| 137 | + if [ "${ARCH}" = "aarch64" ]; then \ |
| 138 | + GO_ARCH="arm64" && \ |
| 139 | + GO_SHA256="16e5017863a7f6071363782b1b8042eb12c6ca4f4cd71528b2123f0a1275b13e"; \ |
| 140 | + elif [ "${ARCH}" = "x86_64" ]; then \ |
| 141 | + GO_ARCH="amd64" && \ |
| 142 | + GO_SHA256="6924efde5de86fe277676e929dc9917d466efa02fb934197bc2eba35d5680971"; \ |
| 143 | + else \ |
| 144 | + echo "Unsupported architecture: ${ARCH}" && exit 1; \ |
| 145 | + fi && \ |
| 146 | + GO_URL="https://go.dev/dl/${GO_VERSION}.linux-${GO_ARCH}.tar.gz" && \ |
| 147 | + wget -nv "${GO_URL}" && \ |
| 148 | + echo "${GO_SHA256} ${GO_VERSION}.linux-${GO_ARCH}.tar.gz" | sha256sum -c - && \ |
| 149 | + tar xf "${GO_VERSION}.linux-${GO_ARCH}.tar.gz" && \ |
| 150 | + mv go "/usr/local/${GO_VERSION}" && \ |
| 151 | + ln -s "/usr/local/${GO_VERSION}" /usr/local/go && \ |
| 152 | + rm -f "${GO_VERSION}.linux-${GO_ARCH}.tar.gz" && \ |
| 153 | + echo 'export PATH=$PATH:/usr/local/go/bin' | tee -a /etc/profile.d/go.sh > /dev/null |
| 154 | + |
| 155 | +RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 && \ |
| 156 | + update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 100 && \ |
| 157 | + update-alternatives --install /usr/bin/x86_64-linux-gnu-gcc x86_64-linux-gnu-gcc /usr/bin/gcc-11 100 && \ |
| 158 | + update-alternatives --set gcc /usr/bin/gcc-11 && \ |
| 159 | + update-alternatives --set g++ /usr/bin/g++-11 |
| 160 | + |
| 161 | +# -------------------------------------------------------------------- |
| 162 | +# Copy Configuration Files and Setup the Environment |
| 163 | +# -------------------------------------------------------------------- |
| 164 | + |
| 165 | +COPY ./configs/* /tmp/ |
| 166 | + |
| 167 | +RUN cp /tmp/90-cbdb-limits /etc/security/limits.d/90-cbdb-limits && \ |
| 168 | + ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \ |
| 169 | + echo $TZ > /etc/timezone && \ |
| 170 | + chmod 755 /tmp/init_system.sh && \ |
| 171 | + /usr/sbin/groupadd gpadmin && \ |
| 172 | + /usr/sbin/useradd -m -g gpadmin gpadmin && \ |
| 173 | + echo 'gpadmin ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/90-gpadmin && \ |
| 174 | + chmod 0440 /etc/sudoers.d/90-gpadmin && \ |
| 175 | + ssh-keygen -A && \ |
| 176 | + mkdir /var/run/sshd && chmod 0755 /var/run/sshd |
| 177 | + |
| 178 | +# Install testinfra via pip |
| 179 | +RUN pip3 install pytest-testinfra |
| 180 | + |
| 181 | +# Example: Copying test files into the container |
| 182 | +COPY tests /tests |
| 183 | + |
| 184 | +USER gpadmin |
| 185 | +WORKDIR /home/gpadmin |
| 186 | + |
| 187 | +CMD ["bash","-c","/tmp/init_system.sh"] |
0 commit comments