Skip to content

Commit 14411a8

Browse files
committed
feat: rename project from xcstrings-translator to opentrans and update Docker configuration
- Rename binary from xcstrings-translator to opentrans in build scripts and workflows - Update CI workflow to trigger on 'next' branch instead of 'main' - Add yzma/llama.cpp library support with proper runtime dependencies - Enhance Dockerfile with multi-stage build including yzma CLI tool and library handling - Update .gitignore to reflect new binary name - Add comprehensive Docker run examples with environment variables and volume mounts - Configure library paths and permissions for non-root execution
1 parent 9eded36 commit 14411a8

7 files changed

Lines changed: 94 additions & 135 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ next ]
66
pull_request:
77

88
jobs:
@@ -87,7 +87,7 @@ jobs:
8787
CGO_ENABLED: 0
8888
run: |
8989
mkdir -p dist
90-
go build -o dist/xcstrings-translator-${{ matrix.suffix }} .
90+
go build -o dist/opentrans-${{ matrix.suffix }} .
9191
9292
gui-build:
9393
runs-on: ${{ matrix.os }}
@@ -154,4 +154,4 @@ jobs:
154154
CGO_ENABLED: 1
155155
run: |
156156
mkdir -p dist
157-
go build -tags gui -o dist/xcstrings-translator-${{ matrix.suffix }} .
157+
go build -tags gui -o dist/opentrans-${{ matrix.suffix }} .

.github/workflows/docker-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build and Push Docker Image
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ next ]
66
# tags: [ 'v*' ]
77

88
env:

.github/workflows/release.yml

Lines changed: 0 additions & 122 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
xcstrings-translator
1+
opentrans
22
.DS_Store
33
dist/
44
!webui/dist/

Dockerfile

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,25 @@ RUN git clone https://github.com/fdddf/opentrans.git . && \
1616
# Builder stage
1717
FROM golang:1.25-alpine AS builder
1818

19-
RUN apk update && apk add --no-cache make gcc musl-dev
19+
RUN apk update && apk add --no-cache make gcc musl-dev git
2020

21-
# Set working directory
21+
# Set working directory to backend where go.mod is located
2222
WORKDIR /app
2323

24-
COPY . .
24+
COPY backend/ .
2525

2626
# Install Go dependencies
2727
RUN go env -w GOPROXY='https://goproxy.cn,direct' && go mod tidy
2828

29+
# Install yzma CLI tool to download llama.cpp libraries
30+
RUN go install github.com/hybridgroup/yzma/cmd/yzma@latest
31+
32+
# Download llama.cpp precompiled libraries for Linux (will be placed in ./lib by default)
33+
RUN yzma lib get || true
34+
35+
# Ensure lib directory exists (even if yzma lib get fails)
36+
RUN mkdir -p /app/lib
37+
2938
# Copy built UI assets from ui-builder stage
3039
COPY --from=ui-builder /app/webui/dist ./webui/dist
3140

@@ -35,10 +44,13 @@ RUN make
3544
# Final stage - minimal Alpine image
3645
FROM alpine:latest
3746

38-
# Install runtime dependencies
47+
# Install runtime dependencies including libyzma support
3948
RUN apk --no-cache add \
4049
ca-certificates \
4150
tzdata \
51+
libstdc++ \
52+
libgcc \
53+
libffi \
4254
&& update-ca-certificates
4355

4456
# Create non-root user
@@ -48,9 +60,17 @@ RUN addgroup -g 65532 --system nonroot && \
4860
# Copy the binary from builder stage
4961
COPY --from=builder /app/opentrans /usr/local/bin/opentrans
5062

51-
# Create app directory and set permissions
52-
RUN mkdir -p /app && \
53-
chown -R nonroot:nonroot /app
63+
# Copy yzma/llama.cpp libraries from builder stage
64+
COPY --from=builder --chown=nonroot:nonroot /app/lib /usr/local/lib/yzma
65+
66+
# Create app directory, models directory for local Llama models, library directory, and set permissions
67+
RUN mkdir -p /app /app/models /usr/local/lib/yzma && \
68+
chown -R nonroot:nonroot /app && \
69+
chmod -R 755 /usr/local/lib/yzma
70+
71+
# Set yzma library path
72+
ENV LD_LIBRARY_PATH=/usr/local/lib/yzma
73+
ENV YZMA_LIB=/usr/local/lib/yzma
5474

5575
WORKDIR /app
5676

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,69 @@ A modern iOS/macOS multilingual string translation management platform supportin
4747
### Quick Start with Docker
4848

4949
```bash
50+
# Build the Docker image
5051
docker build -t opentrans .
52+
53+
# Run with default configuration
5154
docker run -p 3000:3000 opentrans
55+
56+
# Run with environment variables
57+
docker run -d \
58+
-p 3000:3000 \
59+
-e DB_HOST=your-db-host \
60+
-e DB_PORT=5432 \
61+
-e DB_USER=your-db-user \
62+
-e DB_PASSWORD=your-db-password \
63+
-e DB_NAME=xcstrings_translator \
64+
-e JWT_SECRET=your-jwt-secret \
65+
-e GOOGLE_API_KEY=your-google-api-key \
66+
-e DEEPL_API_KEY=your-deepl-api-key \
67+
-e BAIDU_APP_ID=your-baidu-app-id \
68+
-e BAIDU_APP_SECRET=your-baidu-app-secret \
69+
-e OPENAI_API_KEY=your-openai-api-key \
70+
-e ADMIN_USERNAME=admin \
71+
-e ADMIN_EMAIL=admin@example.com \
72+
-e ADMIN_PASSWORD=admin123 \
73+
--name opentrans \
74+
opentrans
75+
76+
# Run with environment file
77+
docker run -d \
78+
-p 3000:3000 \
79+
--env-file .env \
80+
--name opentrans \
81+
opentrans
82+
83+
# Run with config file mount and environment variables
84+
docker run -d \
85+
-p 3000:3000 \
86+
-v $(pwd)/config.yaml:/app/config.yaml:ro \
87+
-v $(pwd)/models:/app/models \
88+
-e DB_HOST=your-db-host \
89+
-e DB_PORT=5432 \
90+
-e DB_USER=your-db-user \
91+
-e DB_PASSWORD=your-db-password \
92+
-e DB_NAME=xcstrings_translator \
93+
-e JWT_SECRET=your-jwt-secret \
94+
--name opentrans \
95+
opentrans
96+
97+
# Run with persistent volume for local Llama models
98+
docker run -d \
99+
-p 3000:3000 \
100+
-v opentrans-models:/app/models \
101+
--env-file .env \
102+
--name opentrans \
103+
opentrans
104+
105+
# Check logs
106+
docker logs -f opentrans
107+
108+
# Stop the container
109+
docker stop opentrans
110+
111+
# Remove the container
112+
docker rm opentrans
52113
```
53114

54115
### Manual Installation

backend/migrations/000001_init_schema.up.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- ============================================
2-
-- xcstrings-translator Database Schema
2+
-- opentrans Database Schema
33
-- Combined migration - all tables and fields
44
-- ============================================
55

0 commit comments

Comments
 (0)