ARG GO_VERSION=1.27
ARG RDF4J_VERSION=latest


FROM golang:${GO_VERSION} AS builder
WORKDIR /src
COPY cmd/ ./
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /out/entrypoint ./entrypoint \
 && CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /out/healthcheck ./healthcheck

FROM eclipse/rdf4j-workbench:${RDF4J_VERSION}

ENV RDF4J_REPOSITORY="default" \
    RDF4J_REPOSITORY_LABEL="Automatically created Repository"
COPY --from=builder /out/entrypoint /out/healthcheck /

EXPOSE 8080

VOLUME /var/rdf4j
VOLUME /usr/local/tomcat/logs

ENTRYPOINT [ "/entrypoint" ]
CMD [ "catalina.sh", "run" ]

COPY ROOT /usr/local/tomcat/webapps/ROOT

HEALTHCHECK --interval=1m --timeout=5s --start-period=30s --start-interval=5s --retries=3 CMD [ "/healthcheck" ]

# spellchecker:words ldflags GOOS