Compare commits
2 Commits
1b2bc7708e
...
c4fa24867c
| Author | SHA1 | Date | |
|---|---|---|---|
| c4fa24867c | |||
| 5cf40ac153 |
@ -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
36
Dockerfile
Normal 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"]
|
||||
@ -12,6 +12,7 @@ func main() {
|
||||
http.HandleFunc("/", helloHandler)
|
||||
http.HandleFunc("/health", healthHandler)
|
||||
|
||||
// port := "8080"
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = "8080"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user