Compare commits

..

2 Commits

Author SHA1 Message Date
c4fa24867c Merge branch 'main' of https://git.gocommunity.ru/chertkov/do_simple
All checks were successful
Build and Push to GHCR / build (push) Successful in 11m27s
2025-11-18 00:02:55 +03:00
5cf40ac153 ci: login on registry 2025-11-18 00:01:58 +03:00
3 changed files with 38 additions and 1 deletions

View File

@ -31,7 +31,7 @@ jobs:
with:
registry: git.gocommunity.ru
username: ${{ secrets.USER }}
password: ${{ secrets.TOKEN }}
password: ${{ secrets.PASSW }}
- name: Build and push Docker image
uses: docker/build-push-action@v5

36
Dockerfile Normal file
View File

@ -0,0 +1,36 @@
# Build stage
FROM golang:1.25-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main ./cmd/.
# Final stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app/main .
# Создать директорию для приложения
WORKDIR /app
COPY --from=builder /app/main .
# Создать non-root пользователя для безопасности
RUN addgroup -g 1001 -S appuser && \
adduser -u 1001 -S appuser -G appuser && \
chown -R appuser:appuser /app
USER appuser
# Установить переменные окружения
ENV PORT=8080
ENV HOST=0.0.0.0
EXPOSE 8080
CMD ["./main"]

View File

@ -12,6 +12,7 @@ func main() {
http.HandleFunc("/", helloHandler)
http.HandleFunc("/health", healthHandler)
// port := "8080"
port := os.Getenv("PORT")
if port == "" {
port = "8080"