From b0b3dc761bed7045d80996991f92de5599e904de Mon Sep 17 00:00:00 2001 From: Benjamin Schmid Date: Thu, 13 Aug 2020 20:36:42 +0200 Subject: [PATCH 1/3] build(Dockerfile): reduce image size from 2G GB to ~0.4GB This uses mulit-stage build to separate the build phase from the distribution image and signigicantly reduces images size. You can find more information on Docker multistage builds here: https://docs.docker.com/develop/develop-images/multistage-build/ --- Dockerfile | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index df24c9eb..632bbbae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.13-buster +FROM golang:1.13-buster AS buildcontainer ARG SIGNAL_CLI_VERSION=0.6.8 ARG SWAG_VERSION=1.6.7 @@ -29,10 +29,7 @@ RUN cd /tmp/ \ && git checkout v${SIGNAL_CLI_VERSION} \ && ./gradlew build \ && ./gradlew installDist \ - && ln -s /tmp/signal-cli-${SIGNAL_CLI_VERSION}/build/install/signal-cli/bin/signal-cli /usr/bin/signal-cli - -RUN mkdir -p /signal-cli-config/ -RUN mkdir -p /home/.local/share/signal-cli + && ln -s /tmp/signal-cli-${SIGNAL_CLI_VERSION}/build/install/signal-cli/ /tmp/signal-cli COPY src/api /tmp/signal-cli-rest-api-src/api COPY src/main.go /tmp/signal-cli-rest-api-src/ @@ -41,7 +38,15 @@ COPY src/go.sum /tmp/signal-cli-rest-api-src/ RUN cd /tmp/signal-cli-rest-api-src && swag init && go build -ENV PATH /tmp/signal-cli-rest-api-src/:/usr/bin/signal-cli-${SIGNAL_CLI_VERSION}/bin/:$PATH +# Start a fresh container for release container +FROM openjdk:11-slim + +COPY --from=buildcontainer /tmp/signal-cli-rest-api-src/signal-cli-rest-api /usr/bin/signal-cli-rest-api +COPY --from=buildcontainer /tmp/signal-cli /opt/signal-cli + +RUN ln -s /opt/signal-cli/bin/signal-cli /usr/bin/signal-cli +RUN mkdir -p /signal-cli-config/ +RUN mkdir -p /home/.local/share/signal-cli EXPOSE 8080 From a6e8cce641640708a5d373480f3c0a35f3a88305 Mon Sep 17 00:00:00 2001 From: Benjamin Schmid Date: Fri, 14 Aug 2020 10:46:36 +0200 Subject: [PATCH 2/3] build(Docker image): switch to JRE and Debian buster variant This should avoid potential issues in ARM environemnts with musl/alpine linux. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 632bbbae..53924311 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,7 @@ COPY src/go.sum /tmp/signal-cli-rest-api-src/ RUN cd /tmp/signal-cli-rest-api-src && swag init && go build # Start a fresh container for release container -FROM openjdk:11-slim +FROM openjdk:11-jre-slim-buster COPY --from=buildcontainer /tmp/signal-cli-rest-api-src/signal-cli-rest-api /usr/bin/signal-cli-rest-api COPY --from=buildcontainer /tmp/signal-cli /opt/signal-cli From c00480696d1e997f79f8b02da8be3c0a47d02883 Mon Sep 17 00:00:00 2001 From: Benjamin Schmid Date: Sun, 16 Aug 2020 11:49:46 +0200 Subject: [PATCH 3/3] build(Docker): switch to adoptopenjdk to support armv7 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 53924311..6d7d95d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,7 @@ COPY src/go.sum /tmp/signal-cli-rest-api-src/ RUN cd /tmp/signal-cli-rest-api-src && swag init && go build # Start a fresh container for release container -FROM openjdk:11-jre-slim-buster +FROM adoptopenjdk:11-jre-hotspot COPY --from=buildcontainer /tmp/signal-cli-rest-api-src/signal-cli-rest-api /usr/bin/signal-cli-rest-api COPY --from=buildcontainer /tmp/signal-cli /opt/signal-cli