Live video on the AT Protocol

Merge branch 'eli/ci' into 'next'

build: add ci

See merge request aquareum-tv/aquareum!2

+135 -2
+3
.gitignore
··· 1 1 node_modules 2 + dist 3 + bin 4 + .pnpm-store
+33
.gitlab-ci.yml
··· 1 + builder: 2 + stage: build 3 + image: quay.io/buildah/stable 4 + variables: 5 + # Use vfs with buildah. Docker offers overlayfs as a default, but Buildah 6 + # cannot stack overlayfs on top of another overlayfs filesystem. 7 + STORAGE_DRIVER: vfs 8 + # Write all image metadata in the docker format, not the standard OCI format. 9 + # Newer versions of docker can handle the OCI format, but older versions, like 10 + # the one shipped with Fedora 30, cannot handle the format. 11 + # BUILDAH_FORMAT: docker 12 + FQ_IMAGE_NAME: "$CI_REGISTRY_IMAGE:builder" 13 + before_script: 14 + # GitLab container registry credentials taken from the 15 + # [predefined CI/CD variables](../variables/index.md#predefined-cicd-variables) 16 + # to authenticate to the registry. 17 + - echo "$CI_REGISTRY_PASSWORD" | buildah login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY 18 + script: 19 + - cd docker && buildah build -t $FQ_IMAGE_NAME -f build.Dockerfile 20 + - buildah push $FQ_IMAGE_NAME 21 + 22 + build: 23 + stage: build 24 + needs: 25 + - builder 26 + image: "$CI_REGISTRY_IMAGE:builder" 27 + script: 28 + - make all 29 + artifacts: 30 + name: "$CI_COMMIT_REF_NAME" 31 + paths: 32 + - bin/aquareum-linux-amd64.tar.gz 33 + - bin/aquareum-linux-arm64.tar.gz
+37 -2
Makefile
··· 1 + OUT_DIR?="bin" 2 + $(shell mkdir -p $(OUT_DIR)) 1 3 2 - .phony: default 3 - default: 4 + .PHONY: default 5 + default: app node 6 + 7 + .PHONY: app 8 + app: 4 9 pnpm install 5 10 pnpm run -r build 11 + 12 + .PHONY: node 13 + node: 14 + go build -o $(OUT_DIR)/aquareum ./cmd/aquareum 15 + 16 + .PHONY: all 17 + all: app node-all-platforms 18 + 19 + .PHONY: node-all-platforms 20 + node-all-platforms: 21 + for GOOS in linux; do \ 22 + for GOARCH in amd64 arm64; do \ 23 + GOOS=$$GOOS GOARCH=$$GOARCH $(MAKE) node OUT_DIR=bin/$$GOOS-$$GOARCH \ 24 + && cd bin/$$GOOS-$$GOARCH \ 25 + && tar -czvf ../aquareum-$$GOOS-$$GOARCH.tar.gz ./aquareum \ 26 + && cd -; \ 27 + done \ 28 + done 29 + 30 + .PHONY: docker-build 31 + docker-build: docker-build-builder docker-build-in-container 32 + 33 + .PHONY: docker-build-builder 34 + docker-build-builder: 35 + cd docker \ 36 + && docker build --os=linux --arch=amd64 -f build.Dockerfile -t aqrm.io/aquareum-tv/aquareum:builder . 37 + 38 + .PHONY: docker-build-builder 39 + docker-build-in-container: 40 + docker run -v $$(pwd):$$(pwd) -w $$(pwd) --rm -it aqrm.io/aquareum-tv/aquareum:builder make
+19
cmd/aquareum/aquareum.go
··· 1 + package main 2 + 3 + import ( 4 + "fmt" 5 + "log" 6 + "net/http" 7 + 8 + "aquareum.tv/aquareum/packages/app" 9 + ) 10 + 11 + func main() { 12 + fmt.Println("hello world") 13 + files, err := app.Files() 14 + if err != nil { 15 + panic(err) 16 + } 17 + http.Handle("/", http.FileServer(http.FS(files))) 18 + log.Fatal(http.ListenAndServe(":8080", nil)) 19 + }
+22
docker/build.Dockerfile
··· 1 + FROM ubuntu:22.04 2 + 3 + ARG TARGETARCH 4 + ENV TARGETARCH $TARGETARCH 5 + 6 + ENV GO_VERSION 1.22.4 7 + ENV NODE_VERSION 22.3.0 8 + 9 + RUN apt update && apt install -y build-essential curl 10 + RUN curl -L --fail https://go.dev/dl/go$GO_VERSION.linux-$TARGETARCH.tar.gz -o go.tar.gz \ 11 + && tar -C /usr/local -xf go.tar.gz \ 12 + && rm go.tar.gz 13 + ENV PATH $PATH:/usr/local/go/bin 14 + 15 + RUN export NODEARCH="$TARGETARCH" \ 16 + && if [ "$TARGETARCH" = "amd64" ]; then export NODEARCH="x64"; fi \ 17 + && curl -L --fail https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$NODEARCH.tar.xz -o node.tar.gz \ 18 + && tar -xf node.tar.gz \ 19 + && cp -r node-v$NODE_VERSION-linux-$NODEARCH/* /usr/local \ 20 + && rm -rf node.tar.gz node-v$NODE_VERSION-linux-$NODEARCH 21 + 22 + RUN npm install -g pnpm
+3
go.mod
··· 1 + module aquareum.tv/aquareum 2 + 3 + go 1.22.2
+18
packages/app/app.go
··· 1 + package app 2 + 3 + import ( 4 + "embed" 5 + "io/fs" 6 + ) 7 + 8 + //go:embed all:dist/** 9 + var files embed.FS 10 + 11 + // fetch a static snapshot of the current Aquareum web app 12 + func Files() (fs.FS, error) { 13 + rootFiles, err := fs.Sub(files, "dist") 14 + if err != nil { 15 + return nil, err 16 + } 17 + return rootFiles, nil 18 + }