Add example compose
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
IamTheFij 2020-08-07 16:00:19 -07:00
parent 916e518f5b
commit 5c5fda3ddf
3 changed files with 35 additions and 7 deletions

View File

@ -4,11 +4,13 @@ GIT_TAG_NAME := $(shell git tag -l --contains HEAD)
GIT_SHA := $(shell git rev-parse HEAD) GIT_SHA := $(shell git rev-parse HEAD)
VERSION := $(if $(GIT_TAG_NAME),$(GIT_TAG_NAME),$(GIT_SHA)) VERSION := $(if $(GIT_TAG_NAME),$(GIT_TAG_NAME),$(GIT_SHA))
GOFILES = *.go go.mod go.sum
.PHONY: default .PHONY: default
default: build default: build
# Downloads dependencies into vendor directory # Downloads dependencies into vendor directory
vendor: vendor: $(GOFILES)
go mod vendor go mod vendor
# Runs the application, useful while developing # Runs the application, useful while developing
@ -34,7 +36,7 @@ check:
pre-commit run --all-files pre-commit run --all-files
# Output target # Output target
dockron: dockron: $(GOFILES)
@echo Version: $(VERSION) @echo Version: $(VERSION)
go build -ldflags '-X "main.version=${VERSION}"' -o dockron go build -ldflags '-X "main.version=${VERSION}"' -o dockron
@ -42,22 +44,22 @@ dockron:
.PHONY: build .PHONY: build
build: dockron build: dockron
dockron-darwin-amd64: dockron-darwin-amd64: $(GOFILES)
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 \ GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 \
go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \ go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \
-o dockron-darwin-amd64 -o dockron-darwin-amd64
dockron-linux-amd64: dockron-linux-amd64: $(GOFILES)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \ go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \
-o dockron-linux-amd64 -o dockron-linux-amd64
dockron-linux-arm: dockron-linux-arm: $(GOFILES)
GOOS=linux GOARCH=arm CGO_ENABLED=0 \ GOOS=linux GOARCH=arm CGO_ENABLED=0 \
go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \ go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \
-o dockron-linux-arm -o dockron-linux-arm
dockron-linux-arm64: dockron-linux-arm64: $(GOFILES)
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 \ GOOS=linux GOARCH=arm64 CGO_ENABLED=0 \
go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \ go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \
-o dockron-linux-arm64 -o dockron-linux-arm64
@ -124,3 +126,9 @@ docker-staged-build-arm64:
docker build --build-arg VERSION=${VERSION} \ docker build --build-arg VERSION=${VERSION} \
--build-arg REPO=arm64v8 --build-arg ARCH=arm64 -t ${DOCKER_TAG}-linux-arm64 \ --build-arg REPO=arm64v8 --build-arg ARCH=arm64 -t ${DOCKER_TAG}-linux-arm64 \
-f Dockerfile.multi-stage . -f Dockerfile.multi-stage .
.PHONY: docker-example
docker-example:
# Uses multistage
docker-compose build
docker-compose up

View File

@ -28,7 +28,7 @@ From either an `amd64`, `arm`, or `arm64` machine, you can run Dockron using:
First, be sure your container is something that is not long running and will actually exit when complete. This is for batch runs and not keeping a service running. Docker should be able to do that on it's own with a restart policy. First, be sure your container is something that is not long running and will actually exit when complete. This is for batch runs and not keeping a service running. Docker should be able to do that on it's own with a restart policy.
Create your container and add a label in the form `dockron.schedule="* * * * *"`, where the value is a valid cron expression (See the section [Cron Expression Formatting](#cron-expression-formatting)). Create your container and add a label in the form `'dockron.schedule=* * * * *'`, where the value is a valid cron expression (See the section [Cron Expression Formatting](#cron-expression-formatting)).
Dockron will now start that container peridically on the schedule. Dockron will now start that container peridically on the schedule.
@ -53,3 +53,5 @@ Either use a separate tool in conjunction with Dockron, or use a more robust sch
## Building ## Building
If you have go on your machine, you can simply use `make build` or `make run` to build and test Dockron. If you don't have go but you do have Docker, you can still build docker images using the provide multi-stage Dockerfile! You can kick that off with `make docker-staged-build` If you have go on your machine, you can simply use `make build` or `make run` to build and test Dockron. If you don't have go but you do have Docker, you can still build docker images using the provide multi-stage Dockerfile! You can kick that off with `make docker-staged-build`
There is also an example `docker-compose.yml` that will use the multi-stage build to ensure an easy sample. This can be run with `make docker-example`.

18
docker-compose.yml Normal file
View File

@ -0,0 +1,18 @@
---
version: '3'
services:
dockron:
build:
context: .
dockerfile: ./Dockerfile.multi-stage
command: ["-watch", "10s", "-debug"]
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
echoer:
image: busybox:latest
command: ["date"]
labels:
# Execute every minute
- 'dockron.schedule=* * * * *'