main pici.sh
Eric Bower  ·  2026-10-12
 1#!/usr/bin/env bash
 2set -euo pipefail
 3
 4export ZMX_SESSION_PREFIX="${ZMX_SESSION_PREFIX:-local.pico.}"
 5JOB_ID="${PICI_JOB:-local}"
 6EVENT_TYPE="${PICI_EVENT:-manual}"
 7
 8printf "\x1b[33m[%s] running ci (event=%s)\x1b[0m\n" "$JOB_ID" "$EVENT_TYPE"
 9
10docker image inspect golangci-lint:local >/dev/null 2>&1 || docker build -q -t golangci-lint:local -f ./Dockerfile.golangci .
11zmx run lint -d  docker run -t --rm -v $(pwd):/app -w /app golangci-lint:local golangci-lint run
12zmx run build -d docker build -t pico-test -f ./Dockerfile.test .
13zmx wait "*"
14zmx run test docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock -e REQUIRE_TESTCONTAINERS=1 pico-test
15
16printf "\x1b[32msuccess tests!\x1b[0m\n"
17
18if [ "$EVENT_TYPE" != "git.tag" ]; then
19  exit 0
20fi
21
22DOCKER_TAG="latest"
23DOCKER_PLATFORM="linux/amd64,linux/arm64"
24
25docker buildx ls | grep pico || docker buildx create --name pico
26docker buildx use pico
27zmx run caddy -d       docker buildx build --push --platform "$DOCKER_PLATFORM" -t "ghcr.io/picosh/pico/caddy:$DOCKER_TAG" ./caddy
28zmx run bouncer        docker buildx build --push --platform "$DOCKER_PLATFORM" -t "ghcr.io/picosh/pico/bouncer:$DOCKER_TAG" ./bouncer
29zmx wait "*"
30
31zmx run pico-ssh    docker buildx build --push --platform "$DOCKER_PLATFORM" -t "ghcr.io/picosh/pico/pico-ssh:$DOCKER_TAG" --build-arg APP=pico --target release-ssh .
32zmx run auth        docker buildx build --push --platform "$DOCKER_PLATFORM" -t "ghcr.io/picosh/pico/auth-web:$DOCKER_TAG" --build-arg APP=auth --target release-web .
33zmx run cdn         docker buildx build --push --platform "$DOCKER_PLATFORM" -t "ghcr.io/picosh/pico/pgs-cdn:$DOCKER_TAG" --target release-web -f Dockerfile.cdn .
34zmx run standalone  docker buildx build --push --platform "$DOCKER_PLATFORM" -t "ghcr.io/picosh/pgs:$DOCKER_TAG" --target release -f Dockerfile.standalone .
35zmx wait "*"
36
37apps=("prose" "pastes" "pgs" "feeds" "pipe")
38for APP in "${apps[@]}"; do
39  zmx run "$APP-ssh" -d docker buildx build --push --platform "$DOCKER_PLATFORM" -t "ghcr.io/picosh/pico/$APP-ssh:$DOCKER_TAG" --build-arg "APP=$APP" --target release-ssh .
40  zmx run "$APP-web" -d docker buildx build --push --platform "$DOCKER_PLATFORM" -t "ghcr.io/picosh/pico/$APP-web:$DOCKER_TAG" --build-arg "APP=$APP" --target release-web .
41  zmx wait "*"
42done
43
44printf "\x1b[32msuccess release!\x1b[0m\n"