0
0
Fork 0
mirror of https://github.com/crazy-max/diun.git synced 2025-01-12 19:48:12 +00:00
crazy-max_diun/Dockerfile
CrazyMax 599a52af0e
Go 1.15 (#218)
* Go 1.15
* Remove s390x arch

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2020-11-12 23:03:43 +00:00

38 lines
886 B
Docker

ARG GO_VERSION=1.15
ARG VERSION=dev
FROM --platform=${BUILDPLATFORM:-linux/amd64} tonistiigi/xx:golang AS xgo
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:${GO_VERSION}-alpine AS base
RUN apk add --no-cache curl gcc git musl-dev
COPY --from=xgo / /
WORKDIR /src
FROM base AS gomod
COPY . .
RUN go mod download
FROM gomod AS build
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG VERSION
ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.io,direct
RUN go build -ldflags "-w -s -X 'main.version=${VERSION}'" -v -o /opt/diun cmd/main.go
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:latest
LABEL maintainer="CrazyMax"
RUN apk --update --no-cache add \
ca-certificates \
libressl \
&& rm -rf /tmp/* /var/cache/apk/*
COPY --from=build /opt/diun /usr/local/bin/diun
RUN diun --version
ENV DIUN_DB_PATH="/data/diun.db"
VOLUME [ "/data" ]
ENTRYPOINT [ "diun" ]