Skip to content
Open
50 changes: 50 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Documentation
*.md
docs/

# Git
.git/
.gitignore
.gitattributes

# IDE
.vscode/
.idea/
*.swp
*.swo

# Go development
*.test
*.out
coverage.txt
vendor/

# Build artifacts (except the binary we need)
dist/
!dist/*/tqm

# CI/CD
.github/
.goreleaser.yml

# Development files
Makefile
docker-compose.yml
.dockerignore

# Temporary files
*.tmp
*.log
tmp/

# OS files
.DS_Store
Thumbs.db

# Node.js (if any)
node_modules/
npm-debug.log

# Other
*.orig
*~
156 changes: 140 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@ name: Build
on:
push:
branches:
- "master"
- "main"
tags:
- 'v*'
- "v*"
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- '.github/images/**'
- 'config.yaml'
- 'docker-compose.yml'
- 'Makefile'
- '**.md'
- ".github/ISSUE_TEMPLATE/**"
- ".github/images/**"
- "config.yaml"
- "docker-compose.yml"
- "Makefile"
- "**.md"
pull_request:
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- '.github/images/**'
- 'config.yaml'
- 'docker-compose.yml'
- 'Makefile'
- '**.md'
- ".github/ISSUE_TEMPLATE/**"
- ".github/images/**"
- "config.yaml"
- "docker-compose.yml"
- "Makefile"
- "**.md"

env:
REGISTRY: ghcr.io
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
GO_VERSION: '1.24'
GO_VERSION: "1.24"

permissions:
contents: write
Expand Down Expand Up @@ -99,4 +99,128 @@ jobs:
path: |
dist/*.tar.gz
dist/*.json
dist/*.yaml
dist/*.yaml

docker:
name: Build Docker images
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
platform:
- linux/amd64
- linux/arm/v6
- linux/arm/v7
- linux/arm64
- linux/arm64/v8
needs: [test]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=semver,pattern={{version}},prefix=v
type=semver,pattern={{major}}.{{minor}},prefix=v
type=ref,event=branch
type=ref,event=pr
flavor: |
latest=auto

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and publish image
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
file: ./ci.Dockerfile
platforms: ${{ matrix.platform }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ (github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request') && 'true' || 'false' }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false

- name: Export image digest
id: digest-prep
run: |
mkdir -p /tmp/digests
digest="${{ steps.docker_build.outputs.digest }}"
echo "manifest-hash=${digest#sha256:}" >> "$GITHUB_OUTPUT"
touch "/tmp/digests/${digest#sha256:}"

- name: Upload image digest
uses: actions/upload-artifact@v4
with:
name: docker-digests-${{ steps.digest-prep.outputs.manifest-hash }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

docker-merge:
name: Publish Docker multi-arch manifest
if: ${{ github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
needs: [docker]
steps:
- name: Download image digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: docker-digests-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=semver,pattern={{version}},prefix=v
type=semver,pattern={{major}}.{{minor}},prefix=v
type=ref,event=branch
type=ref,event=pr
flavor: |
latest=auto

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)

- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
12 changes: 6 additions & 6 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ archives:
- tqm
format_overrides:
- goos: windows
formats: ['zip']
formats: ["zip"]

checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt'
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"

snapshot:
version_template: "{{ .Major }}.{{ .Minor }}.{{ .Patch }}-dev+{{ .ShortCommit }}"
Expand All @@ -61,9 +61,9 @@ release:
prerelease: auto
footer: |
**Full Changelog**: https://github.com/autobrr/tqm/compare/{{ .PreviousTag }}...{{ .Tag }}

## What to do next?

- Read the [documentation](https://autobrr.com)
- Join our [Discord server](https://discord.gg/WQ2eUycxyT)

Expand All @@ -76,10 +76,10 @@ changelog:
- Merge remote-tracking branch
- Merge branch
groups:
- title: 'New Features'
- title: "New Features"
regexp: "^.*feat[(\\w)]*:+.*$"
order: 0
- title: 'Bug fixes'
- title: "Bug fixes"
regexp: "^.*fix[(\\w)]*:+.*$"
order: 10
- title: Other work
Expand Down
60 changes: 60 additions & 0 deletions ci.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# build app
FROM --platform=$BUILDPLATFORM golang:1.24-alpine3.21 AS app-builder
Comment thread
s0up4200 marked this conversation as resolved.
Outdated
RUN apk add --no-cache git tzdata
Comment thread
s0up4200 marked this conversation as resolved.
Outdated

ENV SERVICE=tqm

WORKDIR /src

# Cache Go modules
COPY go.mod go.sum ./
RUN go mod download

COPY . ./

ARG VERSION=dev
ARG REVISION=dev
ARG BUILDTIME
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT

RUN --network=none --mount=target=. \
export GOOS=$TARGETOS; \
export GOARCH=$TARGETARCH; \
[ "$GOARCH" = "amd64" ] && export GOAMD64="$TARGETVARIANT"; \
[ "$GOARCH" = "arm64" ] && case "$TARGETVARIANT" in *.*) export GOARM64="$TARGETVARIANT";; esac; \
[ "$GOARCH" = "arm64" ] && case "$TARGETVARIANT" in *.*) : ;; v*) export GOARM64="$TARGETVARIANT.0";; esac; \
[ "$GOARCH" = "arm" ] && [ "$TARGETVARIANT" = "v6" ] && export GOARM=6; \
[ "$GOARCH" = "arm" ] && [ "$TARGETVARIANT" = "v7" ] && export GOARM=7; \
echo $GOARCH $GOOS $GOARM$GOAMD64$GOARM64; \
go build -ldflags "-s -w -X github.com/autobrr/tqm/pkg/runtime.Version=${VERSION} -X github.com/autobrr/tqm/pkg/runtime.GitCommit=${REVISION} -X github.com/autobrr/tqm/pkg/runtime.Timestamp=${BUILDTIME}" -o /out/bin/tqm cmd/tqm/main.go

# build runner
FROM alpine:latest AS runner

LABEL org.opencontainers.image.source="https://github.com/autobrr/tqm"
LABEL org.opencontainers.image.licenses="GPL-3.0"
LABEL org.opencontainers.image.base.name="alpine:latest"

ENV CONFIG_DIR="/config" \
PUID=1000 \
PGID=1000

RUN apk --no-cache add ca-certificates curl tzdata jq && \
addgroup -g $PGID abc && \
adduser -D -u $PUID -G abc abc

WORKDIR /app
VOLUME /config
EXPOSE 7337

COPY --link --from=app-builder /out/bin/tqm /usr/local/bin/

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD /usr/local/bin/tqm --help > /dev/null || exit 1

USER abc
Comment thread
s0up4200 marked this conversation as resolved.
Outdated

ENTRYPOINT ["/usr/local/bin/tqm", "--config-dir", "/config"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ENTRYPOINT ["/usr/local/bin/tqm", "--config-dir", "/config"]
ENTRYPOINT ["/usr/local/bin/tqm", "--config-dir", "/config"]