First go at Docker builds
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
05c0e18c37
commit
1f6193e486
8
Dockerfile
Normal file
8
Dockerfile
Normal 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
23
Dockerfile.multi-stage
Normal 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" ]
|
10
Makefile
10
Makefile
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user