-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (38 loc) · 1.45 KB
/
Dockerfile
File metadata and controls
54 lines (38 loc) · 1.45 KB
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
44
45
46
47
48
49
50
51
52
53
54
# Use a pinned Go patch version to match go.mod (go 1.24.13)
FROM golang:1.24.13-alpine as builder
# Set maintainer information
LABEL maintainer="Seakee <seakee23@gmail.com>"
# Set the working directory for the build
WORKDIR /build
# Install git for downloading dependencies
RUN apk add --no-cache git
# Copy the go modules files and download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy the project files
COPY . .
# Build the project in the /build directory
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /build/dudu-admin-api ./main.go
# Use a pinned Alpine major/minor version to avoid drifting with :latest
FROM alpine:3.21
RUN apk --no-cache add ca-certificates
# Set the working directory for runtime
WORKDIR /
# Set the build-time argument for TZ
ARG TZ=Asia/Shanghai
# Set the environment variable for TZ
ENV TZ=$TZ
# Install tzdata for timezone support
RUN apk add --no-cache tzdata && \
cp /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone
# Copy the compiled binary file into the /bin directory of the runtime image
COPY --from=builder /build/dudu-admin-api ./bin
# Copy /bin/lang directory from the builder stage to /bin/lang in the runtime image
COPY --from=builder /build/bin/lang ./bin/lang
# Declare mount points for volumes
VOLUME ["/bin/configs", "/bin/logs"]
# Expose port 8080
EXPOSE 8080
# Set the default command to run when the container starts
ENTRYPOINT ["./bin/dudu-admin-api"]