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