Skip to content

Commit

Permalink
Docker improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Depado committed Nov 12, 2020
1 parent 17fb658 commit df18d4f
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 9 deletions.
15 changes: 12 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,29 @@
FROM golang:1.15.4-alpine3.12 AS builder

# Dependencies
RUN apk update && apk add --no-cache upx
COPY --from=mwader/static-ffmpeg:4.3.1-2 /ffmpeg /tmp/ffmpeg
RUN upx /tmp/ffmpeg

# Source
WORKDIR $GOPATH/src/github.com/Depado/fox
COPY . .
COPY go.mod go.sum ./
RUN go mod download
RUN go mod verify
COPY . .

# Build
ARG build
ARG version
RUN CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=${version} -X main.Build=${build}" -o /tmp/fox
RUN upx /tmp/fox

# Final step
FROM jrottenberg/ffmpeg:3.2-alpine

# Final Step
FROM gcr.io/distroless/static
COPY --from=builder /tmp/fox /go/bin/fox
COPY --from=builder /tmp/ffmpeg /usr/bin/ffmpeg

VOLUME [ "/data" ]
WORKDIR /data
ENTRYPOINT ["/go/bin/fox"]
24 changes: 24 additions & 0 deletions Dockerfile.nopack
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Build Step
FROM golang:1.15.4-alpine3.12 AS builder

# Source
WORKDIR $GOPATH/src/github.com/Depado/fox
COPY go.mod go.sum ./
RUN go mod download
RUN go mod verify
COPY . .

# Build
ARG build
ARG version
RUN CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=${version} -X main.Build=${build}" -o /tmp/fox


# Final Step
FROM gcr.io/distroless/static
COPY --from=builder /tmp/fox /go/bin/fox
COPY --from=mwader/static-ffmpeg:4.3.1-2 /ffmpeg /usr/bin/ffmpeg

VOLUME [ "/data" ]
WORKDIR /data
ENTRYPOINT ["/go/bin/fox"]
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ build: ## Build
compressed: fullbuild
upx --brute $(BINARY)

.PHONY: docker-nopack
docker-nopack: ## Build the docker image without packing binaries
docker build -t $(BINARY)-nopack:latest -t $(BINARY)-nopack:$(BUILD) \
--build-arg build=$(BUILD) --build-arg version=$(VERSION) \
-f Dockerfile.nopack .

.PHONY: docker
docker: ## Build the docker image
docker: ## Build the docker image with packed binaries
docker build -t $(BINARY):latest -t $(BINARY):$(BUILD) \
--build-arg build=$(BUILD) --build-arg version=$(VERSION) \
-f Dockerfile .
Expand Down
11 changes: 8 additions & 3 deletions cmd/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@ type LogConf struct {

type BotConf struct {
Channels ChannelsConf `mapstructure:"channels"`
Roles RolesConf `mapstructure:"roles"`
Guild string `mapstrcture:"guild"`
Token string `mapstructure:"token"`
Prefix string `mapstructure:"prefix"`
}

type ChannelsConf struct {
Public string `mapstructure:"public"`
Control string `mapstructure:"control"`
Voice string `mapstructure:"voice"`
Text string `mapstructure:"text"`
Voice string `mapstructure:"voice"`
}

type RolesConf struct {
Admin string `mapstructure:"admin"`
DJ string `mapstructure:"dj"`
}

type DatabaseConf struct {
Expand Down
5 changes: 3 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ func AddLoggerFlags(c *cobra.Command) {
func AddBotFlags(c *cobra.Command) {
c.PersistentFlags().String("bot.prefix", "!fox", "prefix to call the bot")
c.PersistentFlags().String("bot.guild", "", "guild (server) the bot is connected to")
c.PersistentFlags().String("bot.channels.public", "", "public channel ID where basic commands can be issued")
c.PersistentFlags().String("bot.channels.control", "", "private channel ID (set your roles) where the bot can be controled")
c.PersistentFlags().String("bot.channels.text", "", "text channel ID where some commands can be issued")
c.PersistentFlags().String("bot.channels.voice", "", "voice channel ID the bot will stream to")
c.PersistentFlags().String("bot.roles.admin", "", "role ID for the admins")
c.PersistentFlags().String("bot.roles.dj", "", "role ID for the DJ role")
c.PersistentFlags().String("bot.token", "", "private bot token")
}

Expand Down

0 comments on commit df18d4f

Please sign in to comment.