Add example compose
This commit is contained in:
parent
916e518f5b
commit
5c5fda3ddf
20
Makefile
20
Makefile
@ -4,11 +4,13 @@ GIT_TAG_NAME := $(shell git tag -l --contains HEAD)
|
||||
GIT_SHA := $(shell git rev-parse HEAD)
|
||||
VERSION := $(if $(GIT_TAG_NAME),$(GIT_TAG_NAME),$(GIT_SHA))
|
||||
|
||||
GOFILES = *.go go.mod go.sum
|
||||
|
||||
.PHONY: default
|
||||
default: build
|
||||
|
||||
# Downloads dependencies into vendor directory
|
||||
vendor:
|
||||
vendor: $(GOFILES)
|
||||
go mod vendor
|
||||
|
||||
# Runs the application, useful while developing
|
||||
@ -34,7 +36,7 @@ check:
|
||||
pre-commit run --all-files
|
||||
|
||||
# Output target
|
||||
dockron:
|
||||
dockron: $(GOFILES)
|
||||
@echo Version: $(VERSION)
|
||||
go build -ldflags '-X "main.version=${VERSION}"' -o dockron
|
||||
|
||||
@ -42,22 +44,22 @@ dockron:
|
||||
.PHONY: build
|
||||
build: dockron
|
||||
|
||||
dockron-darwin-amd64:
|
||||
dockron-darwin-amd64: $(GOFILES)
|
||||
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 \
|
||||
go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \
|
||||
-o dockron-darwin-amd64
|
||||
|
||||
dockron-linux-amd64:
|
||||
dockron-linux-amd64: $(GOFILES)
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
|
||||
go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \
|
||||
-o dockron-linux-amd64
|
||||
|
||||
dockron-linux-arm:
|
||||
dockron-linux-arm: $(GOFILES)
|
||||
GOOS=linux GOARCH=arm CGO_ENABLED=0 \
|
||||
go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \
|
||||
-o dockron-linux-arm
|
||||
|
||||
dockron-linux-arm64:
|
||||
dockron-linux-arm64: $(GOFILES)
|
||||
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 \
|
||||
go build -ldflags '-X "main.version=${VERSION}"' -a -installsuffix nocgo \
|
||||
-o dockron-linux-arm64
|
||||
@ -124,3 +126,9 @@ docker-staged-build-arm64:
|
||||
docker build --build-arg VERSION=${VERSION} \
|
||||
--build-arg REPO=arm64v8 --build-arg ARCH=arm64 -t ${DOCKER_TAG}-linux-arm64 \
|
||||
-f Dockerfile.multi-stage .
|
||||
|
||||
.PHONY: docker-example
|
||||
docker-example:
|
||||
# Uses multistage
|
||||
docker-compose build
|
||||
docker-compose up
|
||||
|
@ -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.
|
||||
|
||||
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.
|
||||
|
||||
@ -53,3 +53,5 @@ Either use a separate tool in conjunction with Dockron, or use a more robust sch
|
||||
## 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`
|
||||
|
||||
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
18
docker-compose.yml
Normal 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=* * * * *'
|
Loading…
Reference in New Issue
Block a user