-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile
43 lines (28 loc) · 1015 Bytes
/
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
FROM golang:1.23.3-alpine AS builder
WORKDIR /go/src/app
RUN apk update && \
apk add upx ca-certificates tzdata git
ARG VERSION=main
ARG BUILD="N/A"
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux
COPY go.mod go.sum /go/src/app/
RUN go mod download \
&& go mod tidy
COPY . /go/src/app/
RUN go build -a -installsuffix cgo -ldflags="-w -s -X github.com/AkashRajpurohit/git-sync/pkg/version.Version=${VERSION} -X github.com/AkashRajpurohit/git-sync/pkg/version.Build=${BUILD}" -o git-sync . \
&& upx -q git-sync
# Application image
FROM alpine:latest
WORKDIR /opt/go
LABEL maintainer="AkashRajpurohit <me@akashrajpurohit.com>"
# Install git since it's required for the application
RUN apk update && \
apk add git su-exec
RUN mkdir -p /git-sync /backups
COPY --from=builder /go/src/app/git-sync /opt/go/git-sync
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh", "/opt/go/git-sync"]
CMD ["--config", "/git-sync/config.yaml", "--backup-dir", "/backups"]