forked from gabrie30/ghorg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
55 lines (42 loc) · 1.55 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# ==================================================
# Build image
# ==================================================
FROM golang:alpine AS build-image
# ENV GO111MODULE=on
ENV CGO_ENABLED=0
WORKDIR /go/src/github.com/gabrie30/ghorg
COPY . .
RUN go get -d -v ./... \
&& go build -a --mod vendor -o ghorg .
# ==================================================
# Runtime image
# ==================================================
FROM alpine:latest AS runtime-image
ARG USER=ghorg
ARG GROUP=ghorg
ARG UID=1111
ARG GID=2222
ENV XDG_CONFIG_HOME=/config
ENV GHORG_CONFIG=/config/conf.yaml
ENV GHORG_RECLONE_PATH=/config/reclone.yaml
ENV GHORG_ABSOLUTE_PATH_TO_CLONE_TO=/data
RUN apk add -U --no-cache ca-certificates openssh-client tzdata git \
&& mkdir -p /data $XDG_CONFIG_HOME \
&& addgroup --gid $GID $GROUP \
&& adduser -D -H --gecos "" \
--home "/home" \
--ingroup "$GROUP" \
--uid "$UID" \
"$USER" \
&& chown -R $USER:$GROUP /home /data $XDG_CONFIG_HOME \
&& rm -rf /tmp/* /var/{cache,log}/* /var/lib/apt/lists/*
USER $USER
WORKDIR /data
# Sample config
COPY --from=build-image --chown=$USER:$GROUP /go/src/github.com/gabrie30/ghorg/sample-conf.yaml /config/conf.yaml
COPY --from=build-image --chown=$USER:$GROUP /go/src/github.com/gabrie30/ghorg/sample-reclone.yaml /config/reclone.yaml
# Copy compiled binary
COPY --from=build-image --chown=$USER:$GROUP /go/src/github.com/gabrie30/ghorg/ghorg /usr/local/bin
VOLUME /data
ENTRYPOINT ["ghorg"]
CMD ["--help"]