-
-
Notifications
You must be signed in to change notification settings - Fork 220
/
Dockerfile
43 lines (37 loc) · 1.78 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
# Stage 1: Builder
FROM golang:1.22.6-alpine AS builder
# Install necessary packages and tools
RUN apk add --no-cache git upx \
&& go install github.com/goreleaser/goreleaser/v2@latest \
&& go install github.com/air-verse/air@latest \
&& go install golang.org/x/tools/cmd/goimports@latest \
&& go install github.com/fzipp/gocyclo/cmd/gocyclo@latest \
&& go install github.com/go-critic/go-critic/cmd/gocritic@latest \
&& go install github.com/BurntSushi/toml/cmd/tomlv@latest \
&& go get -u github.com/go-bindata/go-bindata/... \
&& go install github.com/wangyihang/platypus/cmd/platypus-server@latest \
&& go install github.com/wangyihang/platypus/cmd/platypus-agent@latest \
&& go install github.com/wangyihang/platypus/cmd/platypus-admin@latest
# Set up the working directory
WORKDIR /app
# Copy source code
COPY . .
# Check if the current commit is tagged, and build accordingly
RUN if git describe --tags --exact-match >/dev/null 2>&1; then \
echo "Commit is tagged. Creating a release build."; \
goreleaser build --clean; \
else \
echo "Commit is not tagged. Creating a snapshot build."; \
goreleaser build --clean --snapshot; \
fi
# Stage 2: Final image
FROM ubuntu:24.04
# Copy necessary binaries from the builder stage
COPY --from=builder /go/bin/goreleaser /usr/local/bin/goreleaser
COPY --from=builder /go/bin/air /usr/local/bin/air
COPY --from=builder /go/bin/goimports /usr/local/bin/goimports
COPY --from=builder /go/bin/gocyclo /usr/local/bin/gocyclo
COPY --from=builder /go/bin/gocritic /usr/local/bin/gocritic
COPY --from=builder /go/bin/platypus-server /usr/local/bin/platypus-server
COPY --from=builder /go/bin/platypus-agent /usr/local/bin/platypus-agent
COPY --from=builder /go/bin/platypus-admin /usr/local/bin/platypus-admin