|
| 1 | +# Go + JasperStarter Docker Image |
| 2 | + |
| 3 | +A lightweight Docker base image combining Go 1.23 Alpine with JasperStarter for report generation. |
| 4 | + |
| 5 | +## What's Included |
| 6 | + |
| 7 | +- **Go 1.23** - Go programming language |
| 8 | +- **OpenJDK 17** - Java runtime for JasperStarter |
| 9 | +- **JasperStarter 3.6.2** - Tool to run JasperReports reports |
| 10 | +- **Font Support** - Common fonts (FreeFont, Liberation, DejaVu) for PDF generation |
| 11 | +- **Alpine Linux** - Small and secure base distribution |
| 12 | + |
| 13 | +## Image Tags |
| 14 | + |
| 15 | +- `golang-jasper:1.23-3.6.2` - Version specific tag |
| 16 | +- `golang-jasper:latest` - Latest version |
| 17 | + |
| 18 | +## Usage |
| 19 | + |
| 20 | +### As a Base Image |
| 21 | + |
| 22 | +Use this image as a base for your Go applications that need JasperStarter: |
| 23 | + |
| 24 | +```dockerfile |
| 25 | +FROM golang-jasper:1.23-3.6.2 |
| 26 | + |
| 27 | +# install your Go development tools |
| 28 | +RUN go install github.com/air-verse/ [email protected] |
| 29 | +RUN go install github.com/go-delve/delve/cmd/dlv@latest |
| 30 | + |
| 31 | +# copy your application files |
| 32 | +COPY go.mod go.sum ./ |
| 33 | +RUN go mod download |
| 34 | + |
| 35 | +COPY . . |
| 36 | + |
| 37 | +# your application setup |
| 38 | +EXPOSE 8080 |
| 39 | +CMD ["air"] |
| 40 | +``` |
| 41 | + |
| 42 | +### Running JasperStarter |
| 43 | + |
| 44 | +The image includes JasperStarter in the PATH, so you can use it directly: |
| 45 | + |
| 46 | +```bash |
| 47 | +# in your Dockerfile or at runtime |
| 48 | +RUN jasperstarter --version |
| 49 | + |
| 50 | +# just an example in your application code, but suggest to use go-jasper |
| 51 | +exec.Command("jasperstarter", "process", "report.jrxml", "-f", "pdf") |
| 52 | +``` |
| 53 | + |
| 54 | +## Building the Image |
| 55 | + |
| 56 | +```bash |
| 57 | +# clone or copy this directory |
| 58 | +cd ~/wkspcs/golang-jasper |
| 59 | + |
| 60 | +# build using the script |
| 61 | +./build.sh |
| 62 | + |
| 63 | +# or build manually |
| 64 | +docker build -t golang-jasper:1.23-3.6.2 . |
| 65 | +docker tag golang-jasper:1.23-3.6.2 golang-jasper:latest |
| 66 | +``` |
| 67 | + |
| 68 | +## Pushing to Registry |
| 69 | + |
| 70 | +Edit the `REGISTRY` variable in `build.sh` or specify it when building: |
| 71 | + |
| 72 | +```bash |
| 73 | +# for Docker Hub |
| 74 | +REGISTRY="yourusername/" |
| 75 | +./build.sh |
| 76 | + |
| 77 | +# for private registry |
| 78 | +REGISTRY="your-registry.com/yournamespace/" |
| 79 | +./build.sh |
| 80 | +``` |
| 81 | + |
| 82 | +## Verification |
| 83 | + |
| 84 | +Test the installation: |
| 85 | + |
| 86 | +```bash |
| 87 | +docker run --rm golang-jasper:1.23-3.6.2 jasperstarter --version |
| 88 | +``` |
| 89 | + |
| 90 | +## Size Optimization |
| 91 | + |
| 92 | +This image is optimized for size while including all necessary components: |
| 93 | + |
| 94 | +- Uses Alpine Linux base |
| 95 | +- Removes build artifacts after installation |
| 96 | +- Combines RUN commands to reduce layers |
| 97 | + |
| 98 | +## Font Support |
| 99 | + |
| 100 | +The image includes common fonts for PDF generation: |
| 101 | + |
| 102 | +- FreeFont family |
| 103 | +- Liberation family |
| 104 | +- DejaVu family |
| 105 | + |
| 106 | +Font cache is updated during image build for optimal performance. |
0 commit comments