From 0bf889b60aeea3e480dae4df8cf616ac368b1f0d Mon Sep 17 00:00:00 2001 From: Nick Dumas Date: Sat, 10 Jun 2023 12:16:19 -0400 Subject: [PATCH] Docker builds and makefile to match --- .drone.yml | 0 Dockerfile | 10 ++++++++++ Makefile | 17 +++++++++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 .drone.yml create mode 100644 Dockerfile diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..73ca74c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM golang:latest AS builder +ADD . /opt/obp +WORKDIR /opt/obp +# RUN go build -o baas cmd/main.go +RUN make alpine-binary + +FROM alpine:latest +RUN apk --no-cache add ca-certificates +COPY --from=builder /opt/obp/bin/obp-alpine /bin/obp +RUN chmod +x /bin/obp diff --git a/Makefile b/Makefile index ed76378..c24c0cf 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,24 @@ BINARY_NAME=obp -build-all: +docker: docker-image docker-push + +docker-push: + docker push code.ndumas.com/ndumas/obsidian-pipeline:latest + +docker-image: + docker build -t code.ndumas.com/ndumas/obsidian-pipeline:latest . + +alpine-binary: + CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o bin/${BINARY_NAME}-alpine cmd/obp/cmd/*.go + +build-all: alpine-binary GOOS=darwin GOARCH=amd64 go build -o bin/${BINARY_NAME}-darwin cmd/obp/*.go GOOS=linux GOARCH=amd64 go build -o bin/${BINARY_NAME}-linux cmd/obp/*.go GOOS=windows GOARCH=amd64 go build -o bin/${BINARY_NAME}-windows.exe cmd/obp/*.go clean-all: go clean - rm bin/${BINARY_NAME}-darwin - rm bin/${BINARY_NAME}-linux - rm bin/${BINARY_NAME}-windows.exe + rm -v bin/* test: go test ./...