Publish docker image with github actions (#1)
Co-authored-by: lowcarbdev <[email protected]>
This commit is contained in:
co-authored by
GitHub
lowcarbdev
parent
fd4e10634a
commit
7d53f20673
@@ -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
@@ -12,21 +12,22 @@ RUN npm ci
|
|||||||
# Copy frontend source
|
# Copy frontend source
|
||||||
COPY frontend/ ./
|
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
|
RUN npm run build
|
||||||
|
|
||||||
# Stage 2: Build backend
|
# Stage 2: Build backend
|
||||||
FROM golang:bookworm AS backend-builder
|
FROM golang:1.25-alpine AS backend-builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install build dependencies for libheif and SQLite FTS5
|
# Install build dependencies for libheif and SQLite FTS5
|
||||||
# Using bookworm-backports to get a newer version of libheif
|
RUN apk add --no-cache \
|
||||||
RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/sources.list && \
|
gcc \
|
||||||
apt-get update && apt-get install -y \
|
g++ \
|
||||||
build-essential \
|
musl-dev \
|
||||||
&& apt-get install -y -t bookworm-backports libheif-dev \
|
libheif-dev
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Copy go mod files
|
# Copy go mod files
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
@@ -39,22 +40,20 @@ COPY *.go ./
|
|||||||
COPY internal/*.go internal/
|
COPY internal/*.go internal/
|
||||||
|
|
||||||
# Build with FTS5 support
|
# 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
|
# Stage 3: Final runtime image
|
||||||
FROM debian:bookworm-slim
|
FROM alpine:3
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install runtime dependencies
|
# Install runtime dependencies
|
||||||
# Using bookworm-backports to get matching runtime library
|
RUN apk add --no-cache \
|
||||||
RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/sources.list && \
|
|
||||||
apt-get update && apt-get install -y \
|
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
wget \
|
wget \
|
||||||
ffmpeg \
|
ffmpeg \
|
||||||
&& apt-get install -y -t bookworm-backports libheif1 \
|
libheif
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Copy backend binary
|
# Copy backend binary
|
||||||
COPY --from=backend-builder /app/sbv .
|
COPY --from=backend-builder /app/sbv .
|
||||||
|
|||||||
@@ -5,20 +5,33 @@ A modern web application for viewing SMS and MMS message backups. Import your me
|
|||||||

|

|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
docker:
|
|
||||||
|
### Docker
|
||||||
|
|
||||||
|
Run the latest stable version:
|
||||||
```bash
|
```bash
|
||||||
docker run -d \
|
docker run -d \
|
||||||
-p 8081:8081 \
|
-p 8081:8081 \
|
||||||
-v $(pwd)/data:/data \
|
-v $(pwd)/data:/data \
|
||||||
-e DB_PATH_PREFIX=/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:
|
services:
|
||||||
sbv:
|
sbv:
|
||||||
image: lowcarbdev/sbv
|
image: ghcr.io/lowcarbdev/sbv:stable
|
||||||
ports:
|
ports:
|
||||||
- "8081:8081"
|
- "8081:8081"
|
||||||
volumes:
|
volumes:
|
||||||
@@ -30,6 +43,14 @@ services:
|
|||||||
restart: unless-stopped
|
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
|
## Features
|
||||||
|
|
||||||
- **Multi-user** - Create a username/password to log in
|
- **Multi-user** - Create a username/password to log in
|
||||||
|
|||||||
+4
-1
@@ -1,6 +1,9 @@
|
|||||||
services:
|
services:
|
||||||
sbv:
|
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
|
container_name: sbv
|
||||||
ports:
|
ports:
|
||||||
- "8081:8081"
|
- "8081:8081"
|
||||||
|
|||||||
Reference in New Issue
Block a user