neiam
/vigil
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
Log in to mark this repository.
Slice 11: packaging and operations plumbing
f960521 · gmorell · 2026-12-02 03:49
Message
{commit_body(@commit)}
Files changed
added
.dockerignore
+36
−0
| 1 | +# Build / dep artifacts — regenerated inside the container. | |
| 2 | +_build/ | |
| 3 | +deps/ | |
| 4 | +# Rust build output and locally built NIFs: Rustler rebuilds them in the | |
| 5 | +# builder with its pinned toolchain. | |
| 6 | +native/*/target/ | |
| 7 | +priv/native/ | |
| 8 | +priv/static/assets/ | |
| 9 | +priv/static/cache_manifest.json | |
| 10 | + | |
| 11 | +# Local uploads (Vigil.Storage.Local's default root). | |
| 12 | +storage/ | |
| 13 | + | |
| 14 | +# Local-only files. | |
| 15 | +.elixir_ls/ | |
| 16 | +.claude/ | |
| 17 | +.idea/ | |
| 18 | +*.iml | |
| 19 | +.envrc | |
| 20 | +.env | |
| 21 | +.env.* | |
| 22 | +erl_crash.dump | |
| 23 | + | |
| 24 | +# Editor / OS noise. | |
| 25 | +.DS_Store | |
| 26 | +*.swp | |
| 27 | +*.swo | |
| 28 | + | |
| 29 | +# Tests / fixtures aren't needed for the prod release. | |
| 30 | +test/ | |
| 31 | +cover/ | |
| 32 | + | |
| 33 | +# VCS metadata and CI aren't needed in the image. | |
| 34 | +.git/ | |
| 35 | +.gitignore | |
| 36 | +.forgejo/ |
added
.forgejo/workflows/audit.yml
+95
−0
| 1 | +name: audit | |
| 2 | +# Known vulnerabilities in what Vigil is built from: every lockfile in | |
| 3 | +# the repository (mix.lock and the NIF crates' native/*/Cargo.lock) | |
| 4 | +# checked against the OSV database (https://osv.dev), which carries the | |
| 5 | +# Hex advisories and RustSec's (what `cargo audit` reads) both, so one | |
| 6 | +# scanner covers both ecosystems, as the sibling apps do (cartosnap, | |
| 7 | +# gitgud). scripts/osv-audit sorts what it finds: a finding with a fixed | |
| 8 | +# version fails the run; one with no fix yet makes the job a warning (its | |
| 9 | +# `gitgud-conclusion` output), since there's nothing to do but wait. | |
| 10 | +# Nightly, since advisories land without anyone pushing, and by hand | |
| 11 | +# from the Actions page. | |
| 12 | +# | |
| 13 | +# On a pull request it compares the lockfiles the pull request changes | |
| 14 | +# with the same files on the base branch: it fails only on a | |
| 15 | +# vulnerability the pull request brings in, and says what it fixed and | |
| 16 | +# what's still there (scripts/osv-diff). | |
| 17 | +on: | |
| 18 | + schedule: | |
| 19 | + - cron: "29 6 * * *" | |
| 20 | + workflow_dispatch: | |
| 21 | + pull_request: | |
| 22 | + | |
| 23 | +permissions: | |
| 24 | + contents: read | |
| 25 | + | |
| 26 | +# A newer push supersedes this run: on a branch or PR the run in | |
| 27 | +# progress is cancelled; on main it finishes, and only a run still | |
| 28 | +# waiting is replaced. | |
| 29 | +concurrency: | |
| 30 | + group: ${{ github.workflow }}-${{ github.ref }} | |
| 31 | + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
| 32 | + | |
| 33 | +jobs: | |
| 34 | + osv: | |
| 35 | + runs-on: self-hosted | |
| 36 | + # `warning` when only unfixable findings remain (scripts/osv-audit). | |
| 37 | + # GitHub and Forgejo read it as an ordinary output. | |
| 38 | + outputs: | |
| 39 | + gitgud-conclusion: ${{ steps.scan.outputs.conclusion }} | |
| 40 | + # "2 to fix, 1 no fix": what the workflow's badge says, rather | |
| 41 | + # than just "warning". | |
| 42 | + gitgud-summary: ${{ steps.scan.outputs.summary }} | |
| 43 | + steps: | |
| 44 | + - uses: actions/checkout@v4 | |
| 45 | + with: | |
| 46 | + fetch-depth: 0 | |
| 47 | + | |
| 48 | + # Pinned, and checked against the release's published checksum | |
| 49 | + # before it runs: a scanner is a strange thing to take on trust. | |
| 50 | + # To move it on, change both together, from | |
| 51 | + # https://github.com/google/osv-scanner/releases (…_SHA256SUMS). | |
| 52 | + - name: Fetch osv-scanner | |
| 53 | + env: | |
| 54 | + OSV_VERSION: v2.6.0 | |
| 55 | + OSV_SHA256: ca69b3d3cd08f889a49dc0a383122f71cc528b83803671df5fd874d97485b108 | |
| 56 | + run: | | |
| 57 | + curl -sSfL -o /tmp/osv-scanner \ | |
| 58 | + "https://github.com/google/osv-scanner/releases/download/${OSV_VERSION}/osv-scanner_linux_amd64" | |
| 59 | + echo "${OSV_SHA256} /tmp/osv-scanner" | sha256sum -c - | |
| 60 | + chmod +x /tmp/osv-scanner | |
| 61 | + | |
| 62 | + # Exit 1 when anything has a fixed version, so the run fails; the | |
| 63 | + # tables name each package, its version, its advisories, and the | |
| 64 | + # version that fixes it or that none does. | |
| 65 | + - name: Scan the lockfiles | |
| 66 | + id: scan | |
| 67 | + if: github.event_name != 'pull_request' | |
| 68 | + env: | |
| 69 | + OSV_SCANNER: /tmp/osv-scanner | |
| 70 | + run: python3 scripts/osv-audit --recursive . | |
| 71 | + | |
| 72 | + - name: Scan the lockfiles this pull request changes | |
| 73 | + if: github.event_name == 'pull_request' | |
| 74 | + env: | |
| 75 | + BASE: ${{ github.base_ref }} | |
| 76 | + run: | | |
| 77 | + git fetch --quiet origin "$BASE" | |
| 78 | + changed=$(git diff --name-only "origin/$BASE"...HEAD | grep -E '(^|/)(mix|Cargo)\.lock$' || true) | |
| 79 | + if [ -z "$changed" ]; then | |
| 80 | + echo "No lockfile changed." | |
| 81 | + exit 0 | |
| 82 | + fi | |
| 83 | + mkdir -p /tmp/base | |
| 84 | + for f in $changed; do | |
| 85 | + mkdir -p "/tmp/base/$(dirname "$f")" | |
| 86 | + git show "origin/$BASE:$f" > "/tmp/base/$f" 2>/dev/null || true | |
| 87 | + done | |
| 88 | + # 0 and 1 (found some) are both answers; with nothing to scan, none. | |
| 89 | + scan() { | |
| 90 | + if [ $# -eq 0 ]; then echo '{}'; return; fi | |
| 91 | + /tmp/osv-scanner scan source --format json $(printf -- '--lockfile %s ' "$@") || [ $? -eq 1 ] | |
| 92 | + } | |
| 93 | + (cd /tmp/base && scan $(for f in $changed; do [ -s "$f" ] && echo "$f"; done)) > /tmp/base.json | |
| 94 | + scan $changed > /tmp/head.json | |
| 95 | + python3 scripts/osv-diff /tmp/base.json /tmp/head.json |
added
.forgejo/workflows/checks.yml
+133
−0
| 1 | +name: checks | |
| 2 | +# A pull request's build and tests, as the sibling apps run them | |
| 3 | +# (cartosnap, gitgud): | |
| 4 | +# | |
| 5 | +# rust — rustfmt and clippy (-D warnings) over each NIF crate in native/ | |
| 6 | +# test — `mix precommit` (compile --warnings-as-errors, deps.unlock | |
| 7 | +# --unused, format, test) against a throwaway Postgres 17, the NIFs | |
| 8 | +# built from source by Rustler on the way, then a check that | |
| 9 | +# precommit changed nothing (an unformatted file or a stale lock | |
| 10 | +# entry fails the run rather than being fixed silently) | |
| 11 | +# | |
| 12 | +# The SDK conformance tests (test/vigil_web/sdk_*_test.exs) skip themselves | |
| 13 | +# here: they need reference SDK checkouts and binaries the runner doesn't | |
| 14 | +# have. Run them locally where those exist. | |
| 15 | +on: | |
| 16 | + push: | |
| 17 | + branches: [main] | |
| 18 | + pull_request: | |
| 19 | + workflow_dispatch: | |
| 20 | + | |
| 21 | +permissions: | |
| 22 | + contents: read | |
| 23 | + | |
| 24 | +# A newer push supersedes this run: on a branch or PR the run in | |
| 25 | +# progress is cancelled; on main it finishes, and only a run still | |
| 26 | +# waiting is replaced. | |
| 27 | +concurrency: | |
| 28 | + group: ${{ github.workflow }}-${{ github.ref }} | |
| 29 | + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
| 30 | + | |
| 31 | +jobs: | |
| 32 | + rust: | |
| 33 | + runs-on: self-hosted | |
| 34 | + steps: | |
| 35 | + - uses: actions/checkout@v4 | |
| 36 | + | |
| 37 | + - name: Build dependencies | |
| 38 | + run: | | |
| 39 | + sudo apt-get update -q | |
| 40 | + sudo apt-get install -y -q --no-install-recommends build-essential | |
| 41 | + | |
| 42 | + # The same toolchain as the Dockerfile (RUST_VERSION); move them together. | |
| 43 | + - name: Rust | |
| 44 | + run: | | |
| 45 | + curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.92.0 -c clippy -c rustfmt | |
| 46 | + echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" | |
| 47 | + | |
| 48 | + - name: rustfmt | |
| 49 | + run: | | |
| 50 | + set -eu | |
| 51 | + for crate in native/*/; do | |
| 52 | + echo "::group::$crate" | |
| 53 | + (cd "$crate" && cargo fmt --check) | |
| 54 | + echo "::endgroup::" | |
| 55 | + done | |
| 56 | + | |
| 57 | + - name: Clippy | |
| 58 | + run: | | |
| 59 | + set -eu | |
| 60 | + for crate in native/*/; do | |
| 61 | + echo "::group::$crate" | |
| 62 | + (cd "$crate" && cargo clippy --all-targets --locked -- -D warnings) | |
| 63 | + echo "::endgroup::" | |
| 64 | + done | |
| 65 | + | |
| 66 | + test: | |
| 67 | + runs-on: self-hosted | |
| 68 | + services: | |
| 69 | + # Plain Postgres, as compose.yml runs: Vigil needs no extensions. | |
| 70 | + postgres: | |
| 71 | + image: postgres:17 | |
| 72 | + env: | |
| 73 | + POSTGRES_USER: vigil | |
| 74 | + POSTGRES_PASSWORD: vigil | |
| 75 | + options: >- | |
| 76 | + --health-cmd "pg_isready -U vigil" | |
| 77 | + --health-interval 5s | |
| 78 | + --health-timeout 5s | |
| 79 | + --health-retries 20 | |
| 80 | + env: | |
| 81 | + MIX_ENV: test | |
| 82 | + VIGIL_TEST_DB_HOST: postgres | |
| 83 | + VIGIL_TEST_DB_PORT: "5432" | |
| 84 | + # Postgres takes 100 connections; the runner has cores for more. | |
| 85 | + VIGIL_TEST_DB_POOL_SIZE: "40" | |
| 86 | + steps: | |
| 87 | + - uses: actions/checkout@v4 | |
| 88 | + | |
| 89 | + # As the Dockerfile's builder: a C compiler for bcrypt's NIF (and the | |
| 90 | + # linker for the Rust ones), git for the heroicons and daisyui | |
| 91 | + # dependencies. | |
| 92 | + - name: Build dependencies | |
| 93 | + run: | | |
| 94 | + sudo apt-get update -q | |
| 95 | + sudo apt-get install -y -q --no-install-recommends build-essential git | |
| 96 | + | |
| 97 | + # The same toolchain the Dockerfile builds with. | |
| 98 | + # OTP and Elixir from builds.hex.pm, the builds setup-beam would | |
| 99 | + # fetch — taken directly, since setup-beam chooses one by ImageOS, | |
| 100 | + # which this runner sets to "selfhosted" over anything a workflow | |
| 101 | + # says. | |
| 102 | + - name: OTP and Elixir | |
| 103 | + env: | |
| 104 | + OTP_VERSION: "28.5.0.8" | |
| 105 | + ELIXIR_VERSION: "1.20.4" | |
| 106 | + run: | | |
| 107 | + ubuntu=$(. /etc/os-release && echo "$VERSION_ID") | |
| 108 | + curl -sSfL "https://builds.hex.pm/builds/otp/ubuntu-${ubuntu}/OTP-${OTP_VERSION}.tar.gz" | tar xz -C /tmp | |
| 109 | + # Installed where it's unpacked: Install's root is its own directory. | |
| 110 | + (cd "/tmp/OTP-${OTP_VERSION}" && ./Install -minimal "/tmp/OTP-${OTP_VERSION}" > /dev/null) | |
| 111 | + curl -sSfL -o /tmp/elixir.zip "https://builds.hex.pm/builds/elixir/v${ELIXIR_VERSION}-otp-${OTP_VERSION%%.*}.zip" | |
| 112 | + unzip -q -d /tmp/elixir /tmp/elixir.zip | |
| 113 | + echo "/tmp/OTP-${OTP_VERSION}/bin" >> "$GITHUB_PATH" | |
| 114 | + echo /tmp/elixir/bin >> "$GITHUB_PATH" | |
| 115 | + | |
| 116 | + # Rustler builds the NIFs from source during `mix compile`. | |
| 117 | + - name: Rust | |
| 118 | + run: | | |
| 119 | + curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.92.0 | |
| 120 | + echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" | |
| 121 | + | |
| 122 | + - name: Dependencies | |
| 123 | + run: | | |
| 124 | + mix local.hex --force | |
| 125 | + mix local.rebar --force | |
| 126 | + mix deps.get | |
| 127 | + | |
| 128 | + # The `test` alias inside it creates and migrates the database first. | |
| 129 | + - name: Precommit | |
| 130 | + run: mix precommit | |
| 131 | + | |
| 132 | + - name: Precommit left the tree as it was | |
| 133 | + run: git diff --exit-code |
added
.forgejo/workflows/image.yml
+75
−0
| 1 | +# Builds the release image (Dockerfile) and pushes it to the forge's own | |
| 2 | +# OCI registry on every push to main, as the sibling apps do: one image | |
| 3 | +# per push, which keel (or whatever deploys) polls for. | |
| 4 | +# | |
| 5 | +# The image lands at <registry>/<owner>/<repo>, tagged :main, :latest and | |
| 6 | +# the full commit sha. | |
| 7 | +# | |
| 8 | +# No secrets. The per-job token is accepted by the registry's /v2/token | |
| 9 | +# endpoint and authorized to push this repository's own image path. | |
| 10 | +name: image | |
| 11 | +on: | |
| 12 | + push: | |
| 13 | + branches: [main] | |
| 14 | + workflow_dispatch: | |
| 15 | + | |
| 16 | +# A newer push supersedes this run: on a branch the run in progress is | |
| 17 | +# cancelled; on main it finishes, and only a run still waiting is | |
| 18 | +# replaced. | |
| 19 | +concurrency: | |
| 20 | + group: ${{ github.workflow }}-${{ github.ref }} | |
| 21 | + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
| 22 | + | |
| 23 | +jobs: | |
| 24 | + image: | |
| 25 | + runs-on: self-hosted | |
| 26 | + steps: | |
| 27 | + - uses: actions/checkout@v4 | |
| 28 | + | |
| 29 | + - uses: docker/setup-buildx-action@v3 | |
| 30 | + | |
| 31 | + # An unset CI_REGISTRY resolves to the empty string, and | |
| 32 | + # login-action then silently defaults to docker.io while | |
| 33 | + # metadata-action builds a nonsense "/owner/repo" reference. Say | |
| 34 | + # what is missing instead. | |
| 35 | + - name: Check the registry variable is set | |
| 36 | + env: | |
| 37 | + CI_REGISTRY: ${{ vars.CI_REGISTRY }} | |
| 38 | + run: | | |
| 39 | + set -euo pipefail | |
| 40 | + if [ -z "${CI_REGISTRY:-}" ]; then | |
| 41 | + echo "CI_REGISTRY is not set for this repository." >&2 | |
| 42 | + echo "Set it as an organisation-level Actions variable (the" >&2 | |
| 43 | + echo "registry hostname), the same one the sibling apps build against." >&2 | |
| 44 | + exit 1 | |
| 45 | + fi | |
| 46 | + echo "pushing to $CI_REGISTRY" | |
| 47 | + | |
| 48 | + # The username is ignored by the token endpoint but login-action | |
| 49 | + # requires it to be non-empty. | |
| 50 | + - uses: docker/login-action@v3 | |
| 51 | + with: | |
| 52 | + registry: ${{ vars.CI_REGISTRY }} | |
| 53 | + username: ci | |
| 54 | + password: ${{ github.token }} | |
| 55 | + | |
| 56 | + # Push to the job's OWN repo path (<registry>/<owner>/<repo>); the | |
| 57 | + # per-job token only grants push there. | |
| 58 | + - uses: docker/metadata-action@v5 | |
| 59 | + id: meta | |
| 60 | + with: | |
| 61 | + images: ${{ vars.CI_REGISTRY }}/${{ github.repository }} | |
| 62 | + tags: | | |
| 63 | + type=sha,format=long | |
| 64 | + type=ref,event=branch | |
| 65 | + type=raw,value=latest,enable={{is_default_branch}} | |
| 66 | + | |
| 67 | + - uses: docker/build-push-action@v6 | |
| 68 | + with: | |
| 69 | + context: . | |
| 70 | + file: ./Dockerfile | |
| 71 | + push: true | |
| 72 | + tags: ${{ steps.meta.outputs.tags }} | |
| 73 | + labels: ${{ steps.meta.outputs.labels }} | |
| 74 | + cache-from: type=registry,ref=${{ vars.CI_REGISTRY }}/${{ github.repository }}:buildcache | |
| 75 | + cache-to: type=registry,ref=${{ vars.CI_REGISTRY }}/${{ github.repository }}:buildcache,mode=max |
added
Dockerfile
+131
−0
| 1 | +# Builder and runner follow the sibling apps (cartosnap, gitgud): Debian | |
| 2 | +# rather than Alpine, to avoid DNS resolution issues in production. | |
| 3 | +# | |
| 4 | +# - https://hub.docker.com/r/hexpm/elixir/tags | |
| 5 | +# - https://hub.docker.com/_/debian?tab=tags&page=1&name=trixie | |
| 6 | +# | |
| 7 | +# OTP must be >= 27.3: older public_key rejects the certificate chain | |
| 8 | +# builds.hex.pm serves, and `mix local.hex` dies at image build. The same | |
| 9 | +# versions are pinned in .forgejo/workflows/checks.yml; move them together. | |
| 10 | +ARG ELIXIR_VERSION=1.20.4 | |
| 11 | +ARG OTP_VERSION=28.5.0.8 | |
| 12 | +ARG DEBIAN_VERSION=trixie-20261020-slim | |
| 13 | + | |
| 14 | +ARG BUILDER_IMAGE="docker.io/hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}" | |
| 15 | +ARG RUNNER_IMAGE="docker.io/debian:${DEBIAN_VERSION}" | |
| 16 | + | |
| 17 | +FROM ${BUILDER_IMAGE} AS builder | |
| 18 | + | |
| 19 | +# Build tools only: | |
| 20 | +# * build-essential — bcrypt's C NIF, and the linker for the Rust NIFs | |
| 21 | +# * git — the heroicons and daisyui dependencies are git checkouts, and | |
| 22 | +# neiam_auth comes from the forge over HTTPS | |
| 23 | +# * curl, ca-certificates — to bootstrap rustup | |
| 24 | +# No npm: assets/ has no package.json, and tailwind and esbuild are | |
| 25 | +# installed through mix (`mix assets.setup`). | |
| 26 | +RUN apt-get update -y \ | |
| 27 | + && apt-get install -y --no-install-recommends build-essential git curl ca-certificates \ | |
| 28 | + && apt-get clean && rm -rf /var/lib/apt/lists/* | |
| 29 | + | |
| 30 | +# Rust via rustup, pinned, for the NIF crates in native/ (vigil_codec, | |
| 31 | +# vigil_ua, vigil_sourcemap), which Rustler builds from source during | |
| 32 | +# `mix compile`: nothing precompiled is downloaded. The crates' MSRV is | |
| 33 | +# 1.91; this is the toolchain gitgud builds with, and the one CI runs | |
| 34 | +# clippy and rustfmt with (.forgejo/workflows/checks.yml). The crates are | |
| 35 | +# pure Rust, so neither image needs a system library for them. | |
| 36 | +ENV RUSTUP_HOME=/usr/local/rustup \ | |
| 37 | + CARGO_HOME=/usr/local/cargo \ | |
| 38 | + PATH=/usr/local/cargo/bin:${PATH} \ | |
| 39 | + RUST_VERSION=1.92.0 | |
| 40 | +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ | |
| 41 | + | sh -s -- -y --profile minimal --default-toolchain ${RUST_VERSION} \ | |
| 42 | + && rustc --version && cargo --version | |
| 43 | + | |
| 44 | +WORKDIR /app | |
| 45 | + | |
| 46 | +RUN mix local.hex --force && \ | |
| 47 | + mix local.rebar --force | |
| 48 | + | |
| 49 | +ENV MIX_ENV="prod" | |
| 50 | + | |
| 51 | +COPY mix.exs mix.lock ./ | |
| 52 | +RUN mix deps.get --only $MIX_ENV | |
| 53 | +RUN mkdir config | |
| 54 | + | |
| 55 | +# Compile-time config first, so a config change recompiles the deps. | |
| 56 | +COPY config/config.exs config/${MIX_ENV}.exs config/ | |
| 57 | +RUN mix deps.compile | |
| 58 | + | |
| 59 | +RUN mix assets.setup | |
| 60 | + | |
| 61 | +COPY priv priv | |
| 62 | +COPY lib lib | |
| 63 | + | |
| 64 | +# The crates' sources (each with its committed Cargo.lock): Rustler runs | |
| 65 | +# cargo in them from `mix compile`. | |
| 66 | +COPY native native | |
| 67 | + | |
| 68 | +COPY assets assets | |
| 69 | + | |
| 70 | +# Compile before bundling so LiveView's colocated hooks | |
| 71 | +# (`phoenix-colocated/vigil`, imported by js/app.js) exist on disk. | |
| 72 | +RUN mix compile | |
| 73 | +RUN mix assets.deploy | |
| 74 | + | |
| 75 | +# Changes to config/runtime.exs don't require recompiling the code. | |
| 76 | +COPY config/runtime.exs config/ | |
| 77 | + | |
| 78 | +# bin/server, bin/migrate, bin/invite, bin/invite-link, bin/token, and | |
| 79 | +# env.sh.eex (the node name for clustering). | |
| 80 | +COPY rel rel | |
| 81 | + | |
| 82 | +RUN mix release | |
| 83 | + | |
| 84 | +FROM ${RUNNER_IMAGE} | |
| 85 | + | |
| 86 | +# The Erlang runtime's needs and nothing else (the NIFs link only libc and | |
| 87 | +# libgcc_s, which the base image has): | |
| 88 | +# * libstdc++6, openssl, libncurses6, locales, ca-certificates — the BEAM, | |
| 89 | +# TLS to Postgres, S3, SMTP, webhooks and uptime checks | |
| 90 | +# * tini — PID 1: forwards signals so connections close cleanly on | |
| 91 | +# SIGTERM, and reaps zombies | |
| 92 | +# `upgrade` first: Debian's security fixes since the base tag was cut. | |
| 93 | +RUN apt-get update -y \ | |
| 94 | + && apt-get upgrade -y --no-install-recommends \ | |
| 95 | + && apt-get install -y --no-install-recommends \ | |
| 96 | + libstdc++6 openssl libncurses6 locales ca-certificates tini \ | |
| 97 | + && apt-get clean && rm -rf /var/lib/apt/lists/* | |
| 98 | + | |
| 99 | +RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen | |
| 100 | + | |
| 101 | +ENV LANG=en_US.UTF-8 \ | |
| 102 | + LANGUAGE=en_US:en \ | |
| 103 | + LC_ALL=en_US.UTF-8 | |
| 104 | + | |
| 105 | +WORKDIR "/app" | |
| 106 | +RUN chown nobody /app | |
| 107 | + | |
| 108 | +# Uploaded files (sourcemaps, artifact bundles, debug files) when no | |
| 109 | +# S3_BUCKET is set: Vigil.Storage.Local under VIGIL_STORAGE_ROOT. Mount a | |
| 110 | +# volume here, shared by every replica, or set S3_* (docs/deploy.md). | |
| 111 | +ENV VIGIL_STORAGE_ROOT=/data/storage | |
| 112 | +RUN mkdir -p /data/storage && chown -R nobody /data | |
| 113 | +VOLUME ["/data/storage"] | |
| 114 | + | |
| 115 | +ENV MIX_ENV="prod" \ | |
| 116 | + PORT=4000 | |
| 117 | + | |
| 118 | +COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/vigil ./ | |
| 119 | + | |
| 120 | +USER nobody | |
| 121 | + | |
| 122 | +EXPOSE 4000 | |
| 123 | + | |
| 124 | +# /_health/ (liveness: the node is up) over plain HTTP with bash's | |
| 125 | +# /dev/tcp, so the image needs no curl. Host: localhost, which prod's | |
| 126 | +# force_ssl leaves alone (config/prod.exs). | |
| 127 | +HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \ | |
| 128 | + CMD ["bash", "-c", "exec 3<>/dev/tcp/127.0.0.1/${PORT:-4000} && printf 'GET /_health/ HTTP/1.0\\r\\nHost: localhost\\r\\n\\r\\n' >&3 && head -n 1 <&3 | grep -q ' 200 '"] | |
| 129 | + | |
| 130 | +ENTRYPOINT ["/usr/bin/tini", "--"] | |
| 131 | +CMD ["/app/bin/server"] |
modified
README.md
+3
−1
Click to load diff…
modified
config/runtime.exs
+158
−14
Click to load diff…
modified
config/test.exs
+10
−6
Click to load diff…
added
docs/deploy.md
+120
−0
Click to load diff…
added
lib/mix/tasks/vigil.token.ex
+41
−0
Click to load diff…
modified
lib/vigil/accounts/user_notifier.ex
+1
−1
Click to load diff…
modified
lib/vigil/alerts/email.ex
+2
−3
Click to load diff…
modified
lib/vigil/application.ex
+15
−1
Click to load diff…
modified
lib/vigil/mailer.ex
+11
−0
Click to load diff…
modified
lib/vigil/release.ex
+72
−0
Click to load diff…
modified
mix.exs
+9
−1
Click to load diff…
modified
mix.lock
+3
−0
Click to load diff…
modified
native/vigil_codec/src/lib.rs
+4
−1
Click to load diff…
added
rel/env.sh.eex
+21
−0
Click to load diff…
added
rel/overlays/bin/token
+13
−0
Click to load diff…
added
scripts/osv-audit
+230
−0
Click to load diff…
added
scripts/osv-diff
+77
−0
Click to load diff…
added
test/mix/vigil_token_task_test.exs
+56
−0
Click to load diff…
Parents: 0f6e20c