# Multi-stage Dockerfile for Investool # Builder stage FROM golang:tip-alpine3.23 AS builder WORKDIR /src # Copy go module files first for cached dependencies COPY go.mod go.sum ./ RUN go mod download # Copy the rest of the source code COPY . . # Build the binary RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X github.com/axiaoxin-com/investool/version.Version=`TZ=Asia/Shanghai date +'%y%m%d%H%M'`" -o investool # Runtime stage FROM alpine:3.19 # Install CA certificates for HTTPS requests RUN apk update && apk add --no-cache ca-certificates WORKDIR /srv/investool # Copy the built binary and the config COPY --from=builder /src/investool ./investool COPY config.toml ./config.toml # Expose the API/Web ports used by Investool EXPOSE 4869 4870 ENTRYPOINT ["./investool", "-c", "./config.toml"]
# .dockerignore # Ignore git and editor specific files .git .gitignore *.md *.log .idea .vscode .DS_Store vendor node_modules __pycache__ *.pyc build.sh Dockerfile
Build timed out after 600s
# Multi-stage Dockerfile for Investool # Builder stage FROM golang:1.20-alpine3.23 AS builder WORKDIR /src # Copy go module files first for cached dependencies COPY go.mod go.sum ./ RUN go mod download # Copy the rest of the source code COPY . . # Build the binary RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X github.com/axiaoxin-com/investool/version.Version=`TZ=Asia/Shanghai date +'%y%m%d%H%M'`" -o investool # Runtime stage FROM alpine:3.19 # Install CA certificates for HTTPS requests RUN apk update && apk add --no-cache ca-certificates WORKDIR /srv/investool # Copy the built binary and the config COPY --from=builder /src/investool ./investool COPY config.toml ./config.toml # Expose the API/Web ports used by Investool EXPOSE 4869 4870 ENTRYPOINT ["./investool", "-c", "./config.toml"]
# Multi-stage Dockerfile for Investool # Builder stage FROM golang:tip-alpine3.23 AS builder WORKDIR /src # Copy go module files first for cached dependencies COPY go.mod go.sum ./ RUN go mod download # Copy the rest of the source code COPY . . # Build the binary RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X github.com/axiaoxin-com/investool/version.Version=`TZ=Asia/Shanghai date +'%y%m%d%H%M'`" -o investool # Runtime stage FROM alpine:3.19 # Install CA certificates for HTTPS requests RUN apk update && apk add --no-cache ca-certificates WORKDIR /srv/investool # Copy the built binary and the config COPY --from=builder /src/investool ./investool COPY config.toml ./config.toml # Expose the API/Web ports used by Investool EXPOSE 4869 4870 ENTRYPOINT ["./investool", "-c", "./config.toml"]
Build timed out after 600s
Image golang:alpine exists on Docker Hub.
Image golang:tip-alpine3.23 exists on Docker Hub.
# Multi-stage Dockerfile for Investool # Builder stage FROM golang:tip-alpine3.23 AS builder WORKDIR /src # Copy go module files first for cached dependencies COPY go.mod go.sum ./ RUN go mod download # Copy the rest of the source code COPY . . # Build the binary RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X github.com/axiaoxin-com/investool/version.Version=`TZ=Asia/Shanghai date +'%y%m%d%H%M'`" -o investool # Runtime stage FROM alpine:3.19 # Install CA certificates for HTTPS requests RUN apk update && apk add --no-cache ca-certificates WORKDIR /srv/investool # Copy the built binary and the config COPY --from=builder /src/investool ./investool COPY config.toml ./config.toml # Expose the API/Web ports used by Investool EXPOSE 4869 4870 ENTRYPOINT ["./investool", "-c", "./config.toml"]
Build timed out after 600s
# Multi-stage Dockerfile for Investool # Builder stage FROM golang:tip-alpine3.23 AS builder WORKDIR /src # Copy go module files first for cached dependencies COPY go.mod go.sum ./ RUN go mod download # Copy the rest of the source code COPY . . # Build the binary RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X github.com/axiaoxin-com/investool/version.Version=`TZ=Asia/Shanghai date +'%y%m%d%H%M'`" -o investool # Runtime stage FROM alpine:3.19 # Install CA certificates for HTTPS requests RUN apk update && apk add --no-cache ca-certificates WORKDIR /srv/investool # Copy the built binary and the config COPY --from=builder /src/investool ./investool COPY config.toml ./config.toml # Create a non-root user for runtime RUN adduser -D -S investool RUN chown investool:investool ./investool ./config.toml USER investool # Expose the API/Web ports used by Investool EXPOSE 4869 4870 ENTRYPOINT ["./investool", "-c", "./config.toml"]
Build timed out after 600s
FROM golang:1.20-alpine3.19 AS builder
WORKDIR /src
# Cache mod download
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the source
COPY . .
# Build the binary with version injected
RUN V=$(TZ=Asia/Shanghai date +'%y%m%d%H%M') && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags "-X github.com/axiaoxin-com/investool/version.Version=${V}" -o investool
# Runtime image
FROM alpine:3.19
# Install CA certificates for TLS
RUN apk add --no-cache ca-certificates
WORKDIR /srv/investool
# Copy binary and config
COPY --from=builder /src/investool /srv/investool/investool
COPY config.toml ./config.toml
EXPOSE 4869 4870
ENTRYPOINT ["./investool", "-c", "./config.toml"]
# Ignore VCS and dependencies .git .gitignore vendor/ node_modules/ dist/ *.tar.gz *.log *.out *.exe *.dll *.so *.dylib .DS_Store
Build timed out after 600s
FROM golang:1.20-alpine3.19 AS builder
RUN apk add --no-cache git ca-certificates
WORKDIR /src
# Cache mod download
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the source
COPY . .
# Build the binary with version injected
RUN V=$(TZ=Asia/Shanghai date +'%y%m%d%H%M') && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags "-X github.com/axiaoxin-com/investool/version.Version=${V}" -o investool
# Runtime image
FROM alpine:3.19
# Install CA certificates for TLS
RUN apk add --no-cache ca-certificates
WORKDIR /srv/investool
# Copy binary and config
COPY --from=builder /src/investool /srv/investool/investool
COPY config.toml ./config.toml
EXPOSE 4869 4870
ENTRYPOINT ["./investool", "-c", "./config.toml"]
Build timed out after 600s
FROM golang:1.20-alpine3.19 AS builder
# Ensure git is available for modules that may fetch from VCS
RUN apk add --no-cache git
WORKDIR /src
# Cache module downloads
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the source
COPY . .
# Build the binary with version injected
RUN V=$(TZ=Asia/Shanghai date +'%y%m%d%H%M') && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -trimpath -ldflags "-s -w -X github.com/axiaoxin-com/investool/version.Version=${V}" -o investool
# Runtime image
FROM alpine:3.19
# Install CA certificates for TLS
RUN apk add --no-cache ca-certificates
WORKDIR /srv/investool
# Copy binary and config
COPY --from=builder /src/investool /srv/investool/investool
COPY config.toml ./config.toml
EXPOSE 4869 4870
ENTRYPOINT ["./investool", "-c", "./config.toml"]
Build timed out after 600s
FROM golang:1.20-alpine3.19 AS builder
# Speed up module downloads
ENV GOPROXY=https://goproxy.cn,direct
ENV CGO_ENABLED=0
# Ensure git is available for module fetches and CA certs for TLS
RUN apk add --no-cache git ca-certificates
WORKDIR /src
# Cache module downloads
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the source
COPY . .
# Build the binary with version injected
RUN V=$(TZ=Asia/Shanghai date +'%y%m%d%H%M') && \
GOOS=linux GOARCH=amd64 \
go build -trimpath -ldflags "-s -w -X github.com/axiaoxin-com/investool/version.Version=${V}" -o investool
# Runtime image
FROM alpine:3.19
# Install CA certificates for TLS
RUN apk add --no-cache ca-certificates
WORKDIR /srv/investool
# Copy binary and config
COPY --from=builder /src/investool /srv/investool/investool
COPY config.toml ./config.toml
EXPOSE 4869 4870
ENTRYPOINT ["./investool", "-c", "./config.toml"]
Build timed out after 600s
FROM golang:tip-alpine3.23 AS builder WORKDIR /src # Install build dependencies RUN apk add --no-cache git ca-certificates # Cache module downloads COPY go.mod go.sum ./ RUN go mod download # Copy the source code COPY . . # Build the binary with version injected RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X github.com/axiaoxin-com/investool/version.Version=`TZ=Asia/Shanghai date +'%y%m%d%H%M'`" -o investool FROM alpine:3.23 AS runtime # Ensure certificates are present for TLS RUN apk --no-cache add ca-certificates WORKDIR /srv/investool # Copy the built binary and config COPY --from=builder /src/investool ./investool COPY --from=builder /src/config.toml ./config.toml EXPOSE 4869 4870 ENTRYPOINT ["./investool", "-c", "./config.toml"]
Build timed out after 600s
Build timed out after 600s
FROM golang:1.20-alpine3.18 AS builder WORKDIR /src # Install build dependencies RUN apk add --no-cache git ca-certificates # Cache module downloads COPY go.mod go.sum ./ RUN go mod download # Copy the source code COPY . . # Build the binary with version injected RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X github.com/axiaoxin-com/investool/version.Version=$(TZ=Asia/Shanghai date +'%y%m%d%H%M')" -o investool FROM alpine:3.23 AS runtime # Ensure certificates are present for TLS RUN apk --no-cache add ca-certificates WORKDIR /srv/investool # Copy files from builder COPY --from=builder /src/investool ./investool COPY --from=builder /src/config.toml ./config.toml COPY --from=builder /src/statics ./statics EXPOSE 4869 4870 ENTRYPOINT ["./investool", "-c", "./config.toml"]
Build timed out after 600s
# Exclude version control .git # OS files .DS_Store # Local env files .env # Misc directories not needed for build misc/scripts/ misc/docs/ misc/pics/ misc/data/ # Build artifacts dist/ *.tar.gz *.exe # Documentation and tests (not needed for runtime image) README.md CHANGELOG.md # Docker related Dockerfile
Build timed out after 600s
FROM golang:1.20-alpine3.18 AS builder # Speed up module download with a Go proxy ENV GOPROXY=https://goproxy.cn,direct WORKDIR /src # Install build dependencies RUN apk add --no-cache git ca-certificates # Cache module downloads COPY go.mod go.sum ./ RUN go mod download # Copy the source code COPY . . # Build the binary with version injected RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X github.com/axiaoxin-com/investool/version.Version=$(TZ=Asia/Shanghai date +'%y%m%d%H%M')" -o investool FROM alpine:3.23 AS runtime # Ensure certificates are present for TLS RUN apk --no-cache add ca-certificates WORKDIR /srv/investool # Copy files from builder COPY --from=builder /src/investool ./investool COPY --from=builder /src/config.toml ./config.toml COPY --from=builder /src/statics ./statics EXPOSE 4869 4870 ENTRYPOINT ["./investool", "-c", "./config.toml"]
Build timed out after 600s