Skip to content

Commit

Permalink
Updated Dockerfile and fixed base image
Browse files Browse the repository at this point in the history
  • Loading branch information
namedgraph committed Jan 14, 2025
1 parent 67596ad commit 2b6f028
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -17,8 +17,9 @@

## This Dockefile builds a reduced footprint container.

ARG OPENJDK_VERSION=21
ARG ALPINE_VERSION=3.15.0
ARG JAVA_VERSION=21

ARG ALPINE_VERSION=3.17.1
ARG JENA_VERSION=4.7.0

# Internal, passed between stages.
Expand All @@ -27,7 +28,7 @@ ARG FUSEKI_JAR=jena-fuseki-server-${JENA_VERSION}.jar
ARG JAVA_MINIMAL=/opt/java-minimal

## ---- Stage: Download and build java.
FROM openjdk:${OPENJDK_VERSION}-alpine AS base
FROM eclipse-temurin:${JAVA_VERSION}-alpine AS base

ARG JAVA_MINIMAL
ARG JENA_VERSION
Expand Down Expand Up @@ -71,12 +72,6 @@ RUN \
ADD entrypoint.sh .
ADD log4j2.properties .

# Run as this user
# -H : no home directorry
# -D : no password

RUN adduser -H -D fuseki fuseki

## ---- Stage: Build runtime
FROM alpine:${ALPINE_VERSION}

Expand All @@ -88,18 +83,32 @@ ARG FUSEKI_JAR

COPY --from=base /opt/java-minimal /opt/java-minimal
COPY --from=base /fuseki /fuseki
COPY --from=base /etc/passwd /etc/passwd

WORKDIR $FUSEKI_DIR

ARG LOGS=${FUSEKI_DIR}/logs
ARG DATA=${FUSEKI_DIR}/databases

ARG JENA_USER=fuseki
ARG JENA_GROUP=$JENA_USER
ARG JENA_GID=1000
ARG JENA_UID=1000

# Run as this user
# -H : no home directory
# -D : no password
RUN addgroup -g "${JENA_GID}" "${JENA_GROUP}" && \
adduser "${JENA_USER}" -G "${JENA_GROUP}" -s /bin/ash -u "${JENA_UID}" -H -D

RUN mkdir --parents "${FUSEKI_DIR}" && \
chown -R $JENA_USER ${FUSEKI_DIR}

USER $JENA_USER

RUN \
mkdir -p $LOGS && \
mkdir -p $DATA && \
chown -R fuseki ${FUSEKI_DIR} && \
chmod a+x entrypoint.sh
chmod a+x entrypoint.sh

## Default environment variables.
ENV \
Expand All @@ -109,8 +118,6 @@ ENV \
FUSEKI_JAR="${FUSEKI_JAR}" \
FUSEKI_DIR="${FUSEKI_DIR}"

USER fuseki

EXPOSE 3030

ENTRYPOINT ["./entrypoint.sh" ]
Expand Down

0 comments on commit 2b6f028

Please sign in to comment.