Add production Dockerfile
Signed-off-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>
This commit is contained in:
parent
8678f13911
commit
a51520382e
7
.dockerignore
Normal file
7
.dockerignore
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
**
|
||||||
|
!/cmd
|
||||||
|
!/internal
|
||||||
|
!/vendor
|
||||||
|
!/docker
|
||||||
|
!go.mod
|
||||||
|
!go.sum
|
47
Dockerfile
Normal file
47
Dockerfile
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
###################################
|
||||||
|
# Build stages
|
||||||
|
###################################
|
||||||
|
FROM golang:1.17-alpine3.14 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.14
|
||||||
|
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"
|
||||||
|
|
||||||
|
VOLUME ["/home/bot/config/"]
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||||
|
CMD []
|
7
docker/usr/local/bin/docker-entrypoint.sh
Normal file
7
docker/usr/local/bin/docker-entrypoint.sh
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ $# -gt 0 ]; then
|
||||||
|
exec "$@"
|
||||||
|
else
|
||||||
|
exec /usr/local/bin/gitea-sonarqube-bot
|
||||||
|
fi
|
Loading…
Reference in a new issue