From 44148ed79d3156f00f2c701f2c2a213d58d14655 Mon Sep 17 00:00:00 2001 From: Samir Patel <48686912+54mir@users.noreply.github.com> Date: Wed, 20 Oct 2021 12:21:05 -0500 Subject: [PATCH] Build featurebase docker image in CI. Add to registry. --- .gitlab/.gitlab-ci.yml | 26 +++++++++++---------- .gitlab/Dockerfile | 51 ++++++++---------------------------------- 2 files changed, 23 insertions(+), 54 deletions(-) diff --git a/.gitlab/.gitlab-ci.yml b/.gitlab/.gitlab-ci.yml index cbb7eeffb..cda5430cc 100644 --- a/.gitlab/.gitlab-ci.yml +++ b/.gitlab/.gitlab-ci.yml @@ -4,7 +4,7 @@ include: - template: Security/Dependency-Scanning.gitlab-ci.yml variables: - GO_VERSION: 1.16.3 + GOVERSION: "1.16.3" stages: - test @@ -126,18 +126,20 @@ build for darwin arm64: paths: - featurebase_darwin_arm64 -# Build a Docker image with CI/CD and push to the GitLab registry. +# Build a FB Docker image with CI/CD and push to the GitLab registry. build container fb: - image: docker:latest + image: docker:stable stage: build - services: - - docker:dind - script: - - | - docker build - --build-arg GO_VERSION=$(GO_VERSION) - --tag featurebase:$(VERSION) . - - docker push "$CI_REGISTRY_IMAGE${tag}" - - @echo Created docker image: featurebase:$(VERSION) + needs: + - "build for linux amd64" + tags: + - shell + before_script: + - echo "${DOCKER_DEPLOY_TOKEN}" | docker login -u ${DOCKER_DEPLOY_USER} --password-stdin ${CI_REGISTRY} + script: + - tag=${CI_REGISTRY_IMAGE}/server:${CI_COMMIT_REF_SLUG} + - docker build --build-arg GO_VERSION=$GOVERSION -t $tag -f .gitlab/Dockerfile . + - docker push $tag + - echo Created docker featurebase image with tag "$tag" diff --git a/.gitlab/Dockerfile b/.gitlab/Dockerfile index 115855034..b22392ce1 100644 --- a/.gitlab/Dockerfile +++ b/.gitlab/Dockerfile @@ -1,50 +1,17 @@ -ARG GO_VERSION=latest - -####################### -### Lattice builder ### -####################### - -FROM moleculacorp/nodejs:latest as lattice-builder -WORKDIR /lattice - -COPY lattice/package.json ./ -COPY lattice/yarn.lock ./ -RUN yarn install - -COPY lattice ./ -RUN yarn build - -###################### -### Pilosa builder ### -###################### - -FROM golang:${GO_VERSION} as pilosa-builder -ARG MAKE_FLAGS -WORKDIR /pilosa - -RUN go get github.com/rakyll/statik - -COPY . ./ -COPY --from=lattice-builder /lattice/build /lattice -RUN /go/bin/statik -src=/lattice -dest=/pilosa - -RUN make build FLAGS="-o build/featurebase" ${MAKE_FLAGS} - -##################### -### Pilosa runner ### -##################### - -FROM alpine:3.13.2 as runner +FROM alpine:3.14.2 LABEL maintainer "dev@molecula.com" +LABEL org.opencontainers.image.authors="dev@molecula.com" + +WORKDIR /featurebase RUN apk add --no-cache curl jq -COPY --from=pilosa-builder /pilosa/build/featurebase / - -COPY LICENSE /LICENSE -COPY NOTICE /NOTICE +COPY LICENSE . +COPY NOTICE . +COPY featurebase_linux_amd64 . +RUN chmod ugo+x . EXPOSE 10101 VOLUME /data @@ -53,4 +20,4 @@ ENV PILOSA_BIND 0.0.0.0:10101 ENV PILOSA_BIND_GRPC 0.0.0.0:20101 ENTRYPOINT ["/featurebase"] -CMD ["server"] +CMD ["server"] \ No newline at end of file