Исправлен workflow - 10 для сборки и релиза

This commit is contained in:
2025-07-27 14:16:54 +06:00
parent 3734143548
commit c5e580c627
4 changed files with 221 additions and 10 deletions

46
Dockerfile Normal file
View File

@@ -0,0 +1,46 @@
# Build stage
FROM golang:1.21-alpine AS builder
# Install git and ca-certificates
RUN apk --no-cache add git ca-certificates
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o hello-api main.go
# Final stage
FROM alpine:latest
# Install jq and ca-certificates
RUN apk --no-cache add ca-certificates jq
# Create non-root user
RUN addgroup -g 1001 -S appgroup && \
adduser -u 1001 -S appuser -G appgroup
WORKDIR /app
# Copy binary from builder stage
COPY --from=builder /app/hello-api .
# Change ownership to non-root user
RUN chown appuser:appgroup hello-api
# Switch to non-root user
USER appuser
# Expose port (if your app uses one)
EXPOSE 8080
# Run the application
CMD ["./hello-api"]