-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathDockerfile
More file actions
87 lines (71 loc) · 2.42 KB
/
Dockerfile
File metadata and controls
87 lines (71 loc) · 2.42 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# syntax=docker/dockerfile:1
#
# Stage: Initial bin build
#
FROM --platform=$BUILDPLATFORM golang:1.26.1-alpine AS stage-bin
WORKDIR /app
# Use mount cache for dependencies
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
go mod download -x
ARG VERSION
ARG COMMIT
ARG COMMIT_DATE
ARG TARGETARCH
ARG TARGETOS
# Build platform-specific
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=bind,target=. \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build \
-trimpath \
-ldflags="-w -s \
-X github.com/grishy/any-sync-bundle/cmd.version=${VERSION} \
-X github.com/grishy/any-sync-bundle/cmd.commit=${COMMIT} \
-X github.com/grishy/any-sync-bundle/cmd.date=${COMMIT_DATE}" \
-o /bin/any-sync-bundle
#
# Stage: stage-release-minimal
#
FROM gcr.io/distroless/static-debian12 AS stage-release-minimal
# Bundle network ports
EXPOSE 33010
EXPOSE 33020/udp
VOLUME /data
COPY --from=stage-bin /bin/any-sync-bundle /usr/local/bin/any-sync-bundle
ENTRYPOINT ["/usr/local/bin/any-sync-bundle"]
CMD ["start-bundle"]
#
# Stage: stage-release-all-in-one
#
FROM docker.io/redis/redis-stack-server:7.4.0-v7 AS stage-release-all-in-one
# Bundle network ports
EXPOSE 33010
EXPOSE 33020/udp
VOLUME /data
# Install prerequisites and MongoDB
RUN DEBIAN_FRONTEND=noninteractive \
&& apt-get update && apt-get install -y --no-install-recommends \
gnupg \
curl \
ca-certificates \
# Install MongoDB
&& curl -fsSL https://pgp.mongodb.com/server-8.0.asc | gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor \
&& echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] http://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/8.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-8.0.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends mongodb-org-server \
# Remove unnecessary packages
&& apt-get remove -y gnupg curl python3-pip \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf \
/var/lib/apt/lists/* \
/tmp/* \
/var/tmp/* \
/usr/share/keyrings/mongodb-server-8.0.gpg \
/etc/apt/sources.list.d/mongodb-org-8.0.list
COPY --from=stage-bin /bin/any-sync-bundle /usr/local/bin/any-sync-bundle
ENTRYPOINT ["/usr/local/bin/any-sync-bundle"]
CMD ["start-all-in-one"]