diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fda9703 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.env +.env.* +db/ +build/ +*.test diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml new file mode 100644 index 0000000..3689fcc --- /dev/null +++ b/.gitea/workflows/docker.yml @@ -0,0 +1,71 @@ +name: Publish Docker Image + +on: + push: + branches: + - main + tags: + - 'v*' + +env: + REGISTRY: gitea.bytevibe.dev + IMAGE: gitea.bytevibe.dev/gary/metatube-server + +jobs: + build: + name: Build and publish amd64 and arm64 + runs-on: ubuntu-latest + steps: + - name: Check out code and version tags + uses: https://github.com/actions/checkout@v7 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Check registry credentials + env: + REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }} + run: | + if [ -z "$REGISTRY_TOKEN" ]; then + echo "Add the REGISTRY_TOKEN repository secret with package read/write permission." + exit 1 + fi + + - name: Set up QEMU + uses: https://github.com/docker/setup-qemu-action@v4 + with: + platforms: amd64,arm64 + + - name: Set up Docker Buildx + uses: https://github.com/docker/setup-buildx-action@v4 + + - name: Log in to Gitea Container Registry + uses: https://github.com/docker/login-action@v4 + with: + registry: ${{ env.REGISTRY }} + username: gary + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Generate image tags and labels + id: meta + uses: https://github.com/docker/metadata-action@v5 + with: + images: ${{ env.IMAGE }} + flavor: | + latest=false + tags: | + type=raw,value=latest,enable=${{ gitea.ref == 'refs/heads/main' }} + type=sha,format=long + type=ref,event=tag + labels: | + org.opencontainers.image.source=https://gitea.bytevibe.dev/gary/metatube-server + + - name: Build and push + uses: https://github.com/docker/build-push-action@v7 + with: + context: . + file: Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index cd3c150..3b5f48b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN apk add --update --no-cache --no-progress make git \ FROM alpine:latest LABEL org.opencontainers.image.licenses=Apache-2.0 -LABEL org.opencontainers.image.source="https://github.com/metatube-community/metatube-sdk-go" +LABEL org.opencontainers.image.source="https://gitea.bytevibe.dev/gary/metatube-server" COPY --from=builder /src/build/metatube-server . diff --git a/README.md b/README.md index 991c7b3..a2b2ece 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Metadata Tube SDK in Golang. - [Contents](#contents) - [Features](#features) - [Installation](#installation) + - [Gitea Docker Deployment](#gitea-docker-deployment) - [Credits](#credits) - [License](#license) @@ -45,6 +46,47 @@ the below Go command to install SDK. go get -u github.com/metatube-community/metatube-sdk-go ``` +## Gitea Docker Deployment + +This fork publishes container images to +`gitea.bytevibe.dev/gary/metatube-server` using +`.gitea/workflows/docker.yml`. Images support both `linux/amd64` and +`linux/arm64`; Docker selects the matching architecture when pulling. + +### Actions Setup + +1. Enable Actions and Packages for the Gitea repository. +2. Register a Linux runner with the `ubuntu-latest` label. Its job environment + must have access to a Docker daemon, and permit QEMU/binfmt registration for + building the other architecture. The runner must also be able to download + the actions from GitHub and base images and Go dependencies from their registries. +3. Create a personal access token for `gary` with package read/write permission. + Add it under repository **Settings > Actions > Secrets** with the name + `REGISTRY_TOKEN`. Do not commit the token to the repository. + +Pushes to `main` publish `latest` and `sha-`. Pushes of tags +starting with `v` publish that tag and the commit tag without changing `latest`. +The commit tag can be used to deploy or roll back to a specific build. The +original `.github/workflows/` files are upstream GitHub workflows; this fork's +Gitea publishing workflow uses the Gitea registry. + +### Deploy or Update + +The included `docker-compose.yaml` uses the Gitea image. If authentication is +required, log in with your Gitea username and a token with package read permission: + +```sh +docker login gitea.bytevibe.dev -u gary +docker pull gitea.bytevibe.dev/gary/metatube-server:latest +docker compose pull metatube +docker compose up -d metatube +``` + +Run these commands on the deployment server in the directory containing your +Compose file. Keep its existing database, volumes, token, and other settings +when changing the image of an existing deployment. Publishing a new image +does not update running containers automatically. + ## Credits | Library | Description | diff --git a/docker-compose.yaml b/docker-compose.yaml index a9dc2b1..76e9bd5 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,6 +1,6 @@ services: metatube: - image: ghcr.io/metatube-community/metatube-server:latest + image: gitea.bytevibe.dev/gary/metatube-server:latest container_name: metatube ports: - "8080:8080"