From 1bbb63b34e593267db4332e6b9b276289e4685c4 Mon Sep 17 00:00:00 2001 From: therealbobo Date: Tue, 15 Sep 2020 12:57:21 +0200 Subject: multistage build --- Dockerfile | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'Dockerfile') diff --git a/Dockerfile b/Dockerfile index 0092628..07f275e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,12 @@ -FROM ubuntu:20.04 +# BUILD STAGE +FROM ubuntu:20.04 AS BUILDSTAGE # Install tools and libraries -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -qq git golang-1.14 pkg-config libpcap-dev libhyperscan-dev yarnpkg +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -qq git golang-1.14 pkg-config libpcap-dev libhyperscan-dev yarnpkg curl RUN ln -sf ../lib/go-1.14/bin/go /usr/bin/go -ENV GIN_MODE release COPY . /caronte @@ -13,6 +14,23 @@ WORKDIR /caronte RUN go mod download && go build -RUN cd frontend && yarnpkg install && yarnpkg build +RUN cd frontend && \ + yarnpkg install && \ + yarnpkg build --production=true +RUN curl -sf https://gobinaries.com/tj/node-prune | sh && cd /caronte/frontend && node-prune + + +# LAST STAGE +FROM ubuntu:20.04 + +COPY --from=BUILDSTAGE /caronte /caronte + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -qq libpcap-dev libhyperscan-dev && \ + rm -rf /var/lib/apt/lists/* + +ENV GIN_MODE release + +WORKDIR /caronte CMD ./caronte -- cgit v1.2.3-70-g09d2 From 5a6f17b6439e42e829a9489575400492bcd10655 Mon Sep 17 00:00:00 2001 From: therealbobo Date: Tue, 15 Sep 2020 18:35:24 +0200 Subject: minor change --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Dockerfile') diff --git a/Dockerfile b/Dockerfile index 07f275e..e3c49bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,9 @@ RUN curl -sf https://gobinaries.com/tj/node-prune | sh && cd /caronte/frontend & # LAST STAGE FROM ubuntu:20.04 -COPY --from=BUILDSTAGE /caronte /caronte +COPY --from=BUILDSTAGE /caronte/caronte /caronte/caronte +COPY --from=BUILDSTAGE /caronte/frontend /caronte/frontend +COPY --from=BUILDSTAGE /caronte/shared /caronte/shared RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -qq libpcap-dev libhyperscan-dev && \ -- cgit v1.2.3-70-g09d2