diff --git a/.dockerignore b/.dockerignore index 6b8710a..f4b1198 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ .git +.github diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 0000000..bddc5dd --- /dev/null +++ b/.github/workflows/cicd.yml @@ -0,0 +1,11 @@ +on: [push, workflow_dispatch] +jobs: + cicd: + # https://github.com/internetarchive/cicd + uses: internetarchive/cicd/.github/workflows/cicd.yml@main + with: + NOMAD_VAR_HOSTNAMES: '["nomad","nomad.archive.org"]' + NOMAD_VAR_MEMORY: 100 # xxx + NOMAD_VAR_CHECK_PROTOCOL: 'tcp' + secrets: + NOMAD_TOKEN_EXT: ${{ secrets.NOMAD_TOKEN_EXT }} diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..7eee3fb --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,50 @@ +# https://docs.github.com/en/actions/using-workflows/reusing-workflows + +name: copy repo & deploy to GitHub Pages + +on: + workflow_call: + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: true + fetch-depth: 0 + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./ + + # Deploy to GitHub Pages + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..9b33306 --- /dev/null +++ b/Caddyfile @@ -0,0 +1,9 @@ +{ + admin off +} + +:5000 { + # We answer all requests this CI/CD yaml file from this repo + file_server + rewrite * /gitlab.yml +} diff --git a/Dockerfile b/Dockerfile index c527829..9bf0f5d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,14 +8,15 @@ RUN mkdir -m777 /usr/local/sbin && \ rm nomad.zip && \ chmod 777 nomad && \ # podman for build.sh - apk add bash zsh jq podman && \ + apk add bash zsh jq podman caddy && \ # using podman not docker ln -s /usr/bin/podman /usr/bin/docker +WORKDIR /app +COPY gitlab.yml Caddyfile ./ + COPY build.sh deploy.sh / -# revisit this: -# USER deno +USER deno -# NOTE: `nomad` binary needed for other repositories using us for CI/CD - but drop from _our_ webapp. -CMD rm /usr/local/sbin/nomad /usr/bin/podman && su deno -c 'deno eval "import { serve } from \"https://deno.land/std/http/server.ts\"; serve(() => new Response(\"hai\"), { port: 5000 })"' +CMD ["/usr/sbin/caddy", "run"] diff --git a/README.md b/README.md index 1cb9f70..2e2ee5e 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,14 @@ Uses: - simply make your project have this simple `.gitlab-ci.yml` in top-level dir: ```yaml include: - - remote: 'https://gitlab.com/internetarchive/nomad/-/raw/master/.gitlab-ci.yml' + - remote: 'https://nomad.archive.org' ``` +*OR* +```yaml +include: + - remote: 'https://raw.githubusercontent.com/internetarchive/nomad/refs/heads/main/gitlab.yml' +``` + - if you want a [test] phase, you can add this to the `.gitlab-ci.yml` file above: ```yaml test: diff --git a/build.yml b/build.yml deleted file mode 100644 index 66e2624..0000000 --- a/build.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Tracey 3/2024: -# This was adapted & simplified from: -# https://gitlab.com/gitlab-org/gitlab/-/raw/master/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml - -build: - stage: build - # If need to rebuild this image while runners are down, `cd` to this directory, then, as root: - # podman login registry.gitlab.com - # podman build --net=host --tag registry.gitlab.com/internetarchive/nomad/master . && sudo podman push registry.gitlab.com/internetarchive/nomad/master - image: registry.gitlab.com/internetarchive/nomad/master - variables: - DOCKER_HOST: 'unix:///run/podman/podman.sock' - DOCKER_TLS_CERTDIR: '' - DOCKER_BUILDKIT: 1 - script: - - /build.sh - artifacts: - reports: - dotenv: gl-auto-build-variables.env - rules: - - if: '$BUILD_DISABLED' - when: never - - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' diff --git a/.gitlab-ci.yml b/gitlab.yml similarity index 77% rename from .gitlab-ci.yml rename to gitlab.yml index 7545c46..c2ace58 100644 --- a/.gitlab-ci.yml +++ b/gitlab.yml @@ -17,10 +17,28 @@ stages: - deploy - cleanup - -include: - # GitLab Auto DevOps' stock CI/CD [build] phase: - - remote: 'https://gitlab.com/internetarchive/nomad/-/raw/master/build.yml' +build: + # Tracey 3/2024: + # This was adapted & simplified from: + # https://gitlab.com/gitlab-org/gitlab/-/raw/master/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml + stage: build + # If need to rebuild this image while runners are down, `cd` to this directory, then, as root: + # podman login registry.gitlab.com + # podman build --net=host --tag registry.gitlab.com/internetarchive/nomad/master . && sudo podman push registry.gitlab.com/internetarchive/nomad/master + image: registry.gitlab.com/internetarchive/nomad/master + variables: + DOCKER_HOST: 'unix:///run/podman/podman.sock' + DOCKER_TLS_CERTDIR: '' + DOCKER_BUILDKIT: 1 + script: + - /build.sh + artifacts: + reports: + dotenv: gl-auto-build-variables.env + rules: + - if: '$BUILD_DISABLED' + when: never + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' test-ourself: stage: test