From 41823b29eb3398ac9340014cea8d77a57c6e0534 Mon Sep 17 00:00:00 2001 From: John Ajera <37360952+jajera@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:43:34 +0000 Subject: [PATCH] feat: add test image in the build-and-release workflow builds and release a test image --- .github/workflows/build-and-release.yml | 15 +++- .gitignore | 2 - .vscode/extensions.json | 20 ++++++ .vscode/settings.json | 93 +++++++++++++++++++++++++ Dockerfile.test | 41 +++++++++++ 5 files changed, 167 insertions(+), 4 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 Dockerfile.test diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 04da5a4..ef40ab2 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -18,6 +18,16 @@ jobs: permissions: contents: write packages: write + strategy: + matrix: + image_type: [base, test] + include: + - image_type: base + dockerfile: Dockerfile + image_suffix: "" + - image_type: test + dockerfile: Dockerfile.test + image_suffix: "-test" steps: - name: Checkout code @@ -37,7 +47,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}${{ matrix.image_suffix }} tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} @@ -49,6 +59,7 @@ jobs: uses: docker/build-push-action@v6 with: context: . + file: ${{ matrix.dockerfile }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -56,7 +67,7 @@ jobs: cache-to: type=gha,mode=max - name: Create Release - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/') && matrix.image_type == 'base' uses: softprops/action-gh-release@v2 with: files: "" diff --git a/.gitignore b/.gitignore index 6ae02aa..2b21ef6 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,6 @@ env/ ENV/ # IDE -.vscode/ .idea/ *.swp *.swo @@ -41,4 +40,3 @@ Thumbs.db # MkDocs site/ - diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..6336ed3 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,20 @@ +{ + "recommendations": [ + "amazonwebservices.aws-toolkit-vscode", + "davidanson.vscode-markdownlint", + "eamodio.gitlens", + "esbenp.prettier-vscode", + "foxundermoon.shell-format", + "Gruntfuggly.todo-tree", + "hashicorp.terraform", + "mhutchie.git-graph", + "ms-vscode-remote.remote-ssh-edit", + "ms-vscode-remote.remote-ssh", + "ms-vscode.remote-containers", + "ms-vscode.vscode-json", + "redhat.vscode-yaml", + "streetsidesoftware.code-spell-checker", + "usernamehw.errorlens", + "vscode-icons-team.vscode-icons" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..beeafba --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,93 @@ +{ + "files.associations": { + "*.tf": "terraform", + "*.tfvars": "terraform", + "*.tfstate": "json", + "*.tfstate.backup": "json", + "*.hcl": "terraform", + "*.nomad": "hcl", + "*.consul": "hcl", + "*.vault": "hcl", + "*.dockerfile": "dockerfile", + "*.sh.tpl": "shellscript", + "docker-compose*.yml": "yaml", + "Dockerfile*": "dockerfile" + }, + "files.exclude": { + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/CVS": true, + "**/.DS_Store": true, + "**/.terraform": true, + "**/.terraform.lock.hcl": true, + "**/terraform.tfstate*": true, + "**/.terraform.tfstate.lock.info": true, + "__debug_bin": true, + "vendor/": true, + "go.sum": true + }, + "files.trimTrailingWhitespace": true, + "files.trimFinalNewlines": true, + "files.insertFinalNewline": true, + "files.autoSave": "onFocusChange", + "search.exclude": { + "**/.terraform": true, + "**/terraform.tfstate*": true, + "**/.terraform.tfstate.lock.info": true + }, + "editor.formatOnSave": true, + "editor.formatOnPaste": true, + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit" + }, + "editor.rulers": [80, 120], + "editor.wordWrap": "wordWrapColumn", + "editor.wordWrapColumn": 120, + "editor.tabSize": 2, + "editor.insertSpaces": true, + "editor.detectIndentation": false, + "workbench.iconTheme": "vscode-icons", + "workbench.colorTheme": "Default Dark+", + "terraform.codelens.referenceCount": true, + "[terraform]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "hashicorp.terraform", + "editor.tabSize": 2, + "editor.insertSpaces": true, + "editor.detectIndentation": false, + "editor.rulers": [80, 120], + "editor.wordWrap": "wordWrapColumn", + "editor.wordWrapColumn": 120 + }, + "[hcl]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "hashicorp.terraform", + "editor.tabSize": 2, + "editor.insertSpaces": true, + "editor.detectIndentation": false + }, + "[json]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.tabSize": 2, + "editor.insertSpaces": true + }, + "[yaml]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "redhat.vscode-yaml", + "editor.tabSize": 2, + "editor.insertSpaces": true + }, + "[shellscript]": { + "editor.defaultFormatter": "foxundermoon.shell-format", + "editor.tabSize": 2, + "editor.insertSpaces": true + }, + "[markdown]": { + "editor.defaultFormatter": "davidanson.vscode-markdownlint", + "editor.tabSize": 2, + "editor.insertSpaces": true, + "editor.wordWrap": "on" + } +} diff --git a/Dockerfile.test b/Dockerfile.test new file mode 100644 index 0000000..6ae003a --- /dev/null +++ b/Dockerfile.test @@ -0,0 +1,41 @@ +# Stage 0: Build the base image locally +FROM python:3.13-slim AS base-builder + +WORKDIR /tmp + +# Install mkdocs and mkdocs-material +COPY requirements.txt /tmp/requirements.txt +RUN pip install --no-cache-dir -r /tmp/requirements.txt + +# Stage 1: Build the documentation using the base image +FROM base-builder AS builder + +WORKDIR /docs + +# Copy the test documentation +COPY test/ /docs/ + +# Build the static site +RUN mkdocs build + +# Stage 2: Serve the static site with nginx +FROM nginx:alpine + +# Install wget for health check +RUN apk add --no-cache wget + +# Copy the built site from builder stage +COPY --from=builder /docs/site /usr/share/nginx/html + +# Create health check endpoint +RUN echo '{"status":"healthy"}' > /usr/share/nginx/html/health + +# Configure nginx to listen on port 8000 +RUN sed -i 's/listen 80;/listen 8000;/' /etc/nginx/conf.d/default.conf + +# Expose port 8000 (same as base image) +EXPOSE 8000 + +# Health check +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:8000/health || exit 1