-
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor build configuration to use latest goreleaser version and opt…
…imize platform combinations
- Loading branch information
1 parent
3934b41
commit 2c1f71b
Showing
3 changed files
with
38 additions
and
4,540 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,44 @@ | ||
# 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/[email protected] \ | ||
&& 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 | ||
FROM golang:1.23.2 AS builder | ||
|
||
# # replace shell with bash so we can source files | ||
RUN rm /bin/sh && ln -s /bin/bash /bin/sh | ||
|
||
# Install necessary golang packages and tools | ||
RUN go env -w GO111MODULE=on | ||
RUN go env -w GOPROXY=https://goproxy.cn,direct | ||
RUN go install github.com/goreleaser/goreleaser/v2@latest | ||
RUN go install github.com/air-verse/air@latest | ||
RUN go install golang.org/x/tools/cmd/goimports@latest | ||
RUN go install github.com/fzipp/gocyclo/cmd/gocyclo@latest | ||
RUN go install github.com/go-critic/go-critic/cmd/gocritic@latest | ||
RUN go install github.com/BurntSushi/toml/cmd/tomlv@latest | ||
|
||
# Installs nvm (Node Version Manager) | ||
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash | ||
|
||
# Download and install Node.js (you may need to restart the terminal) | ||
RUN source ~/.nvm/nvm.sh \ | ||
&& nvm install 20 \ | ||
&& nvm alias default 20 \ | ||
&& nvm use default \ | ||
&& npm config set registry https://registry.npmmirror.com/ \ | ||
&& npm install -g yarn | ||
|
||
# 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 | ||
# Download golang dependencies | ||
RUN /usr/local/go/bin/go mod download | ||
|
||
# Download web dependencies | ||
RUN source ~/.nvm/nvm.sh \ | ||
&& cd web/platypus \ | ||
&& yarn install \ | ||
&& yarn build | ||
|
||
# Build the application | ||
RUN goreleaser build --snapshot --clean --single-target |
Oops, something went wrong.