From 1f40425b04f3c86ca8401942d66b1ad1739b472a Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Wed, 28 Jul 2021 11:23:40 +0200 Subject: Add deploy workflow. Update Dockerfile --- Dockerfile | 52 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 18 deletions(-) (limited to 'Dockerfile') diff --git a/Dockerfile b/Dockerfile index a9c8134..4fb71a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,54 @@ -# BUILD STAGE -FROM ubuntu:20.04 AS BUILDSTAGE +# Build backend with go +FROM golang:1.16 AS BACKEND_BUILDER # 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 - -COPY . /caronte + DEBIAN_FRONTEND=noninteractive apt-get install -qq \ + git \ + pkg-config \ + libpcap-dev \ + libhyperscan-dev WORKDIR /caronte -RUN ln -sf ../lib/go-1.14/bin/go /usr/bin/go && \ - export VERSION=$(git describe --tags) && \ +COPY . ./ + +RUN export VERSION=$(git describe --tags --abbrev=0) && \ go mod download && \ go build -ldflags "-X main.Version=$VERSION" && \ - cd frontend && \ - yarnpkg install && \ - yarnpkg build --production=true && \ - cd - && \ - mkdir -p /caronte-build/frontend && \ - cp -r caronte pcaps/ scripts/ shared/ test_data/ /caronte-build && \ - cp -r frontend/build/ /caronte-build/frontend + mkdir -p build && \ + cp -r caronte pcaps/ scripts/ shared/ test_data/ build/ + + +# Build frontend via yarn +FROM node:16 as FRONTEND_BUILDER + +WORKDIR /caronte-frontend + +COPY ./frontend ./ + +RUN yarnpkg install && yarnpkg build --production=true # LAST STAGE FROM ubuntu:20.04 -COPY --from=BUILDSTAGE /caronte-build /caronte +COPY --from=BACKEND_BUILDER /caronte/build /opt/caronte + +COPY --from=FRONTEND_BUILDER /caronte-frontend/build /opt/caronte/frontend/build RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -qq libpcap-dev libhyperscan-dev && \ + DEBIAN_FRONTEND=noninteractive apt-get install -qq \ + libpcap-dev \ + libhyperscan-dev && \ rm -rf /var/lib/apt/lists/* ENV GIN_MODE release -WORKDIR /caronte +ENV MONGO_HOST mongo + +ENV MONGO_PORT 27017 + +WORKDIR /opt/caronte -CMD ./caronte +ENTRYPOINT ./caronte -mongo-host ${MONGO_HOST} -mongo-port ${MONGO_PORT} -assembly_memuse_log -- cgit v1.2.3-70-g09d2 From 489ae5c7c65e7f60c3a0e5dc86b1e669e7bf67b5 Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Wed, 28 Jul 2021 13:00:36 +0200 Subject: Update test backend dockerfile --- .github/docker/Dockerfile-backend | 5 ++--- Dockerfile | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'Dockerfile') diff --git a/.github/docker/Dockerfile-backend b/.github/docker/Dockerfile-backend index 06036e4..82ed29f 100644 --- a/.github/docker/Dockerfile-backend +++ b/.github/docker/Dockerfile-backend @@ -11,8 +11,7 @@ WORKDIR /caronte COPY . ./ -RUN export VERSION=$(git describe --tags --abbrev=0) && \ - go mod download && \ - go build -ldflags "-X main.Version=$VERSION" +RUN go mod download && \ + go build ENTRYPOINT go test -v -race -covermode=atomic diff --git a/Dockerfile b/Dockerfile index 4fb71a3..0573a6c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,7 @@ WORKDIR /caronte-frontend COPY ./frontend ./ -RUN yarnpkg install && yarnpkg build --production=true +RUN yarn install && yarn build --production=true # LAST STAGE -- cgit v1.2.3-70-g09d2