[#570] Fix docker image builds

- Moving to Alpine as a base image
- Fix dirty image build
- Fix version format to match neofs-node

Signed-off-by: Stanislav Bogatyrev <stanislav@nspcc.ru>
This commit is contained in:
Stanislav Bogatyrev 2022-07-05 14:19:09 +03:00 committed by Stanislav Bogatyrev
parent 5bfc549746
commit aaddc0a1f7
3 changed files with 21 additions and 16 deletions

View file

@ -1,25 +1,21 @@
FROM golang:1 as builder FROM golang:1.17 as builder
WORKDIR /src
RUN set -x \
&& apt update \
&& apt install -y make
COPY . /src
ARG BUILD=now
ARG REPO=github.com/nspcc-dev/neofs-s3-gw ARG REPO=github.com/nspcc-dev/neofs-s3-gw
ARG VERSION=dev ARG VERSION=dev
RUN set -x && make -o dep # run make without dep dependency WORKDIR /src
COPY . /src
RUN make
# Executable image # Executable image
FROM scratch FROM alpine AS neofs-s3-gw
RUN apk add --no-cache bash ca-certificates
WORKDIR / WORKDIR /
COPY --from=builder /src/bin/neofs-s3-gw /bin/neofs-s3-gw COPY --from=builder /src/bin/neofs-s3-gw /bin/neofs-s3-gw
COPY --from=builder /src/bin/neofs-s3-authmate /bin/neofs-s3-authmate COPY --from=builder /src/bin/neofs-s3-authmate /bin/neofs-s3-authmate
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
ENTRYPOINT ["/bin/neofs-s3-gw"] ENTRYPOINT ["/bin/neofs-s3-gw"]

9
.docker/Dockerfile.dirty Normal file
View file

@ -0,0 +1,9 @@
FROM alpine AS neofs-s3-gw
RUN apk add --no-cache bash ca-certificates
WORKDIR /
COPY /bin/neofs-s3-gw /bin/neofs-s3-gw
COPY /bin/neofs-s3-authmate /bin/neofs-s3-authmate
ENTRYPOINT ["/bin/neofs-s3-gw"]

View file

@ -2,7 +2,7 @@
# Common variables # Common variables
REPO ?= $(shell go list -m) REPO ?= $(shell go list -m)
VERSION ?= $(shell git describe --tags 2>/dev/null || cat VERSION 2>/dev/null || echo "develop") VERSION ?= $(shell git describe --tags --dirty --always 2>/dev/null || cat VERSION 2>/dev/null || echo "develop")
GO_VERSION ?= 1.17 GO_VERSION ?= 1.17
LINT_VERSION ?= 1.46.2 LINT_VERSION ?= 1.46.2
BINDIR = bin BINDIR = bin
@ -67,13 +67,13 @@ format:
@gofmt -s -w ./ @gofmt -s -w ./
# Build clean Docker image # Build clean Docker image
image: dep image:
@echo "⇒ Build NeoFS S3 Gateway docker image " @echo "⇒ Build NeoFS S3 Gateway docker image "
@docker build \ @docker build \
--build-arg REPO=$(REPO) \ --build-arg REPO=$(REPO) \
--build-arg VERSION=$(VERSION) \ --build-arg VERSION=$(VERSION) \
--rm \ --rm \
-f Dockerfile \ -f .docker/Dockerfile \
-t $(HUB_IMAGE):$(HUB_TAG) . -t $(HUB_IMAGE):$(HUB_TAG) .
# Push Docker image to the hub # Push Docker image to the hub
@ -88,7 +88,7 @@ dirty-image:
--build-arg REPO=$(REPO) \ --build-arg REPO=$(REPO) \
--build-arg VERSION=$(VERSION) \ --build-arg VERSION=$(VERSION) \
--rm \ --rm \
-f Dockerfile.dirty \ -f .docker/Dockerfile.dirty \
-t $(HUB_IMAGE)-dirty:$(HUB_TAG) . -t $(HUB_IMAGE)-dirty:$(HUB_TAG) .
# Run linters # Run linters