FROM golang:latest ### Install InfluxDB clients for testing # Install InfluxDB keys to verify client installs. # Follow the install instructions (https://docs.influxdata.com/telegraf/v1/install/?t=curl), except for sudo (which isn't available in Docker). # influxdata-archive.key GPG fingerprint: # Primary key fingerprint: 24C9 75CB A61A 024E E1B6 3178 7C3D 5715 9FC2 F927 # Subkey fingerprint: 9D53 9D90 D332 8DC7 D6C8 D3B9 D8FF 8E1F 7DF8 B07E ADD https://repos.influxdata.com/influxdata-archive.key ./influxdata-archive.key RUN gpg --no-default-keyring --homedir $(mktemp -d) --show-keys --with-fingerprint --with-colons ./influxdata-archive.key 2>&1 | grep -q '^fpr:\+24C975CBA61A024EE1B631787C3D57159FC2F927:$' && cat influxdata-archive.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/influxdata-archive.gpg > /dev/null RUN echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive.gpg] https://repos.influxdata.com/debian stable main' | tee /etc/apt/sources.list.d/influxdata.list # Vault is used for testing InfluxDB 2.0 Secrets # Fetch vault package information from HashiCorp repository ADD https://apt.releases.hashicorp.com/gpg /tmp/hashicorp.gpg RUN apt-get update && apt-get install -y lsb-release && \ cat /tmp/hashicorp.gpg | gpg --dearmor > /usr/share/keyrings/hashicorp-archive-keyring.gpg && \ echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \ tee /etc/apt/sources.list.d/hashicorp.list # Install depedencies for clients and tests. # - InfluxData clients to use in tests. # - apt-utils for verification tools # - perl for shasum (default on MacOS) RUN apt-get update && apt-get upgrade -y && apt-get install -y \ apt-utils \ curl \ git \ gpg \ influxdb2 \ influxdb2-cli \ influxctl \ jq \ maven \ nodejs \ npm \ perl \ python3 \ python3-pip \ python3-venv \ rsync \ telegraf \ vault \ wget \ yq # Install InfluxDB 3 Core RUN curl -O https://www.influxdata.com/d/install_influxdb3.sh \ && chmod +x install_influxdb3.sh \ && bash -c yes | ./install_influxdb3.sh RUN ln -s /usr/bin/python3 /usr/bin/python # Create a virtual environment for Python to avoid conflicts with the system Python and having to use the --break-system-packages flag when installing packages with pip. RUN python -m venv /opt/venv # Enable venv ENV PATH="/opt/venv/bin:$PATH" # Prevents Python from writing pyc files. ENV PYTHONDONTWRITEBYTECODE=1 # the application crashes without emitting any logs due to buffering. ENV PYTHONUNBUFFERED=1 WORKDIR /app RUN mkdir -p /app/log && chmod +w /app/log RUN mkdir -p /app/assets && chmod +w /app/assets RUN mkdir -p /root/influxdb/templates && chmod +rw /root/influxdb/templates # Some Python test dependencies (pytest-dotenv and pytest-codeblocks) aren't # available as packages in apt-cache, so use pip to download dependencies in a # separate step and use Docker's caching. # Pytest configuration file. COPY ./test/pytest/pytest.ini pytest.ini # Python and Pytest dependencies. COPY ./test/pytest/requirements.txt requirements.txt # Pytest fixtures. COPY ./test/pytest/conftest.py conftest.py RUN pip install -Ur requirements.txt # Activate the Python virtual environment configured in the Dockerfile. RUN . /opt/venv/bin/activate ARG CONTENT_PATH ENV CONTENT_PATH="${CONTENT_PATH}" # Create a mock xdg-open script` to prevent the test suite from attempting to open a browser (for example, during influxctl OAuth2 authentication). RUN echo '#!/bin/bash' > /usr/local/bin/xdg-open \ && echo 'echo "$1" > /shared/urls.txt' >> /usr/local/bin/xdg-open \ && chmod +x /usr/local/bin/xdg-open RUN service influxdb start RUN vault server -dev > ~/.vault-server-log 2>&1 & # Copy test scripts and make them executable. COPY --chmod=755 ./test/scripts/parse_yaml.sh /usr/local/bin/parse_yaml COPY --chmod=755 ./test/scripts/get-container-info.sh /usr/local/bin/get-container-info ENTRYPOINT [ "pytest" ] # Specify command arguments: # --env-file to pass environment variables to the test suite. # the test directory to run the test suite. CMD [ "--codeblocks", "" ]