dc3969cd05
Instead of re-inventing the wheel regarding configuration location handling and validation, this introduces a new command flag `--config` allowing for full flexibility of configuration filename and location. This flag can also be defined via environment variable which allows an easy way of starting the bot from command line, inside a Docker container or using the Helm Chart. It makes the custom environment lookup unnecessary and reduces some complexity during startup and for writing tests. Resolves: #10 Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
49 lines
1.2 KiB
Docker
49 lines
1.2 KiB
Docker
###################################
|
|
# Build stages
|
|
###################################
|
|
FROM golang:1.18-alpine3.15 AS build-go
|
|
|
|
ARG GOPROXY
|
|
ENV GOPROXY ${GOPROXY:-direct}
|
|
|
|
RUN apk update \
|
|
&& apk --no-cache add build-base git bash
|
|
|
|
COPY . ${GOPATH}/src/bot
|
|
WORKDIR ${GOPATH}/src/bot
|
|
|
|
RUN go build ./cmd/gitea-sonarqube-bot
|
|
|
|
###################################
|
|
# Production image
|
|
###################################
|
|
FROM alpine:3.15
|
|
LABEL maintainer="justusbunsi <sk.bunsenbrenner@gmail.com>"
|
|
|
|
RUN apk update \
|
|
&& apk --no-cache add ca-certificates bash \
|
|
&& rm -rf /var/cache/apk/*
|
|
|
|
RUN addgroup -S -g 1000 bot \
|
|
&& adduser -S -D -H -h /home/bot -s /bin/bash -u 1000 -G bot bot
|
|
|
|
RUN mkdir -p /home/bot/config/
|
|
RUN chown bot:bot /home/bot/config/
|
|
|
|
COPY --chown=bot:bot docker /
|
|
COPY --from=build-go --chown=bot:bot /go/src/bot/gitea-sonarqube-bot /usr/local/bin/gitea-sonarqube-bot
|
|
|
|
#bot:bot
|
|
USER 1000:1000
|
|
WORKDIR /home/bot
|
|
ENV HOME=/home/bot
|
|
|
|
EXPOSE 3000
|
|
ENV GIN_MODE "release"
|
|
ENV GITEA_SQ_BOT_CONFIG_PATH "/home/bot/config/config.yaml"
|
|
|
|
VOLUME ["/home/bot/config/"]
|
|
RUN ["chmod", "+x", "/usr/local/bin/docker-entrypoint.sh"]
|
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
|
CMD []
|