Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
- Disable http server on default (on binary)
- Enable http server and metrics on Docker images
- Enable JSON log per default on Docker images
- Add debian, ubuntu und alpine Docker images

Signed-off-by: Markus Blaschke <mblaschke82@gmail.com>
  • Loading branch information
mblaschke committed Jul 1, 2020
1 parent 7656d83 commit 7143bdf
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 15 deletions.
6 changes: 5 additions & 1 deletion Dockerfile → Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ RUN make build-local
# FINAL IMAGE
#############################################
FROM alpine
ENV SERVER_BIND=":8080" \
SERVER_METRICS="1" \
LOG_JSON="1"
COPY --from=build /go/src/github.com/webdevops/go-crond/go-crond /usr/local/bin
CMD ["go-crond"]
EXPOSE 8080
ENTRYPOINT ["go-crond"]
24 changes: 24 additions & 0 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM golang:1.14 as build

WORKDIR /go/src/github.com/webdevops/go-crond

# Get deps (cached)
COPY ./go.mod /go/src/github.com/webdevops/go-crond
COPY ./go.sum /go/src/github.com/webdevops/go-crond
RUN go mod download

# Compile
COPY ./ /go/src/github.com/webdevops/go-crond
RUN make lint
RUN make build-local

#############################################
# FINAL IMAGE
#############################################
FROM debian:stable-slim
ENV SERVER_BIND=":8080" \
SERVER_METRICS="1" \
LOG_JSON="1"
COPY --from=build /go/src/github.com/webdevops/go-crond/go-crond /usr/local/bin
EXPOSE 8080
ENTRYPOINT ["go-crond"]
3 changes: 3 additions & 0 deletions Dockerfile.develop
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,7 @@ COPY . /go/src/github.com/webdevops/go-crond
RUN make build-local \
&& cp -a go-crond /usr/local/bin

ENV SERVER_BIND=":8080" \
SERVER_METRICS="1"

CMD ["./go-crond"]
24 changes: 24 additions & 0 deletions Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM golang:1.14 as build

WORKDIR /go/src/github.com/webdevops/go-crond

# Get deps (cached)
COPY ./go.mod /go/src/github.com/webdevops/go-crond
COPY ./go.sum /go/src/github.com/webdevops/go-crond
RUN go mod download

# Compile
COPY ./ /go/src/github.com/webdevops/go-crond
RUN make lint
RUN make build-local

#############################################
# FINAL IMAGE
#############################################
FROM ubuntu:latest
ENV SERVER_BIND=":8080" \
SERVER_METRICS="1" \
LOG_JSON="1"
COPY --from=build /go/src/github.com/webdevops/go-crond/go-crond /usr/local/bin
EXPOSE 8080
ENTRYPOINT ["go-crond"]
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ Inspired by https://github.com/anarcher/go-cron

Using https://godoc.org/github.com/robfig/cron

## Docker images

on [Docker hub](https://hub.docker.com/repository/docker/webdevops/go-crond/tags)

- `webdevops/go-crond:alpine` (based on `alpine`)
- `webdevops/go-crond:ubuntu` (based on `ubuntu:latest`)
- `webdevops/go-crond:debian` (based on `debian:stable-slim`)
- `webdevops/go-crond:{version}-alpine` (based on `alpine`)
- `webdevops/go-crond:{version}-ubuntu` (based on `ubuntu:latest`)
- `webdevops/go-crond:{version}-debian` (based on `debian:stable-slim`)

## Features

Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ var opts struct {
ShowHelp bool `short:"h" long:"help" description:"show this help message"`

// logger
Verbose bool `short:"v" long:"verbose" description:"verbose mode"`
LogJson bool ` long:"log.json" description:"Switch log output to json format"`
Verbose bool `short:"v" long:"verbose" env:"VERBOSE" description:"verbose mode"`
LogJson bool ` long:"log.json" env:"LOG_JSON" description:"Switch log output to json format"`

// server settings
ServerBind string `long:"server.bind" env:"SERVER_BIND" description:"Server address (eg. prometheus metrics)" default:":8080"`
ServerBind string `long:"server.bind" env:"SERVER_BIND" description:"Server address, eg. ':8080' (/healthz and /metrics for prometheus)" default:""`
ServerMetrics bool `long:"server.metrics" env:"SERVER_METRICS" description:"Enable prometheus metrics (do not use senstive informations in commands -> use environment variables or files for storing these informations)"`
}

Expand Down
11 changes: 0 additions & 11 deletions release/Dockerfile

This file was deleted.

0 comments on commit 7143bdf

Please sign in to comment.