ADD build files
This commit is contained in:
parent
aaa01de15c
commit
788707b163
14
Dockerfile
Normal file
14
Dockerfile
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
FROM golang:latest as builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY . .
|
||||||
|
RUN go mod download && go mod tidy
|
||||||
|
|
||||||
|
RUN go build -o ./bin/us-dop-bot ./cmd/bot
|
||||||
|
|
||||||
|
FROM debian:unstable-slim
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get install -y ca-certificates
|
||||||
|
|
||||||
|
COPY --from=builder /app/bin/us-dop-bot /app/us-dop-bot
|
||||||
|
WORKDIR /app
|
||||||
|
CMD ["/app/us-dop-bot"]
|
||||||
61
Makefile
Normal file
61
Makefile
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# must create a .env file with info
|
||||||
|
# must have compose installed
|
||||||
|
include .env
|
||||||
|
export
|
||||||
|
OS:=${shell go env GOOS}
|
||||||
|
ARCH=$(shell go env GOARCH)
|
||||||
|
OOSS="linux"
|
||||||
|
ARRCHS="arm 386"
|
||||||
|
DEBUG=1
|
||||||
|
SERVICE=us-dop-bot
|
||||||
|
VERSION=0.0.0_1
|
||||||
|
BINAME=$(SERVICE)-$(OS)-$(ARCH)-$(VERSION)
|
||||||
|
BINAMEARM=$(SERVICE)-$(OS)-arm64-$(VERSION)
|
||||||
|
# can be docker or podman or whatever
|
||||||
|
CONTAINERS=docker
|
||||||
|
COMPOSE=$(CONTAINERS)-compose
|
||||||
|
# Configure local registry
|
||||||
|
REGADDR=192.168.0.151:32000
|
||||||
|
K8SRSNAME=$(shell kubectl get rs --no-headers -o custom-columns=":metadata.name" | grep us-dop-bot)
|
||||||
|
.phony: all clean build test clean-image build-image build-image-debug run-image run-image-debug run-local
|
||||||
|
|
||||||
|
|
||||||
|
build-image:
|
||||||
|
# here we made the images and push to registry with buildx
|
||||||
|
@$(CONTAINERS) buildx build --platform linux/arm64 --push -t $(REGADDR)/us-dop-bot:latest .
|
||||||
|
# Here we upload it to local
|
||||||
|
|
||||||
|
run-image: build-image
|
||||||
|
@$(CONTAINERS) compose -f docker-compose.yaml up
|
||||||
|
|
||||||
|
build-image-debug: clean
|
||||||
|
@$(CONTAINERS) compose -f docker-compose-debug.yaml build
|
||||||
|
|
||||||
|
run-image-debug: build-image-debug
|
||||||
|
@$(CONTAINERS) compose -f docker-compose-debug.yaml up
|
||||||
|
|
||||||
|
run-local:clean build
|
||||||
|
@bin/$(BINAME)
|
||||||
|
|
||||||
|
build:
|
||||||
|
#@mkdir dolardb
|
||||||
|
@env GOOS=$(OS) GOARCH=$(arch) go build -o ./bin/$(BINAME) ./cmd/bot/.
|
||||||
|
@env GOOS=$(OS) GOARCH=arm64 go build -o ./bin/$(BINAMEARM) ./cmd/bot/.
|
||||||
|
|
||||||
|
create-descriptors:
|
||||||
|
@envsubst < k8s/deployment.yml.template > k8s/deployment.yml
|
||||||
|
|
||||||
|
deploy: build-image create-descriptors
|
||||||
|
@kubectl apply -f k8s/deployment.yml
|
||||||
|
@kubectl scale rs $(K8SRSNAME) --replicas=0
|
||||||
|
@kubectl scale rs $(K8SRSNAME) --replicas=1
|
||||||
|
|
||||||
|
test:
|
||||||
|
@go -count=1 test ./...
|
||||||
|
clean:
|
||||||
|
@rm -rf ./bin
|
||||||
|
|
||||||
|
clean-image:
|
||||||
|
@$(CONTAINERS) system prune -f
|
||||||
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user