|
| 1 | +# Docker Setup and GitHub Packages Release |
| 2 | + |
| 3 | +## Docker Build |
| 4 | + |
| 5 | +Build the Docker image: |
| 6 | + |
| 7 | +```bash |
| 8 | +docker build -t xcstrings-translator . |
| 9 | +``` |
| 10 | + |
| 11 | +## Running the Container |
| 12 | + |
| 13 | +Run the container with your xcstrings files: |
| 14 | + |
| 15 | +```bash |
| 16 | +# Mount a directory containing your xcstrings files |
| 17 | +docker run -v /path/to/your/files:/workspace -w /workspace xcstrings-translator [command] [options] |
| 18 | + |
| 19 | +# Example: |
| 20 | +docker run -v $(pwd):/workspace -w /workspace xcstrings-translator google --api-key "your-key" --input "Localizable.xcstrings" --target-languages "zh-Hans" |
| 21 | +``` |
| 22 | + |
| 23 | +## GitHub Packages Release |
| 24 | + |
| 25 | +The Docker image is automatically built and pushed to GitHub Container Registry when you push to the main branch or create a tag. |
| 26 | + |
| 27 | +### Manual Release Process |
| 28 | + |
| 29 | +1. **Build and tag the image:** |
| 30 | +```bash |
| 31 | +# Get the current version from cmd/root.go or create a tag |
| 32 | +VERSION=$(grep 'Version = ' cmd/root.go | cut -d'"' -f2) |
| 33 | +docker build -t ghcr.io/fdddf/xcstrings-translator:${VERSION} . |
| 34 | +docker tag ghcr.io/fdddf/xcstrings-translator:${VERSION} ghcr.io/fdddf/xcstrings-translator:latest |
| 35 | +``` |
| 36 | + |
| 37 | +2. **Login to GitHub Container Registry:** |
| 38 | +```bash |
| 39 | +echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin |
| 40 | +``` |
| 41 | + |
| 42 | +3. **Push the image:** |
| 43 | +```bash |
| 44 | +docker push ghcr.io/fdddf/xcstrings-translator:${VERSION} |
| 45 | +docker push ghcr.io/fdddf/xcstrings-translator:latest |
| 46 | +``` |
| 47 | + |
| 48 | +### Automated Release with GitHub Actions |
| 49 | + |
| 50 | +The workflow in `.github/workflows/docker-release.yml` automatically: |
| 51 | +- Builds the Docker image on pushes to main branch |
| 52 | +- Tags images with branch names, PR numbers, semantic versions, and commit SHAs |
| 53 | +- Pushes to GitHub Container Registry |
| 54 | +- Runs security scanning with Trivy |
| 55 | + |
| 56 | +#### Workflow Triggers: |
| 57 | +- Push to `main` or `master` branches |
| 58 | +- Push of version tags (`v*`) |
| 59 | +- Pull requests to `main` |
| 60 | + |
| 61 | +### Using the Released Image |
| 62 | + |
| 63 | +Pull and run the latest image: |
| 64 | + |
| 65 | +```bash |
| 66 | +docker pull ghcr.io/fdddf/xcstrings-translator:latest |
| 67 | +docker run ghcr.io/fdddf/xcstrings-translator:latest --help |
| 68 | +``` |
| 69 | + |
| 70 | +## Multi-platform Support |
| 71 | + |
| 72 | +The GitHub Actions workflow builds for both `linux/amd64` and `linux/arm64` architectures. |
| 73 | + |
| 74 | +## Security Features |
| 75 | + |
| 76 | +- Runs as non-root user (UID 65532) |
| 77 | +- Minimal Alpine base image |
| 78 | +- Health checks built-in |
| 79 | +- Built with security scanning via Trivy |
0 commit comments