Newer
Older
dockerfiles / gitbucket.dockerfile
Mark George on 14 Dec 2021 1 KB Add GitBucket
# A minimal GitBucket.
#
# Volumes:
#   /gitbucket - GitBucket persistent data.  Precreate to prevent Docker creating with root privs.
#   /opt/gitbucket - location of gitbucket.war (parent directory)
#
# Build with:
# >docker build .
#
# Run with:
# >docker run --detach --publish 8080:8080 --volume data_location:/gitbucket --volume war_location:/opt/gitbucket -e GITBUCKET_PREFIX=/prefix
#
# Configuration changes can be made via environment variables, so override by supplying -e parameters (or an env file).


# start with the Alpine Adoptium base
FROM eclipse-temurin:11-alpine as jre-build

# Java module dependencies found by unzipping WAR and running:
# jdeps --class-path 'WEB-INF/classes,WEB-INF/lib/*,.' -recursive -summary .

# generate a minimal JRE that includes only the necessary modules
RUN $JAVA_HOME/bin/jlink \
         --add-modules java.base,java.desktop,java.instrument,java.logging,java.management,java.naming,java.security.jgss,java.sql,java.xml \
         --strip-debug \
         --no-man-pages \
         --no-header-files \
         --compress=2 \
         --output /jre

FROM alpine:3.15

### COPY GENERATED JRE ###

ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"
COPY --from=jre-build /jre $JAVA_HOME

### INSTALL DEPENDENCIES ###

# font support needed for generating avatar icons, curl needed for healthcheck
RUN apk add --no-cache fontconfig ttf-opensans curl

### DEPLOY APPLICATION ###

#RUN mkdir /opt/gitbucket
#COPY gitbucket.war /opt/gitbucket

RUN addgroup gitbucket && adduser -D -G gitbucket gitbucket
USER gitbucket

ENV \
	GITBUCKET_HOME=/gitbucket/gitbucket-data \
	GITBUCKET_PORT=8080 \
	GITBUCKET_PREFIX="" \
	GITBUCKET_PLUGINDIR="" \
	GITBUCKET_TMPDIR=""

EXPOSE 8080/tcp

HEALTHCHECK --interval=5m --timeout=5s CMD curl --fail http://localhost:8080/ || exit 1

CMD ["/opt/java/openjdk/bin/java", "-Xms128m", "-Xms512m", "-jar", "/opt/gitbucket/gitbucket.war"]