Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bin/
build/
tmp/
.env
web/node_modules/
Expand Down
27 changes: 24 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
IMAGE ?= squirrelbot:0.1.0
IMAGE_NAME ?= squirrelbot
CONTAINER ?= $(shell command -v docker >/dev/null 2>&1 && echo docker || echo podman)
COMPOSE = $(CONTAINER) compose

Expand All @@ -15,7 +15,7 @@ help:
'up Bot and Postgres via $(CONTAINER)' \
'down Stop $(CONTAINER) compose services' \
'build Local bot binary and dashboard' \
'image Container image ($(IMAGE))' \
'image $(IMAGE_NAME):latest and the next patch version' \
'test Go unit tests' \
'test-e2e API and dashboard end-to-end tests'

Expand Down Expand Up @@ -51,7 +51,28 @@ build-web: web/node_modules
npm --prefix web run build

image:
$(CONTAINER) build -t $(IMAGE) .
@mkdir -p build
@version_file=build/image-version; \
if [ -f "$$version_file" ]; then \
version=$$(tr -d '[:space:]' < "$$version_file"); \
else \
version=$$(awk '/^appVersion:/{gsub(/"/,"",$$2); print $$2; exit}' deploy/helm/squirrelbot/Chart.yaml); \
fi; \
case "$$version" in \
*.*.*) ;; \
*) echo "image version must be major.minor.patch, got $$version" >&2; exit 1 ;; \
esac; \
major=$${version%%.*}; \
rest=$${version#*.}; \
minor=$${rest%%.*}; \
patch=$${rest#*.}; \
case "$$patch" in \
*[!0-9]*) echo "image patch must be a number, got $$patch" >&2; exit 1 ;; \
esac; \
next="$$major.$$minor.$$((10#$$patch + 1))"; \
echo "Building $(IMAGE_NAME):$$next and $(IMAGE_NAME):latest"; \
$(CONTAINER) build -t "$(IMAGE_NAME):$$next" -t "$(IMAGE_NAME):latest" . \
&& printf '%s\n' "$$next" > "$$version_file"

test:
go test ./...
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Copy `.env.example` to `.env` and fill in the Discord token, OAuth client id, OA

`make dev` starts Postgres, Air, and the dashboard at `http://localhost:5173`. Air rebuilds the bot when Go files, SQL migrations, or `.env` change. `make bot` and `make web` start those processes on their own, after `make db`.

`make build` writes `bin/squirrelbot` and `web/build`. `make image` builds the container `squirrelbot:0.1.0`. `make test` runs the Go unit tests. `make test-e2e` runs the API suite against Postgres and a Discord stand-in, then the browser suite against the dashboard. It starts the Compose Postgres if nothing is listening on port 5432.
`make build` writes `bin/squirrelbot` and `web/build`. `make image` builds `squirrelbot:latest` and the next patch version. `make test` runs the Go unit tests. `make test-e2e` runs the API suite against Postgres and a Discord stand-in, then the browser suite against the dashboard. It starts the Compose Postgres if nothing is listening on port 5432.

`make up` runs the bot and Postgres in Docker. In that mode the dashboard is served by the bot on port 8080, so set `PUBLIC_URL` to `http://localhost:8080`. `make down` stops those containers.

Expand All @@ -76,7 +76,7 @@ helm upgrade --install squirrelbot deploy/helm/squirrelbot \

Set `postgres.bundled=true` and `postgres.auth.password` to start a bundled Postgres StatefulSet. That database is for a single cluster and a small server. Use an external Postgres for anything you need to restore. `postgres.sslMode` sets the libpq mode on `DATABASE_URL` when the chart writes that URL. The default is `disable`. An `sslmode` already present in `secrets.databaseUrl` is left as written.

`make image` builds `squirrelbot:0.1.0` from the repository root. Override the tag with `make image IMAGE=squirrelbot:dev`. Set `imagePullSecrets` when the registry is private.
`make image` builds `squirrelbot:latest` and the next patch version from the repository root. The first build is one patch above the chart app version. Later builds increment the patch again. The last version is stored in `build/image-version`. Set `imagePullSecrets` when the registry is private.

## Releases

Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/squirrelbot/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{{- end }}

{{- define "squirrelbot.image" -}}
{{- $tag := .Values.image.tag | default .Chart.AppVersion }}
{{- $tag := .Values.image.tag | default "latest" }}
{{- printf "%s:%s" .Values.image.repository $tag }}
{{- end }}

Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/squirrelbot/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fullnameOverride: ""

image:
repository: squirrelbot
tag: ""
tag: latest
pullPolicy: IfNotPresent

imagePullSecrets: []
Expand Down
Loading