First go at Docker builds
continuous-integration/drone/push Build is passing Details

This commit is contained in:
IamTheFij 2019-10-10 17:20:42 -07:00
parent 05c0e18c37
commit 1f6193e486
3 changed files with 41 additions and 0 deletions

8
Dockerfile Normal file
View File

@ -0,0 +1,8 @@
ARG REPO=library
FROM ${REPO}/busybox:latest
WORKDIR /root/
ARG ARCH=amd64
COPY ./minitor-go ./minitor
ENTRYPOINT [ "./minitor" ]

23
Dockerfile.multi-stage Normal file
View File

@ -0,0 +1,23 @@
ARG REPO=library
FROM golang:1.12-alpine AS builder
RUN apk add --no-cache git
RUN mkdir /app
WORKDIR /app
COPY ./go.mod ./go.sum /app/
RUN go mod download
COPY ./*.go /app/
ARG ARCH=amd64
ARG VERSION=dev
ENV CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH}
RUN go build -ldflags "-X main.version=${VERSION}" -a -installsuffix nocgo -o minitor .
FROM ${REPO}/busybox:latest
WORKDIR /root/
COPY --from=builder /app/minitor .
ENTRYPOINT [ "./minitor" ]

View File

@ -1,3 +1,5 @@
DOCKER_TAG ?= minitor-go-${USER}
.PHONY: test
default: test
@ -27,3 +29,11 @@ test:
clean:
rm -f ./minitor-go
rm -f ./coverage.out
.PHONY: docker-build
docker-build:
docker build -f ./Dockerfile.multi-stage -t $(DOCKER_TAG) .
.PHONY: docker-run
docker-run: docker-build
docker run --rm -v $(shell pwd)/config.yml:/root/config.yml $(DOCKER_TAG)