Skip to content

Commit db4e80f

Browse files
rdelcorroTheDevMinerTV
authored andcommitted
Applied changes from mcuadros#137
1 parent 94edcdf commit db4e80f

21 files changed

+452
-234
lines changed

Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
FROM golang:1.17.1-alpine AS builder
1+
FROM golang:1.18.1-alpine3.15 AS builder
22

3-
RUN apk --no-cache add gcc musl-dev
3+
RUN apk --no-cache add gcc musl-dev git
44

55
WORKDIR ${GOPATH}/src/github.com/mcuadros/ofelia
66
COPY . ${GOPATH}/src/github.com/mcuadros/ofelia
77

88
RUN go build -o /go/bin/ofelia .
99

10-
FROM alpine:3.14.2
10+
FROM alpine:3.16.0
1111

1212
# this label is required to identify container with ofelia running
1313
LABEL ofelia.service=true

README.md

+39-9
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ In order to use this type of configurations, ofelia need access to docker socket
6565
```sh
6666
docker run -it --rm \
6767
-v /var/run/docker.sock:/var/run/docker.sock:ro \
68-
--label ofelia.job-local.my-test-job.schedule="@every 5s" \
69-
--label ofelia.job-local.my-test-job.command="date" \
70-
mcuadros/ofelia:latest daemon --docker
68+
mcuadros/ofelia:latest daemon
7169
```
7270

7371
Labels format: `ofelia.<JOB_TYPE>.<JOB_NAME>.<JOB_PARAMETER>=<PARAMETER_VALUE>.
@@ -86,9 +84,8 @@ docker run -it --rm \
8684
nginx
8785
```
8886

89-
Now if we start `ofelia` container with the command provided above, it will pickup 2 jobs:
87+
Now if we start `ofelia` container with the command provided above, it will execute the task:
9088

91-
- Local - `date`
9289
- Exec - `uname -a`
9390

9491
Or with docker-compose:
@@ -100,12 +97,9 @@ services:
10097
image: mcuadros/ofelia:latest
10198
depends_on:
10299
- nginx
103-
command: daemon --docker
100+
command: daemon
104101
volumes:
105102
- /var/run/docker.sock:/var/run/docker.sock:ro
106-
labels:
107-
ofelia.job-local.my-test-job.schedule: "@every 5s"
108-
ofelia.job-local.my-test-job.command: "date"
109103

110104
nginx:
111105
image: nginx
@@ -115,6 +109,42 @@ services:
115109
ofelia.job-exec.datecron.command: "uname -a"
116110
```
117111
112+
#### Dynamic docker configuration
113+
114+
You can start ofelia in its own container or on the host itself, and it will magically pick up any container that starts, stops or is modified on the fly.
115+
In order to achieve this, you simply have to use docker containers with the labels described above and let ofelia take care of the rest.
116+
117+
#### Hybrid configuration (INI files + Docker)
118+
119+
You can specify part of the configuration on the INI files, such as globals for the middlewares or even declare tasks in there but also merge them with docker.
120+
The docker labels will be parsed, added and removed on the fly but also, the file config can be used.
121+
122+
**Use the INI file to:**
123+
124+
- Configure the slack or other middleware integration
125+
- Configure any global setting
126+
- Create a job-run so it executes on a new container each time
127+
128+
```ini
129+
[global]
130+
slack-webhook = https://myhook.com/auth
131+
132+
[job-run "job-executed-on-new-container"]
133+
schedule = @hourly
134+
image = ubuntu:latest
135+
command = touch /tmp/example
136+
```
137+
138+
**Use docker to:**
139+
140+
```sh
141+
docker run -it --rm \
142+
--label ofelia.enabled=true \
143+
--label ofelia.job-exec.test-exec-job.schedule="@every 5s" \
144+
--label ofelia.job-exec.test-exec-job.command="uname -a" \
145+
nginx
146+
```
147+
118148
### Logging
119149
**Ofelia** comes with three different logging drivers that can be configured in the `[global]` section:
120150
- `mail` to send mails

0 commit comments

Comments
 (0)