aboutsummaryrefslogtreecommitdiff
path: root/Dockerfile
diff options
context:
space:
mode:
authortherealbobo2020-09-15 10:57:21 +0000
committertherealbobo2020-09-15 10:57:21 +0000
commit1bbb63b34e593267db4332e6b9b276289e4685c4 (patch)
treef114085d35d1c51bff6f962656af3903334221cc /Dockerfile
parent1e8a07f770c85a2ed6159798d1fb00dbebe08e98 (diff)
multistage build
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile26
1 files changed, 22 insertions, 4 deletions
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