Skip to content
Open
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
28 changes: 25 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ name: release

on:
push:
# run only against tags
# run only against version tags
tags:
- "*"
Comment thread
waveywaves marked this conversation as resolved.
- "v*"

permissions:
contents: write
packages: write
id-token: write # keyless cosign signing

jobs:
goreleaser:
runs-on: ubuntu-latest
env:
# true if tag-name doesn't contain a hyphen (eg. v1.2.3-dev, 1.2.4-nightly), false otherwise
# Evaluates to the string "true" or "false". true if tag-name doesn't
# contain a hyphen (eg. v1.2.3-dev, 1.2.4-nightly), false otherwise.
# GoReleaser templates consume this as a string comparison for the
# conditional :latest container tag.
MAKE_LATEST_RELEASE: ${{ contains(github.ref_name, '-') == false }}
steps:
- name: Checkout
Expand All @@ -26,6 +31,22 @@ jobs:
with:
go-version: stable

- name: Install cosign
uses: sigstore/cosign-installer@v3

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

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

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
Expand All @@ -40,3 +61,4 @@ jobs:
MAKE_LATEST_RELEASE: ${{ env.MAKE_LATEST_RELEASE }}
# If using goreleaser-pro, uncomment the following line
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

30 changes: 30 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,36 @@ builds:
# Templates: allowed.
mod_timestamp: "{{ .CommitTimestamp }}"

dockers_v2:
- id: plakar
ids:
- plakar
images:
- "ghcr.io/plakarkorp/plakar"
tags:
- "{{ .Tag }}"
- '{{ if eq .Env.MAKE_LATEST_RELEASE "true" }}latest{{ end }}'
dockerfile: Dockerfile
flags:
- "--target=goreleaser"
platforms:
- linux/amd64
- linux/arm64
labels:
"org.opencontainers.image.source": "https://github.com/PlakarKorp/plakar"
"org.opencontainers.image.version": "{{ .Version }}"
"org.opencontainers.image.created": "{{ .Date }}"
"org.opencontainers.image.title": "plakar"
"org.opencontainers.image.revision": "{{ .FullCommit }}"

docker_signs:
- cmd: cosign
output: true
args:
- sign
- "${artifact}"
- "--yes"

nfpms:
- package_name: plakar

Expand Down
36 changes: 22 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,26 @@
# persistent volume at the plakar cache directory, e.g.:
# docker run -v plakar-cache:/home/plakar/.cache/plakar ...
#
# Stage 1: Build
# Stage 1: Shared runtime base
FROM alpine:3.23 AS runtime-base

# CA certificates for HTTPS connections to remote repositories and plakar.io
RUN apk add --no-cache ca-certificates

# Create non-root user (/etc/passwd required by user.Current())
RUN addgroup -S plakar && adduser -S -G plakar -h /home/plakar plakar

USER plakar
WORKDIR /home/plakar

ENTRYPOINT ["plakar"]

# Stage 2: GoReleaser runtime image (binary provided via GoReleaser build context)
FROM runtime-base AS goreleaser
ARG TARGETPLATFORM
COPY ${TARGETPLATFORM}/plakar /usr/local/bin/plakar

# Stage 3: Build from source for manual Docker builds
FROM golang:1.25-alpine AS builder

WORKDIR /src
Expand All @@ -20,18 +39,7 @@ COPY . .
# Build static binary matching goreleaser configuration
RUN CGO_ENABLED=0 go build -trimpath -v -o /plakar .

# Stage 2: Runtime
FROM alpine:3.23

# CA certificates for HTTPS connections to remote repositories and plakar.io
RUN apk add --no-cache ca-certificates

# Create non-root user (/etc/passwd required by user.Current())
RUN addgroup -S plakar && adduser -S -G plakar -h /home/plakar plakar
# Stage 4: Runtime image for manual Docker builds
FROM runtime-base

COPY --from=builder /plakar /usr/local/bin/plakar

USER plakar
WORKDIR /home/plakar

ENTRYPOINT ["plakar"]
Loading