Publish docker image with github actions (#1)

Co-authored-by: lowcarbdev <[email protected]>
This commit is contained in:
lowcarbdev
2025-11-11 21:56:53 -07:00
committed by GitHub
co-authored by GitHub lowcarbdev
parent fd4e10634a
commit 7d53f20673
5 changed files with 111 additions and 21 deletions
+67
View File
@@ -0,0 +1,67 @@
name: Docker Build and Push
on:
push:
branches:
- main
- '*'
tags:
- 'v*.*.*'
pull_request:
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- 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 GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=stable,enable={{is_default_branch}}
flavor: |
latest=false
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
+14 -15
View File
@@ -12,21 +12,22 @@ RUN npm ci
# Copy frontend source
COPY frontend/ ./
# Build frontend
# Build frontend with production API URL (relative path)
# This ensures the frontend uses relative paths instead of localhost:8081
ENV VITE_API_URL=/api
RUN npm run build
# Stage 2: Build backend
FROM golang:bookworm AS backend-builder
FROM golang:1.25-alpine AS backend-builder
WORKDIR /app
# Install build dependencies for libheif and SQLite FTS5
# Using bookworm-backports to get a newer version of libheif
RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/sources.list && \
apt-get update && apt-get install -y \
build-essential \
&& apt-get install -y -t bookworm-backports libheif-dev \
&& rm -rf /var/lib/apt/lists/*
RUN apk add --no-cache \
gcc \
g++ \
musl-dev \
libheif-dev
# Copy go mod files
COPY go.mod go.sum ./
@@ -39,22 +40,20 @@ COPY *.go ./
COPY internal/*.go internal/
# Build with FTS5 support
RUN go build -tags "fts5 heic" -o sbv .
# Use CGO for SQLite and libheif
RUN CGO_ENABLED=1 go build -tags "fts5 heic" -o sbv .
# Stage 3: Final runtime image
FROM debian:bookworm-slim
FROM alpine:3
WORKDIR /app
# Install runtime dependencies
# Using bookworm-backports to get matching runtime library
RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/sources.list && \
apt-get update && apt-get install -y \
RUN apk add --no-cache \
ca-certificates \
wget \
ffmpeg \
&& apt-get install -y -t bookworm-backports libheif1 \
&& rm -rf /var/lib/apt/lists/*
libheif
# Copy backend binary
COPY --from=backend-builder /app/sbv .
+25 -4
View File
@@ -5,20 +5,33 @@ A modern web application for viewing SMS and MMS message backups. Import your me
![conversation view](docs/conversation-view.png "SBV Conversation View")
## Quick Start
docker:
### Docker
Run the latest stable version:
```bash
docker run -d \
-p 8081:8081 \
-v $(pwd)/data:/data \
-e DB_PATH_PREFIX=/data \
lowcarbdev/sbv
ghcr.io/lowcarbdev/sbv:stable
```
docker-compose:
Or run the latest development version:
```bash
docker run -d \
-p 8081:8081 \
-v $(pwd)/data:/data \
-e DB_PATH_PREFIX=/data \
ghcr.io/lowcarbdev/sbv:latest
```
### Docker Compose
```yaml
services:
sbv:
image: lowcarbdev/sbv
image: ghcr.io/lowcarbdev/sbv:stable
ports:
- "8081:8081"
volumes:
@@ -30,6 +43,14 @@ services:
restart: unless-stopped
```
### Available Image Tags
- `stable` - Latest stable release (recommended for production)
- `latest` - Latest build from main branch (development)
- `v0.1.0` - Specific version (e.g., v0.1.0)
- `v0.1` - Latest patch version of v0.1.x
- `v0` - Latest minor version of v0.x.x
## Features
- **Multi-user** - Create a username/password to log in
+4 -1
View File
@@ -1,6 +1,9 @@
services:
sbv:
build: .
# Use pre-built image from GitHub Container Registry
# For local development, comment out 'image' and uncomment 'build: .' below
image: ghcr.io/lowcarbdev/sbv:stable
# build: .
container_name: sbv
ports:
- "8081:8081"
+1 -1
View File
@@ -1,6 +1,6 @@
module github.com/lowcarbdev/sbv
go 1.24.7
go 1.25.4
require github.com/mattn/go-sqlite3 v1.14.32