-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
83 lines (63 loc) · 2.01 KB
/
Dockerfile
File metadata and controls
83 lines (63 loc) · 2.01 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Pastebox Engine - Production Dockerfile
# Includes: Go runtime, rclone, FUSE support, MongoDB client
FROM golang:1.21-alpine AS builder
# Install build dependencies
RUN apk add --no-cache git gcc musl-dev
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the router binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o router ./cmd/router
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o pasteboxctl ./cmd/pasteboxctl
# ============================================
# Production image
# ============================================
FROM alpine:3.19
# Install runtime dependencies
RUN apk add --no-cache \
ca-certificates \
fuse3 \
bash \
curl \
openssh-client \
tzdata \
&& rm -rf /var/cache/apk/*
# Install rclone
RUN curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip \
&& unzip rclone-current-linux-amd64.zip \
&& cp rclone-*-linux-amd64/rclone /usr/local/bin/ \
&& chmod +x /usr/local/bin/rclone \
&& rm -rf rclone-* \
&& rclone version
# Enable FUSE for non-root users
RUN echo "user_allow_other" >> /etc/fuse.conf
# Create app user and directories
RUN adduser -D -u 1000 pastebox \
&& mkdir -p /app/data/storage /app/data/mongodb /app/bin /app/logs \
&& chown -R pastebox:pastebox /app
WORKDIR /app
# Copy binaries from builder
COPY --from=builder /app/router /app/router
COPY --from=builder /app/pasteboxctl /app/bin/pasteboxctl
# Copy default config
COPY config.yaml.example /app/config.yaml
# Set permissions
RUN chmod +x /app/router /app/bin/pasteboxctl
# Environment variables
ENV PASTEBOX_STORAGE_PATH=/app/data/storage
ENV PASTEBOX_LOG_LEVEL=info
ENV GIN_MODE=release
# Expose ports
# 8080 - HTTP API
# 2222 - SSH/SFTP
EXPOSE 8080 2222
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# Run as non-root user
USER pastebox
# Start the router
CMD ["/app/router"]