Dockerfile.dev 902 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Use build arguments for Go version and architecture
  2. ARG GO_VERSION=1.23.2
  3. ARG BUILDARCH
  4. # Stage 1: Build the Go application with swag
  5. FROM golang:${GO_VERSION} AS builder
  6. # Set up working directory
  7. WORKDIR /app
  8. # Install dependencies and copy the source code
  9. COPY go.mod ./
  10. RUN go install github.com/swaggo/swag/cmd/swag@latest
  11. RUN go mod download
  12. COPY . .
  13. #run the build script
  14. RUN chmod +x build.sh && ./build.sh
  15. # Stage 2: Prepare the final image
  16. FROM alpine:latest
  17. # Set up working directory
  18. WORKDIR /app
  19. # Install necessary dependencies
  20. RUN apk add --no-cache tzdata file
  21. # Copy the built application from the builder stage
  22. COPY --from=builder /app/release /app/
  23. # Ensure the binary is correctly built
  24. RUN file /app/apimain
  25. # Set up a volume for persistent data
  26. VOLUME /app/data
  27. # Expose the necessary port
  28. EXPOSE 21114
  29. # Define the command to run the application
  30. CMD ["app/apimain"]