Skip to content

Commit 1e675fa

Browse files
committed
feat: initial commit of build file for golang alpine image with jasperstarter installed onto it
0 parents  commit 1e675fa

File tree

5 files changed

+231
-0
lines changed

5 files changed

+231
-0
lines changed

Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Go + JasperStarter Docker Image
2+
# Contains Go programming language and JasperStarter for JasperReports
3+
# See NOTICES file for third-party software licenses
4+
5+
FROM golang:1.23.5-alpine
6+
7+
LABEL maintainer="[email protected]"
8+
LABEL org.opencontainers.image.title="Go with JasperStarter"
9+
LABEL org.opencontainers.image.description="Go 1.23 Alpine with JasperStarter 3.6.2 pre-installed"
10+
LABEL org.opencontainers.image.version="1.23-3.6.2"
11+
LABEL org.opencontainers.image.source="https://github.com/unlockedlabs/golang-jasperstarter-docker"
12+
LABEL org.opencontainers.image.licenses="MIT (Dockerfile), BSD-3-Clause (Go), Apache-2.0 (JasperStarter)"
13+
14+
# install Java and dependencies needed for JasperStarter
15+
RUN apk add --no-cache \
16+
openjdk17-jre \
17+
unzip \
18+
wget \
19+
fontconfig \
20+
ttf-freefont \
21+
ttf-liberation \
22+
ttf-dejavu \
23+
curl \
24+
tar \
25+
&& fc-cache -fv
26+
27+
# install JasperStarter binary
28+
ENV JASPER_VERSION=3.6.2
29+
RUN mkdir -p /opt/jasperstarter && \
30+
wget "https://sourceforge.net/projects/jasperstarter/files/JasperStarter-3.6/jasperstarter-${JASPER_VERSION}-bin.tar.bz2/download" -O /tmp/jasperstarter.tar.bz2 && \
31+
tar -xjf /tmp/jasperstarter.tar.bz2 -C /tmp && \
32+
cp -r /tmp/jasperstarter/* /opt/jasperstarter/ && \
33+
rm -rf /tmp/jasperstarter.tar.bz2 /tmp/jasperstarter
34+
35+
ENV PATH="/opt/jasperstarter/bin:${PATH}"
36+
37+
COPY LICENSE NOTICES /usr/share/doc/golang-jasperstarter/
38+
39+
WORKDIR /app
40+
41+
# verify installations making sure
42+
RUN go version && jasperstarter --version
43+
44+
CMD ["/bin/sh"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Unlocked Labs
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

NOTICES

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
This Docker image includes the following third-party software:
2+
3+
================================================================================
4+
Go Programming Language
5+
================================================================================
6+
Copyright (c) 2009 The Go Authors. All rights reserved.
7+
8+
License: BSD-3-Clause
9+
Source: https://golang.org/
10+
License Text: https://golang.org/LICENSE
11+
12+
================================================================================
13+
JasperStarter
14+
================================================================================
15+
Copyright (c) 2012-2014 Cenote GmbH.
16+
17+
License: Apache License 2.0
18+
Source: https://github.com/cenote-gmbh/jasperstarter
19+
License Text: http://www.apache.org/licenses/LICENSE-2.0
20+
21+
================================================================================
22+
OpenJDK (Java Runtime Environment)
23+
================================================================================
24+
License: GNU General Public License, version 2, with the Classpath Exception
25+
Source: https://openjdk.java.net/

README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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.

build.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# builds and pushs Go + JasperStarter base image
4+
5+
# config settings
6+
IMAGE_NAME="golang-jasper"
7+
VERSION="1.23-3.6.2"
8+
REGISTRY="carddev81/" # Set your registry here, e.g., "your-registry.com/"
9+
FULL_IMAGE_NAME="${REGISTRY}${IMAGE_NAME}:${VERSION}"
10+
11+
echo "Building ${FULL_IMAGE_NAME}..."
12+
docker build -t "${FULL_IMAGE_NAME}" .
13+
docker tag "${FULL_IMAGE_NAME}" "${REGISTRY}${IMAGE_NAME}:latest"
14+
15+
echo "Build completed!"
16+
echo "Image: ${FULL_IMAGE_NAME}"
17+
echo "Also tagged as: ${REGISTRY}${IMAGE_NAME}:latest"
18+
19+
read -p "Push to registry? (y/N): " -n 1 -r
20+
echo
21+
if [[ $REPLY =~ ^[Yy]$ ]]; then
22+
echo "Pushing ${FULL_IMAGE_NAME}..."
23+
docker push "${FULL_IMAGE_NAME}"
24+
25+
echo "Pushing ${REGISTRY}${IMAGE_NAME}:latest..."
26+
docker push "${REGISTRY}${IMAGE_NAME}:latest"
27+
28+
echo "Push completed!"
29+
else
30+
echo "Images built locally. Use 'docker push' to upload to registry when ready."
31+
fi
32+
33+
echo ""
34+
echo "To use this image in your Dockerfile:"
35+
echo "FROM ${FULL_IMAGE_NAME}"

0 commit comments

Comments
 (0)