Skip to content

Commit 524939d

Browse files
author
Bernhard B
authored
Merge pull request #27 from bentolor/build/reduce-image-size
build(Dockerfile): reduce image size from 2G GB to ~0.4GB
2 parents 4e4829b + c004806 commit 524939d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Dockerfile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.13-buster
1+
FROM golang:1.13-buster AS buildcontainer
22

33
ARG SIGNAL_CLI_VERSION=0.6.8
44
ARG SWAG_VERSION=1.6.7
@@ -29,10 +29,7 @@ RUN cd /tmp/ \
2929
&& git checkout v${SIGNAL_CLI_VERSION} \
3030
&& ./gradlew build \
3131
&& ./gradlew installDist \
32-
&& ln -s /tmp/signal-cli-${SIGNAL_CLI_VERSION}/build/install/signal-cli/bin/signal-cli /usr/bin/signal-cli
33-
34-
RUN mkdir -p /signal-cli-config/
35-
RUN mkdir -p /home/.local/share/signal-cli
32+
&& ln -s /tmp/signal-cli-${SIGNAL_CLI_VERSION}/build/install/signal-cli/ /tmp/signal-cli
3633

3734
COPY src/api /tmp/signal-cli-rest-api-src/api
3835
COPY src/main.go /tmp/signal-cli-rest-api-src/
@@ -41,7 +38,15 @@ COPY src/go.sum /tmp/signal-cli-rest-api-src/
4138

4239
RUN cd /tmp/signal-cli-rest-api-src && swag init && go build
4340

44-
ENV PATH /tmp/signal-cli-rest-api-src/:/usr/bin/signal-cli-${SIGNAL_CLI_VERSION}/bin/:$PATH
41+
# Start a fresh container for release container
42+
FROM adoptopenjdk:11-jre-hotspot
43+
44+
COPY --from=buildcontainer /tmp/signal-cli-rest-api-src/signal-cli-rest-api /usr/bin/signal-cli-rest-api
45+
COPY --from=buildcontainer /tmp/signal-cli /opt/signal-cli
46+
47+
RUN ln -s /opt/signal-cli/bin/signal-cli /usr/bin/signal-cli
48+
RUN mkdir -p /signal-cli-config/
49+
RUN mkdir -p /home/.local/share/signal-cli
4550

4651
EXPOSE 8080
4752

0 commit comments

Comments
 (0)