diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index e78fb68f6..000000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -FROM quay.io/redhat-pipeline-service/devenv:main diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index 027662f3c..000000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "build": { - "dockerfile": "Dockerfile" - }, - "extensions": [ - "ms-kubernetes-tools.vscode-kubernetes-tools", - "redhat.vscode-yaml", - "timonwong.shellcheck" - ], - "runArgs": [ - "--privileged", - "--volume=${localWorkspaceFolder}:/workspace:Z" - ], - "settings": { - "editor.codeActionsOnSave": { - "source.organizeImports": true - }, - "editor.formatOnSave": true, - }, - "workspaceFolder": "/workspace", - "workspaceMount": "" -} \ No newline at end of file diff --git a/developer/hack/build-images-buildah.sh b/developer/hack/build-images-buildah.sh index 17e686b6c..71f4dc136 100755 --- a/developer/hack/build-images-buildah.sh +++ b/developer/hack/build-images-buildah.sh @@ -18,7 +18,6 @@ parse_args() { mapfile -t DEFAULT_IMAGE_DIRS < <( find "$PROJECT_DIR" -type f -name Dockerfile -exec dirname {} \; | sed "s:$PROJECT_DIR/::" | - grep --invert-match --extended-regexp "/developer/exploration/|.devcontainer" | sort ) IMAGE_DIRS=() diff --git a/developer/images/devenv/Dockerfile b/developer/images/devenv/Dockerfile deleted file mode 100644 index 1a0c1073b..000000000 --- a/developer/images/devenv/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM quay.io/podman/stable:v4.7 -RUN set -x \ - && mkdir ~/.kube \ - && mkdir -p /tmp/image-build \ - && dnf install -y \ - # gcc is needed when installing checkov's dependencies - gcc-c++-13.2.1 \ - git-2.43.2 \ - openssl-3.1.1 \ - procps-ng-4.0.3 \ - # python3-devl is needed when installing checkov's dependencies - python3-devel-3.12.0 \ - rsync-3.2.7 \ - unzip-6.0 \ - which-2.21 \ - xz-5.4.4 \ - && dnf clean all \ - && sed -i -e "s:podman:root:" /etc/subuid /etc/subgid -COPY shared /tmp/image-build/shared -RUN /tmp/image-build/shared/hack/install.sh --debug --bin argocd,bitwarden,checkov,hadolint,jq,kubectl,oc,shellcheck,tkn,yamllint,yq \ - && rm -rf /tmp/image-build -WORKDIR "/workspace" diff --git a/developer/images/devenv/README.md b/developer/images/devenv/README.md deleted file mode 100644 index 1ab9535ef..000000000 --- a/developer/images/devenv/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Development Environment in a Container - -This folder holds the configuration to build and run an image embedding all the required -dependencies to work on the project. - -## Using the image -You can start a container with `./run.sh`, by default it will use the latest image available on `quay.io`. -If you want to build a local image (e.g. after changing dependencies locally), you can use the `--dev` flag. - -When exiting the container, it will be stopped. Running `./run.sh` will restart the container. -This allow users to preserve any customization they might have done. - -## Managing containers -One container will be spawned per repository clone, and you'll see that the container name is based on the clone path. - -## Integration with IDEs -This image is used as the base image by the IDE integration (e.g. `.devcontainer` for VS Code). diff --git a/developer/images/devenv/run.sh b/developer/images/devenv/run.sh deleted file mode 100755 index 9ed1edbcf..000000000 --- a/developer/images/devenv/run.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2022 The pipelines-service Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -o errexit -set -o nounset -set -o pipefail - -usage() { - echo " -Usage: - ${0##*/} [options] - -Run a container with the development environment. - -Optional arguments: - --dev - Build and run a local image - -f, --force - Force the creation of a new container - -d, --debug - Activate tracing/debug mode. - -h, --help - Display this message. - -Example: - ${0##*/} -" >&2 -} - -init() { - SCRIPT_DIR=$( - cd "$(dirname "$0")" >/dev/null - pwd - ) - PROJECT_DIR=$( - cd "$SCRIPT_DIR" >/dev/null - git rev-parse --show-toplevel - ) - DEV_MODE="0" - IMAGE_NAME="quay.io/redhat-pipeline-service/devenv:main" - LOCAL_IMAGE_NAME="$IMAGE_NAME" - CONTAINER_NAME=$(pwd | sed -e 's:/:__:g' -e 's:[^a-zA-Z0-9_-]:-:g' | cut -c3-) - - detect_container_engine -} - -parse_args() { - while [[ $# -gt 0 ]]; do - case $1 in - --dev) - DEV_MODE="1" - ;; - -f | --force) - $CONTAINER_ENGINE rm -f "$CONTAINER_NAME" &>/dev/null || true - ;; - -d | --debug) - set -x - ;; - -h | --help) - usage - exit 0 - ;; - *) - echo "Unknown argument: $1" - usage - exit 1 - ;; - esac - shift - done -} - -detect_container_engine() { - CONTAINER_ENGINE="${CONTAINER_ENGINE:-}" - if [[ -n "${CONTAINER_ENGINE}" ]]; then - return - fi - - # Check if docker should be used - if ! command -v podman >/dev/null; then - CONTAINER_ENGINE="docker" - return - fi - if [[ "$OSTYPE" == "darwin"* && -z "$(podman ps)" ]]; then - # Podman machine is not started - CONTAINER_ENGINE="docker" - return - fi - if [[ "$OSTYPE" == "darwin"* && -z "$(podman system connection ls --format=json)" ]]; then - CONTAINER_ENGINE="docker" - return - fi - - # Default container engine is podman - CONTAINER_ENGINE="podman" -} - -get_image_name() { - DEPENDENCIES_SHA=$( - cat "$SCRIPT_DIR/Dockerfile" "$PROJECT_DIR/shared/hack/install.sh" "$PROJECT_DIR/shared/config/dependencies.sh" | - sha256sum | cut -c1-8 - ) - IMAGE_NAME="pipeline-service/devenv:$DEPENDENCIES_SHA" - LOCAL_IMAGE_NAME="localhost/$IMAGE_NAME" -} - -build_image() { - if [ "$("${CONTAINER_ENGINE[@]}" images --filter "reference=$LOCAL_IMAGE_NAME" --noheading | wc -l)" = "0" ]; then - echo "[Building container]" - $CONTAINER_ENGINE build -f "$SCRIPT_DIR/Dockerfile" --label "name=$IMAGE_NAME" -t "$IMAGE_NAME" "$PROJECT_DIR" - fi -} - -start_container() { - if ! $CONTAINER_ENGINE ps --filter "name=$CONTAINER_NAME" | grep -q "$IMAGE_NAME"; then - if ! $CONTAINER_ENGINE ps -a --filter "name=$CONTAINER_NAME" | grep -q "$IMAGE_NAME"; then - echo "[Starting container]" - $CONTAINER_ENGINE rm -f "$CONTAINER_NAME" >/dev/null 2>&1 || true - if [ "$DEV_MODE" = "0" ]; then - CONTAINER_ENGINE_OPTS=("--pull" "always") - fi - $CONTAINER_ENGINE run \ - --detach \ - --entrypoint '["bash", "-c", "sleep infinity"]' \ - --name "$CONTAINER_NAME" \ - --privileged \ - --volume "$PROJECT_DIR:/workspace" \ - "${CONTAINER_ENGINE_OPTS[@]}" \ - "$LOCAL_IMAGE_NAME" >/dev/null 2>&1 - else - echo "[Restarting container]" - $CONTAINER_ENGINE start "$CONTAINER_NAME" >/dev/null 2>&1 - fi - fi -} - -open_shell() { - echo "[Opening shell in container]" - $CONTAINER_ENGINE exec -it "$CONTAINER_NAME" /bin/bash -} - -stop_container() { - # Stop container when the last shell exits - if ! $CONTAINER_ENGINE exec "$CONTAINER_NAME" /bin/sh -c "ps -ef | grep ' /bin/bash$'"; then - echo "[Stopping container]" - $CONTAINER_ENGINE stop "$CONTAINER_NAME" >/dev/null - fi -} - -main() { - init - parse_args "$@" - if [ "$DEV_MODE" != "0" ]; then - get_image_name - build_image - fi - start_container - open_shell - stop_container -} - -if [ "${BASH_SOURCE[0]}" == "$0" ]; then - main "$@" -fi