From b77b0ba66c648380bc772830da0716bbcf3b9200 Mon Sep 17 00:00:00 2001 From: Sven Marnach Date: Fri, 13 Mar 2026 16:44:07 +0100 Subject: [PATCH] CRINGE-225: Remove obs-common Docker containers. --- .devcontainer/Dockerfile | 31 ---------------------------- .devcontainer/devcontainer.json | 28 ------------------------- .dockerignore | 15 -------------- .github/dependabot.yml | 1 - .github/workflows/build.yaml | 23 ++++++++------------- bin/test.sh | 9 +++++++++ docker-compose.yml | 36 --------------------------------- docker/Dockerfile | 33 ------------------------------ docker/config/local_dev.env | 8 -------- justfile | 22 +++++++++----------- pyproject.toml | 3 +-- 11 files changed, 27 insertions(+), 182 deletions(-) delete mode 100644 .devcontainer/Dockerfile delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .dockerignore delete mode 100644 docker/Dockerfile delete mode 100644 docker/config/local_dev.env diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 9abe625..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -# This should be kept in sync with the python version used in docker/Dockerfile and -# docker/images/fakesentry/Dockerfile -FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/python:3.11-bookworm@sha256:138c451b17c1c5930f77e71a6510a0bae1d7b77feff5e0a714a22fa3d757a51f - -ARG userid=10001 -ARG groupid=10001 - -WORKDIR /app - -# add a non-privileged user for installing and running the application -# We use --non-unique in case $groupid/$userid collide with the existing "vscode" user. -RUN groupadd --gid $groupid --non-unique app && \ - useradd -g app --uid $userid --non-unique --shell /bin/bash --create-home app && \ - chown app:app /app/ - -# Install Debian packages -RUN apt-get update && \ - apt-get install -y ripgrep tig - -# Install uv -COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ - -USER app - -COPY --chown=app:app . /app - -# Install Python dependencies -RUN --mount=type=cache,uid=$userid,gid=$groupid,target=/home/app/.cache/uv \ - --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ - uv sync -ENV PATH="/app/.venv/bin:$PATH" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index 4e423d0..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "Obs Common", - "dockerComposeFile": [ - "../docker-compose.yml" - ], - "service": "devcontainer", - "runServices": [ - "devcontainer" - ], - "shutdownAction": "none", - "workspaceFolder": "/app", - "customizations": { - "vscode": { - "settings": { - "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true, - "[python]": { - "editor.defaultFormatter": "charliermarsh.ruff" - } - }, - "extensions": [ - "charliermarsh.ruff" - ] - } - }, - "remoteUser": "app", - "updateRemoteUserUID": false -} diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 45650d6..0000000 --- a/.dockerignore +++ /dev/null @@ -1,15 +0,0 @@ -*.py[co] -*.sw[po] -.DS_Store -.env -.git/ -.pytest_cache -.python-version -.venv/ -build/ -dist/ -obs_common.egg-info/ -uv.lock - -# Ignore generated credentials from google-github-actions/auth -gha-creds-*.json diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7637749..e3353cf 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -12,7 +12,6 @@ updates: - package-ecosystem: "docker" directories: - - "/docker" - "/docker/images/*" schedule: interval: "monthly" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 98f8f55..ed92c9c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -23,23 +23,17 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install dependencies - run: | - uv sync + run: uv sync + - name: Install just + run: sudo apt-get update && sudo apt-get install -y just - name: Run lint check if: ${{ matrix.python-version == '3.11' }} - run: | - uv run bin/lint.sh + run: just lint - name: Run tests - env: - SENTRY_DSN: http://public@localhost:8090/1 - STORAGE_EMULATOR_HOST: http://localhost:8001 - PUBSUB_EMULATOR_HOST: localhost:5010 run: | - docker compose up -d fakesentry gcs-emulator pubsub - # Run outside docker because we are testing the matrix python version - uv run bin/test.sh + just test # stop services immediate and ignore errors - docker compose down -t0 || true + just down -t0 || true build-and-release: permissions: @@ -59,8 +53,7 @@ jobs: with: python-version: 3.11 - name: Install dependencies - run: | - uv sync + run: uv sync - name: Generate release tag run: echo RELEASE_TAG="$(uv run python -c 'import obs_common.release; print(obs_common.release.generate_tag())')" >> "$GITHUB_ENV" - name: Overrride wheel version @@ -78,7 +71,7 @@ jobs: run: uv build --wheel - name: Build docker images for publishing run: | - docker compose build fakesentry gcs-emulator + just build fakesentry gcs-emulator GAR_REPO="us-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/cavendish-prod" FAKESENTRY_TAG="$GAR_REPO/fakesentry:${{ env.RELEASE_TAG }}" docker tag local/obs-common-fakesentry:latest "$FAKESENTRY_TAG" diff --git a/bin/test.sh b/bin/test.sh index dcd8955..11cc224 100755 --- a/bin/test.sh +++ b/bin/test.sh @@ -16,6 +16,15 @@ set -euo pipefail +# Set Pub/Sub library to use emulator +export PUBSUB_EMULATOR_HOST="localhost:${EXPOSE_PUBSUB_EMULATOR_PORT:-5010}" + +# Set GCS library to use emulator +export STORAGE_EMULATOR_HOST="http://localhost:${EXPOSE_GCS_EMULATOR_PORT:-8001}" + +# Set up fakesentry +export SENTRY_DSN="http://public@localhost:${EXPOSE_SENTRY_PORT:-8090}/1" + # Wait for services to be ready (both have the same endpoint url) echo ">>> wait for services" waitfor --verbose "http://${PUBSUB_EMULATOR_HOST}" diff --git a/docker-compose.yml b/docker-compose.yml index 5860864..f41cde7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,40 +1,4 @@ services: - shell: - build: - context: . - dockerfile: docker/Dockerfile - args: - userid: ${USE_UID:-10001} - groupid: ${USE_GID:-10001} - image: local/obs-common-shell - env_file: - - docker/config/local_dev.env - links: - - fakesentry - - gcs-emulator - - pubsub - volumes: - - .:/app - - /app/.venv - - devcontainer: - build: - dockerfile: .devcontainer/Dockerfile - args: - userid: ${USE_UID:-10001} - groupid: ${USE_GID:-10001} - image: local/obs-common-devcontainer - entrypoint: ["sleep", "inf"] - env_file: - - docker/config/local_dev.env - links: - - fakesentry - - gcs-emulator - - pubsub - volumes: - - .:/app - - /app/.venv - # https://github.com/willkg/kent fakesentry: build: diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 311573b..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -# This should be kept in sync with the python version used in .devcontainer/Dockerfile and -# docker/images/fakesentry/Dockerfile -FROM --platform=linux/amd64 ghcr.io/astral-sh/uv:python3.11-bookworm-slim@sha256:4f5d923c9dcea037f57bda425dd209f3ec643da2f0b74227f68d09dab0b3bb36 - -# Set up user and group -ARG groupid=10001 -ARG userid=10001 - -WORKDIR /app/ -RUN groupadd --gid $groupid app && \ - useradd -g app --uid $userid --shell /usr/sbin/nologin --create-home app && \ - chown app:app /app/ - -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - git \ - ripgrep \ - tig && \ - apt-get autoremove -y && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -USER app - -COPY --chown=app:app . /app - -# Install Python dependencies -RUN --mount=type=cache,uid=$userid,gid=$groupid,target=/home/app/.cache/uv \ - --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ - uv sync -ENV PATH="/app/.venv/bin:$PATH" - -CMD ["/bin/bash"] diff --git a/docker/config/local_dev.env b/docker/config/local_dev.env deleted file mode 100644 index 4907f85..0000000 --- a/docker/config/local_dev.env +++ /dev/null @@ -1,8 +0,0 @@ -# Set Pub/Sub library to use emulator -PUBSUB_EMULATOR_HOST=pubsub:5010 - -# Set GCS library to use emulator -STORAGE_EMULATOR_HOST=http://gcs-emulator:8001 - -# Set up fakesentry -SENTRY_DSN=http://public@fakesentry:8090/1 diff --git a/justfile b/justfile index eb78c2a..5d082e7 100644 --- a/justfile +++ b/justfile @@ -9,22 +9,18 @@ _default: build *args: docker compose --progress plain build {{args}} -# Open a shell in docker. -shell *args: - docker compose run --rm shell {{args}} +# Start Docker containers. +up *args='--detach': + docker compose up {{args}} -# Run VS Code development container. -devcontainer: - docker compose up --detach devcontainer - -# Run uv inside the container -uv *args: - docker compose run --rm --no-deps shell uv {{args}} +# Stop and remove Docker containers. +down *args: + docker compose down {{args}} # Lint code, or use --fix to reformat and apply auto-fixes for lint. lint *args: - docker compose run --rm --no-deps shell bin/lint.sh {{args}} + uv run bin/lint.sh {{args}} # Run tests. -test *args: - docker compose run --rm shell bin/test.sh {{args}} +test *args: up + uv run bin/test.sh {{args}} diff --git a/pyproject.toml b/pyproject.toml index ee78682..c3362d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,10 +21,9 @@ dependencies = [ [dependency-groups] dev = [ - "ipython", "pytest", "requests", - "ruff" + "ruff", ] [project.scripts]