Skip to content

Commit cab363a

Browse files
committed
✨ Enhance Dockerfiles with metadata labels and optimize image size
1 parent 276d47f commit cab363a

File tree

4 files changed

+72
-11
lines changed

4 files changed

+72
-11
lines changed

core/Dockerfile

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
1-
FROM eclipse-temurin:21-jre
1+
ARG ECLIPSE_TEMURIN_JRE=21-jre
2+
FROM eclipse-temurin:${ECLIPSE_TEMURIN_JRE}
23

4+
LABEL org.opencontainers.image.title="RESTHeart"
5+
LABEL org.opencontainers.image.description="RESTHeart is Java Framework, built on top of Undertow"
6+
LABEL org.opencontainers.image.url="https://restheart.org"
7+
LABEL org.opencontainers.image.licenses="AGPL-3.0, Apache-2.0"
8+
LABEL org.opencontainers.image.authors="SoftInstigate <[email protected]>"
9+
LABEL org.opencontainers.image.vendor="SoftInstigate"
10+
LABEL org.opencontainers.image.source="https://github.com/SoftInstigate/restheart"
11+
LABEL org.opencontainers.image.documentation="https://restheart.org/docs"
312
LABEL maintainer="SoftInstigate <[email protected]>"
413

14+
# Reduce image size by removing package lists after installation
515
RUN apt-get update && \
6-
apt-get --no-install-recommends install -y && \
7-
apt-get clean
16+
apt-get upgrade -y && \
17+
apt-get clean && \
18+
rm -rf /var/lib/apt/lists/*
819

920
WORKDIR /opt/restheart
10-
COPY target/restheart.jar ./restheart.jar
21+
22+
# Copy the executable jar and the required libraries
23+
COPY target/restheart.jar ./restheart.jarq
1124
COPY target/lib/*.jar lib/
1225
COPY target/plugins/*.jar plugins/
1326
COPY target/plugins/lib/*.jar plugins/lib/
1427

28+
# Set environment variables
1529
ENV RHO='/mclient/connection-string->"mongodb://host.docker.internal";/http-listener/host->"0.0.0.0"'
30+
1631
ENTRYPOINT [ "java", "-Dfile.encoding=UTF-8", "-server", "-jar", "restheart.jar" ]
1732
EXPOSE 8009 8080 4443

core/Dockerfile.distroless

+12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
FROM gcr.io/distroless/java21-debian12:latest
22

3+
LABEL org.opencontainers.image.title="RESTHeart distroless"
4+
LABEL org.opencontainers.image.description="RESTHeart is Java Framework, built on top of Undertow"
5+
LABEL org.opencontainers.image.url="https://restheart.org"
6+
LABEL org.opencontainers.image.licenses="AGPL-3.0, Apache-2.0"
7+
LABEL org.opencontainers.image.authors="SoftInstigate <[email protected]>"
8+
LABEL org.opencontainers.image.vendor="SoftInstigate"
9+
LABEL org.opencontainers.image.source="https://github.com/SoftInstigate/restheart"
10+
LABEL org.opencontainers.image.documentation="https://restheart.org/docs"
311
LABEL maintainer="SoftInstigate <[email protected]>"
412

513
WORKDIR /opt/restheart
14+
15+
# Copy the executable jar and the required libraries
616
COPY target/restheart.jar ./restheart.jar
717
COPY target/lib/*.jar lib/
818
COPY target/plugins/*.jar plugins/
919
COPY target/plugins/lib/*.jar plugins/lib/
1020

21+
# Set environment variables
1122
ENV RHO='/mclient/connection-string->"mongodb://host.docker.internal";/http-listener/host->"0.0.0.0"'
23+
1224
ENTRYPOINT [ "java", "-Dfile.encoding=UTF-8", "-server", "-jar", "restheart.jar" ]
1325
EXPOSE 8009 8080 4443

core/Dockerfile.graalvm

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
1-
FROM softinstigate/graalvm:21.0.2-graalce
1+
ARG GRAALVM_VERSION=21.0.2-graalce
2+
FROM softinstigate/graalvm:${GRAALVM_VERSION}
23

4+
LABEL org.opencontainers.image.title="RESTHeart GraalVM"
5+
LABEL org.opencontainers.image.description="RESTHeart is Java Framework, built on top of Undertow"
6+
LABEL org.opencontainers.image.url="https://restheart.org"
7+
LABEL org.opencontainers.image.licenses="AGPL-3.0, Apache-2.0"
8+
LABEL org.opencontainers.image.authors="SoftInstigate <[email protected]>"
9+
LABEL org.opencontainers.image.vendor="SoftInstigate"
10+
LABEL org.opencontainers.image.source="https://github.com/SoftInstigate/restheart"
11+
LABEL org.opencontainers.image.documentation="https://restheart.org/docs"
312
LABEL maintainer="SoftInstigate <[email protected]>"
413

514
WORKDIR /opt/restheart
15+
16+
# Copy the executable jar and the required libraries
617
COPY target/restheart.jar ./restheart.jar
718
COPY target/lib/*.jar lib/
819
COPY target/plugins/*.jar plugins/
920
COPY target/plugins/lib/*.jar plugins/lib/
1021

22+
# Install SDKMAN
1123
SHELL ["/bin/bash", "-i", "-c"]
12-
1324
RUN bash -c "source $HOME/.sdkman/bin/sdkman-init.sh"
1425
ENV PATH="/root/.sdkman/candidates/java/current/bin:$PATH"
1526

27+
# set environment variables
1628
ENV RHO='/mclient/connection-string->"mongodb://host.docker.internal";/http-listener/host->"0.0.0.0"'
29+
1730
ENTRYPOINT [ "java", "-Dfile.encoding=UTF-8", "-server", "-jar", "restheart.jar" ]
1831
EXPOSE 8009 8080 4443

core/Dockerfile.native

+26-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
1-
FROM debian:12.10-slim
1+
ARG DEBIAN_VERSION=12.10-slim
2+
FROM debian:${DEBIAN_VERSION}
23

4+
LABEL org.opencontainers.image.title="RESTHeart native"
5+
LABEL org.opencontainers.image.description="RESTHeart is Java Framework, built on top of Undertow"
6+
LABEL org.opencontainers.image.url="https://restheart.org"
7+
LABEL org.opencontainers.image.licenses="AGPL-3.0, Apache-2.0"
8+
LABEL org.opencontainers.image.authors="SoftInstigate <[email protected]>"
9+
LABEL org.opencontainers.image.vendor="SoftInstigate"
10+
LABEL org.opencontainers.image.source="https://github.com/SoftInstigate/restheart"
11+
LABEL org.opencontainers.image.documentation="https://restheart.org/docs"
312
LABEL maintainer="SoftInstigate <[email protected]>"
413

14+
# Reduce image size by removing package lists after installation
15+
RUN apt-get update && \
16+
apt-get upgrade -y && \
17+
apt-get clean && \
18+
rm -rf /var/lib/apt/lists/*
19+
520
WORKDIR /opt/restheart
6-
COPY target/restheart .
7-
RUN chmod +x restheart && mkdir etc plugins
821

22+
# Copy only the executable binary
23+
COPY target/restheart ./restheart
24+
25+
# Create required directories and set permissions in one layer
26+
RUN chmod +x restheart && mkdir -p etc plugins
27+
28+
# Set environment variables
929
ENV RHO='/mclient/connection-string->"mongodb://host.docker.internal";/http-listener/host->"0.0.0.0"'
10-
ENTRYPOINT [ "./restheart" ]
11-
EXPOSE 8009 8080 4443
30+
31+
EXPOSE 8009 8080 4443
32+
ENTRYPOINT ["./restheart"]

0 commit comments

Comments
 (0)