first commit
هذا الالتزام موجود في:
34
q1-deploy-monitor/app/Dockerfile
Normal file
34
q1-deploy-monitor/app/Dockerfile
Normal file
@@ -0,0 +1,34 @@
|
||||
# Build stage
|
||||
FROM golang:1.26-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy dependency files first to leverage Docker cache
|
||||
COPY go.mod ./
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN go build -o server .
|
||||
|
||||
|
||||
# Runtime stage
|
||||
FROM alpine:3.20
|
||||
|
||||
# Create a non-root user
|
||||
RUN adduser -D appuser
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the compiled binary
|
||||
COPY --from=builder /app/server .
|
||||
|
||||
# Run as non-root user
|
||||
USER appuser
|
||||
|
||||
# Document the application port
|
||||
EXPOSE 8080
|
||||
|
||||
# Start the application
|
||||
CMD ["./server"]
|
||||
المرجع في مشكلة جديدة
حظر مستخدم